Category-level smooths for different auto types
Now you extend your models to include different smooths for different levels of categorical terms.
Deze oefening maakt deel uit van de cursus
Nonlinear Modeling with Generalized Additive Models (GAMs) in R
Oefeninstructies
- Fit a model to predict city fuel efficiency (
city.mpg) with smooth terms ofweight,length, andprice, but make each of these smooth terms depend on thedrivecategorical variable usingby=in the smooth terms. - Include a separate linear term for the
drivevariable.
Praktische interactieve oefening
Probeer deze oefening eens door deze voorbeeldcode in te vullen.
library(mgcv)
# Fit the model
mod_city3 <- gam(city.mpg ~ ___,
data = mpg, method = "REML")
# Plot the model
plot(mod_city3, pages = 1)