Making yield predictions
The fun part of modeling is using the models to make predictions. You can do this using a call to predict(), in the following form.
predict(model, cases_to_predict, type = "response")
mgcv and dplyr are loaded; GAMs of the corn and wheat datasets are available as corn_model and wheat_model. A character vector of census regions is stored as census_regions.
แบบฝึกหัดนี้เป็นส่วนหนึ่งของหลักสูตร
Introduction to Writing Functions in 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 = ___)