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.
Este exercício faz parte do curso
Nonlinear Modeling with Generalized Additive Models (GAMs) in R
Instruções do exercício
- Load the
mgcv
package. - Fit a model to the
mcycle
data whereaccel
has a smooth, nonlinear relation totimes
using thegam()
function. - Visualize the model fit using the provided call to
plot()
.
Exercício interativo prático
Experimente este exercício completando este código de exemplo.
# Load mgcv
___
# Fit the model
gam_mod <- gam(___ ~ s(___), data = mcycle)
# Plot the results
plot(gam_mod, residuals = TRUE, pch = 1)