I have 2 models, using exactly the same variables, one fitted as a linear mixed model (LMM) and another fitted as a generalised additive mixed model (GAMM). I am interested in the fixed effect X and whether it is more appropriate (or just equivalent) to fit as a linear term in a simpler linear model. As I understand, restricted maximum likelihood is not used to compare fixed effects, so I include REML = FALSE. Is a comparison of these two models with AIC valid? I am not certain because of how the smooth term is treated in the GAMM and whether it is the same as a normal fixed effect?
library(lmerTest)
m1 <- lmer(Y ~ X + W + (1|V) + (1|U), REML = FALSE)
library(gamm4)
m2 <- gamm4(Y ~ s(X) + W + (1|V) + (1|U), REML = FALSE)
(Where: Y = continuous response, X = continuous explanatory variable, W = continuous covariate, V = factor block-like variable, U = individual variable (there are repeated measures from individiuals))