CommencerCommencer gratuitement

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.

Cet exercice fait partie du cours

Introduction to Writing Functions in R

Afficher le cours

Exercice interactif pratique

Essayez cet exercice en complétant cet exemple de code.

# 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 = ___)
Modifier et exécuter le code