始める無料で始める

交互作用を使って手計算で予測する

predict() がどのように動くかを理解するために、もう一度予測を手計算してみましょう。このモデルでは、計算すべき直線が3本あり、いずれも「切片 + 傾き × 数値の説明変数」という形で予測します。ポイントは、各ケースに対して正しい切片と正しい傾きを選ぶことです。

mdl_price_vs_both_interexplanatory_data が利用可能です。dplyrtidyr も利用可能です。

この演習はコースの一部です

Rで学ぶ中級回帰分析

コースを見る

実践的なインタラクティブ演習

このサンプルコードを完成させて、この演習に挑戦してみましょう。

# Get the coefficients from mdl_price_vs_both_inter
coeffs <- ___

# Get the intercept for 0 to 15 year age group
intercept_0_15 <- ___

# Get the intercept for 15 to 30 year age group
intercept_15_30 <- ___

# Get the intercept for 30 to 45 year age group
intercept_30_45 <- ___

# Get the slope for 0 to 15 year age group
slope_0_15 <- ___

# Get the slope for 15 to 30 year age group
slope_15_30 <- ___

# Get the slope for 30 to 45 year age group
slope_30_45 <- ___
コードを編集して実行