Using the package "mgcv" I fitted a GAM to demonstrate head circumference changes over the lifetime for data stemming from two different countries;
library("mgcv") gam1 <- gam(Size~s(Age,k=12, bs="cr")+Country1+Country2+Sex,data = sizedata, method="REML")
I am mostly interested in plotting centile reference curves using the lms method described by Cole & Green (1992). According to the documentation in CRAN for the "gamlss" package this method can accomodate only one explanatory variable to the model, the code of which would look like this
library("gamlss") model1 <- lms(Size, Age, families = c("BCPEo"), data=sizedata) centiles(model1, xvar=sizedata$Size, cent = c(0.4, 2, 10, 25, 50, 75, 90, 98, 99.6),ylab = "Head Circumference", xlab = "Age",legend = FALSE, points = FALSE, col.cent=c(1), xlim = range(0,100, length=5), lwd.cent=c(1,1,1,1,5,1,1,1,1))
Do you know of any ways to control for the effects of countries and sex to model these centile reference curves using R?