決定係数を比較する
決定係数は、線形回帰直線が観測値にどれだけよく当てはまっているかを示す指標です。線形回帰に複数の説明変数を含める重要な動機は、単一の説明変数だけを考える場合と比べて当てはまりを改善できる可能性があるためです。
ここでは、台湾の住宅価格モデル3つの決定係数を比較し、どれが最も良い結果を与えるかを確認します。
mdl_price_vs_conv、mdl_price_vs_age、mdl_price_vs_both が利用できます。dplyr と broom は読み込まれています。
この演習はコースの一部です
Rで学ぶ中級回帰分析
実践的なインタラクティブ演習
このサンプルコードを完成させて、この演習に挑戦してみましょう。
mdl_price_vs_conv %>%
# Get the model-level coefficients
___ %>%
# Select the coeffs of determination
___
# Get the coeffs of determination for mdl_price_vs_age
mdl_price_vs_age %>%
___ %>%
___
# Get the coeffs of determination for mdl_price_vs_both
mdl_price_vs_both %>%
___ %>%
___