開始使用免費開始

進行產量預測

建模最有趣的部分,就是用模型來做預測。你可以用 predict() 來完成,格式如下:

predict(model, cases_to_predict, type = "response")

已載入 mgcvdplyr;玉米與小麥資料集的 GAM 已分別存在 corn_modelwheat_model。人口普查分區的字元向量已儲存在 census_regions

本練習屬於課程

R 函式撰寫入門

檢視課程

動手互動練習

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

# Make predictions in 2050  
predict_this <- data.frame(
  year = ___,
  census_region = census_regions
) 

# Predict the yield
pred_yield_kg_per_ha <- ___(___, ___, type = "response")

predict_this %>%
  # Add the prediction as a column of predict_this 
  ___(pred_yield_kg_per_ha = ___)
編輯並執行程式碼