Plotting multiple auto performance variables
In plotting GAMs, you sometimes want to look at just parts of a model, or all the terms in model. Here you'll practice selecting which terms to visualize.
Deze oefening maakt deel uit van de cursus
Nonlinear Modeling with Generalized Additive Models (GAMs) in R
Oefeninstructies
- Plot the provided model (
mod) that uses thempgdata, using theselectterm to view only the partial effect ofprice. - Make another plot, this time showing all terms on a single page, including the linear
comp.ratioterm.
Praktische interactieve oefening
Probeer deze oefening eens door deze voorbeeldcode in te vullen.
library(mgcv)
# Fit the model
mod <- gam(hw.mpg ~ s(weight) + s(rpm) + s(price) + comp.ratio,
data = mpg, method = "REML")
# Plot the price effect
___
# Plot all effects
___