開始使用免費開始

使用平行斜率模型進行預測

雖然 ggplot 能自動顯示模型預測,但如果你想在程式中取用這些數值,就需要自己計算。

和只有一個解釋變數的情況一樣,流程分成兩步:先建立包含解釋變數的資料框,再加入一個預測值欄位。為了確認答案正確,你可以把自己的預測用 geom_parallel_slopes() 加到 ggplot 上查看。

taiwan_real_estatemdl_price_vs_both 已可使用;已載入 dplyrtidyrggplot2

本練習屬於課程

R 的迴歸分析中級

檢視課程

動手互動練習

試著完成這個範例程式碼,體驗一下這個練習。

# Make a grid of explanatory data
explanatory_data <- ___(
  # Set n_convenience to zero to ten
  ___,
  # Set house_age_years to the unique values of that variable
  ___
)

# See the result
explanatory_data
編輯並執行程式碼