収量を予測してみましょう
モデリングの楽しいところは、モデルを使って予測することです。これは次のように predict() を呼び出して行います。
predict(model, cases_to_predict, type = "response")
mgcv と dplyr は読み込まれており、トウモロコシと小麦のデータセットに対する GAM はそれぞれ corn_model と wheat_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 = ___)