I have two different GAM models as follows, generated via 'mgcv' in R.
I run checks to ensure that the basis dimension is specified correctly via gam.check().
I also run summary() to get a basic report.
Now I want to select the best model via AIC. However, R finds that the two models are equally parsimonious - how can this be?
#### Linear effect of distance ####
nz_gam_linear <- gam(reducedhap ~ s(latitude, k = 20) + distances, data = final2) # here, distance is a linear effect
gam.check(nz_gam_linear) # based on p-value being large (not significant), k = 20 is sufficient
Method: GCV Optimizer: magic
Smoothing parameter selection converged after 6 iterations.
The RMS GCV score gradient at convergence was 1.206796e-06 .
The Hessian was positive definite.
Model rank = 21 / 21
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(latitude) 19.0 17.4 1.19 0.94
#### Smooth effect of distance ####
nz_gam_smooth <- gam(reducedhap ~ s(latitude, k = 20) + s(distances, k = 20), data = final2) # here, distance is a smmoth effect
gam.check(nz_gam_smooth) # based on p-value being large (not significant), k = 20 is sufficient
Method: GCV Optimizer: magic
Smoothing parameter selection converged after 14 iterations.
The RMS GCV score gradient at convergence was 6.818248e-08 .
The Hessian was positive definite.
Model rank = 29 / 29
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(latitude) 19.0 17.4 1.19 0.94
s(distances) 9.0 1.0 1.00 0.36
#### Summarizing and choosing models ####
summary(nz_gam_linear) # linear effect of distance on genetic diversity is not significant
summary(nz_gam_smooth) # smooth effect of distance on genetic diversity is significant
nz_gam_linear$aic # AIC = -15.90926
nz_gam_smooth$aic # AIC = -15.90926
Any idea what is going on here?
Specifying a third model that excludes distance would be appropriate. Trying this gives me an AIC = -12.0363. Clearly, in comparison to the other models, it's not the best.
NB - I can't share the actual code (sorry) as it confidential until we get the manuscript submitted.
Can anyone weigh in here?
method = "REML"
or"ML"
) $\endgroup$