[R-sig-ME] lme with cyclic cubic regression splines
Ben Bolker
bbolker at gmail.com
Mon May 16 21:20:17 CEST 2016
Gabriela Czanner via R-sig-mixed-models <r-sig-mixed-models at ...> writes:
>
> Hello list,
>
> I am trying to fit linear mixed model with fixed effect being cyclic cubic
> regression splines, because my data are defined on a circle, while circle
> is divided into 24 directions. I defined a variable Direction which is
> numeric and has values 1,2,... 24. I receive this error message:
>
> > out.lme.8=lme(Y~ s(Direction,bs="cc",k=8),
> + random=~1|PatientID,
> + data=mydata,na.action=na.omit,method="ML")
> Error in model.frame.default(fixed, dataMix) :
> invalid type (list) for variable 's(Direction, bs = "cc", k = 8)'
> >
>
> I wonder if anyone has any suggestion, please?
As Alexandre Villers implicitly pointed out, specifying a smooth
term via s() is restricted to the mgcv:gam(m) and gamm4:gamm functions.
However, if you want to do this in lme (with spline order and knot
positions pre-specified, rather than using penalized regression splines)
it looks like you could use cSplineDes from the mgcv package to set
up the splines yourself. However, I don't know how smoothly these
will work with the built-in model matrix machinery -- using gamm(4)
will probably be easier.
Ben Bolker
More information about the R-sig-mixed-models
mailing list