Motorcycle crash data: non-linear approach
Now you will fit a non-linear model to the same mcycle data using the gam() function from
the mgcv package.
Deze oefening maakt deel uit van de cursus
Nonlinear Modeling with Generalized Additive Models (GAMs) in R
Oefeninstructies
- Load the
mgcvpackage. - Fit a model to the
mcycledata whereaccelhas a smooth, nonlinear relation totimesusing thegam()function. - Visualize the model fit using the provided call to
plot().
Praktische interactieve oefening
Probeer deze oefening eens door deze voorbeeldcode in te vullen.
# Load mgcv
___
# Fit the model
gam_mod <- gam(___ ~ s(___), data = mcycle)
# Plot the results
plot(gam_mod, residuals = TRUE, pch = 1)