Use buildmer to fit generalized additive models using gam from package mgcv
buildmer
gam
mgcv
Useful links