[R] gamm problem/error fitting smooth by factor
bgunter.4567 at gmail.com
Mon Dec 26 19:24:24 CET 2016
You will likely do better posting this on the r-sig-mixed-models
list. This list is for general R programming issues, whereas that one
is specifically concerned with mixed effects modeling in R, which is
the focus of your post.
"The trouble with having an open mind is that people keep coming along
and sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
On Mon, Dec 26, 2016 at 3:16 AM, Mathew Guilfoyle <mrguilfoyle at gmail.com> wrote:
> I have a (unbalanced) dataset of time series collected across several subjects (n~500, ~60000 observations). I would like to model the overall smooth time trend of a variable and how this trend differs by various categorical factors, with the subject as a random effect.
> My baseline model
> m1 = gamm(v1 ~ s(time), random=list(id=~1+time), data=dat)
> shows that time is a significant term.
> I have then tried to run this model:
> m2 = gamm(v1 ~ s(time)+s(time, by=fac1), random=list(id=~1+time), data=dat)
> where fac1 is a binary factor.
> My intuitive understanding of this is that the first smooth term will capture the overall major trend common to both groups of fac1 and the second smooth will model the deviation from this mean trend for the fac1==1 subgroup. However, I get the error:
> Error in MEestimate(lmeSt, grps) :
> Singularity in backsolve at level 0, block 1
> I've tried other models to isolate the problem but get the exact same error
> m3 = gamm(v1 ~ s(time)+s(time, by=fac1), random=list(id=~1), data=dat) #remove the time random effect
> m4 = gamm(v1 ~ fac1+s(time)+s(time, by=fac1), random=list(id=~1+time), data=dat) #have the factor as a main effect also
> I'm not sure if the whole notion of what I'm trying to do is wrong-headed or if I need to adjust some parameters to get the model (m2) to fit.
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help