ベイズモデルのR二乗
ここでは、stan_glm で推定したモデルの予測を評価するために、ベイズモデルの R 二乗を計算します。stan_model オブジェクトはすでに読み込まれています。
この演習はコースの一部です
rstanarm で学ぶベイズ回帰モデリング
演習の手順
stan_modelの残差の分散を計算しますstan_modelの当てはめ値の分散を計算します- R 二乗を計算します
実践的なインタラクティブ演習
このサンプルコードを完成させて、この演習に挑戦してみましょう。
# Save the variance of residulas
ss_res <- ___(___(stan_model))
# Save the variance of fitted values
ss_fit <- ___(___(stan_model))
# Calculate the R-squared
1 - (___ / (___ + ___))