Tensor smooths in gamm4

447 Views Asked by At

I am trying to extend a model similar to the one described by Gavin Simpson here to also include random effects. https://stats.stackexchange.com/questions/32730/how-to-include-an-interaction-term-in-gam

Where locis replaced by a 4-level factor. The fixed effects are two categorical variables (A and B) and two continuous ones (C1 and C2) with all pairwise interactions. The response is 1s and 0s.

e.g.

gamm4(y~A*C1 + A*C2 + B*C1 + B*C2    
                s(yDay, bs = "cc", k = 12) + 
                s(yDay, bs = "cc", by = A, k = 12, m = 1) + 
                s(Hour, bs = "cc", k = 12) + 
                s(Hour, bs = "cc", by = Loc, k = 12, m = 1) +
                t2(Hour, yDay, by = A, bs = rep("cc",2)),
                random = ~ (1 | ID),
                family = "binomial"(link="logit"),
                data = dat)

Trying to run it I got the error
Error in X %*% diag(diagU[indi]) : non-conformable arguments

From lurking around in the code of gamm4() and gamm() it seems to be related to penalising the smooths within each level of the random effect?

I am currently running the model with a subset of 4 individuals (can end up around 40), and should also eventually nest individuals within years.

It could be that my problem is to situation specific (read: I am being way too ambitious on behalf of my data), but reading that gamm4() is still "construction phase" on some matters makes me wonder if I am being to ambitious on behalf of gamm4()?

Or I am probably just plain wrong and off hiking in some dead ends...

0

There are 0 best solutions below