BaşlayınÜcretsiz Başlayın

Fixing problems with model diagnostics

You can use gam.check() to improve models by updating them based on its results.

Bu egzersiz

Nonlinear Modeling with Generalized Additive Models (GAMs) in R

kursunun bir parçasıdır
Kursu Görüntüle

Egzersiz talimatları

  • Run the model diagnostics on mod.
  • Based on the diagnostics, re-fit the model as mod2, changing the number of basis functions (k) for failing smooths.
  • Run the model diagnostics on mod2 to ensure you have fixed the issue.

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

library(mgcv)
# Fit the model
mod <- gam(y ~ s(x0, k = 3) + s(x1, k = 3) + s(x2, k = 3) + s(x3, k = 3),
           data = dat, method = "REML")

# Check the diagnostics
___

# Refit to fix issues
mod2 <- gam(y ~ s(x0, k = ___) + s(x1, k = ___) + s(x2, k = ___) + s(x3, k = ___),
           data = dat, method = "REML")

# Check the new model
___
Kodu Düzenle ve Çalıştır