Model checking with gam.check()

Nonlinear Modeling with Generalized Additive Models (GAMs) in R

Noam Ross

Senior Research Scientist, EcoHealth Alliance

Pitfall one: inadequate basis number

mod <- gam(y ~ s(x1, k = 4) + s(x2, k = 4),
           data = check_data, method = "REML")

Nonlinear Modeling with Generalized Additive Models (GAMs) in R
gam.check(mod)
Method: REML   Optimizer: outer newton
full convergence after 9 iterations.
Gradient range [-0.0001467222,0.00171085]
(score 784.6012 & scale 2.868607).
Hessian positive definite, eigenvalue range [0.00014,198.5]
Model rank =  7 / 7 

Basis dimension (k) checking results. Low p-value
(k-index<1) may indicate that k is too low, especially
if edf is close to k'.

        k'  edf k-index p-value    
s(x1) 3.00 1.00    0.35  <2e-16 ***
s(x2) 3.00 2.88    1.00    0.52    
 ---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1
Nonlinear Modeling with Generalized Additive Models (GAMs) in R

Running gam.check (2)

mod <- gam(y ~ s(x1, k = 12) + s(x2, k = 4),
                data = dat, method = "REML")
gam.check(mod)
...

         k'   edf k-index p-value  
s(x1) 11.00 10.85    1.05   0.830  
s(x2)  3.00  2.98    0.89   0.015 *

...
Nonlinear Modeling with Generalized Additive Models (GAMs) in R

Running gam.check (3)

mod <- gam(y ~ s(x1, k = 12) + s(x2, k = 12),
            data = dat, method = "REML")
gam.check(mod)
...
         k'   edf k-index p-value
s(x1) 11.00 10.86    1.08    0.94
s(x2) 11.00  7.78    0.94    0.12
...
Nonlinear Modeling with Generalized Additive Models (GAMs) in R

Nonlinear Modeling with Generalized Additive Models (GAMs) in R

Nonlinear Modeling with Generalized Additive Models (GAMs) in R

Let's check some models

Nonlinear Modeling with Generalized Additive Models (GAMs) in R

Preparing Video For Download...