Imagine a linear mixed effects model with one random intercept:
library(lme4)
LMM1 <- lmer(response ~ experience + (1|subject), REML=FALSE, data=train)
I'd like to fit a conceptual equivalent using the mgcv
package, that is:
library(mgcv)
LMM2 <- bam(response ~ experience, s(subject, bs='re'), method='ML', data=train)
Note that I use the function bam
which is optimized for big datasets. The summaries of the two models yield the same results w.r.t. the estimated intercept, and effect size, standard deviation and t-value of the fixed effect. However, AIC(LMM1)
and AIC(LMM2)
yield different results. Why?
In addition, I'm wondering whether the below listed pairs of models are conceptual equal:
Random intercept:
lmer(response ~ experience + (1|subject), data=train)
bam(response ~ experience + s(subject, bs=’re’), data=train)
Random slope:
lmer(response ~ experience + (0+experience|subject), data=train)
bam(response ~ experience + s(experience, subject, bs=’re’), data=train)
Random intercept and random slope:
lmer(response ~ experience + (1+experience|subject), data=train)
bam(response ~ experience + s(subject, bs='re') + s(experience, subject, bs=’re’), data=train)
If not, please put me right.