MulaiMulai sekarang secara gratis

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.

Latihan ini adalah bagian dari kursus

Nonlinear Modeling with Generalized Additive Models (GAMs) in R

Lihat Kursus

Petunjuk latihan

  • Load the mgcv package.
  • Fit a model to the mcycle data where accel has a smooth, nonlinear relation to times using the gam() function.
  • Visualize the model fit using the provided call to plot().

Latihan interaktif praktis

Cobalah latihan ini dengan menyelesaikan kode contoh berikut.

# Load mgcv
___

# Fit the model
gam_mod <- gam(___ ~ s(___), data = mcycle)

# Plot the results
plot(gam_mod, residuals = TRUE, pch = 1)
Edit dan Jalankan Kode