Nonlinear Modeling with Generalized Additive Models (GAMs) in R
Noam Ross
Senior Research Scientist, EcoHealth Alliance
mod <- gam(y ~ s(x1, k = 4) + s(x2, k = 4),
data = check_data, method = "REML")
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
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 *
...
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