Skip to content

lme with cyclic cubic regression splines

3 messages · Gabriela Czanner, Alexandre Villers, Ben Bolker

#
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:
+               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?

Best regards,

Gabriela

Dr Gabriela Czanner
Lecturer in Ophthalmic Statistics
University of Liverpool
1 day later
#
Good morning,

For that you can use mgcv::gamm or gamm4::gamm4 (but for the later, I'm not
sure whether cyclic splines are possible).
HTH

Alex
2 days later
#
Gabriela Czanner via R-sig-mixed-models <r-sig-mixed-models at ...> writes:
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