Exercise

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.

Instructions 1/2

undefined XP
    1
    2
  • In predict_this, set the prediction year to 2050.
  • Predict the yield using corn_model and the cases specified in predict_this.
  • Mutate predict_this to add the prediction vector as a new column named pred_yield_kg_per_ha.