I am trying to specify both a random intercept and random slope term in a GAMM model with one fixed effect.
I have successfully fitted a model with a random intercept using the below code within the mgcv
library, but can now not determine what the syntax is for a random slope within the gamm()
function:
M1 = gamm(dur ~ s(dep, bs="ts", k = 4), random= list(fInd = ~1), data= df)
If I was using both a random intercept and slope within a linear mixed-effects model I would write it in the following way:
M2 = lme(dur ~ dep, random=~1 + dep|fInd, data=df)
The gamm()
supporting documentation states that the random terms need to be given in the list
form as in lme()
but I cannot find any interpretable examples that include both slope and intercept terms. Any advice / solutions would be much appreciated.
fInd
(as shown in the lme() example), I just can't figure out the syntax. – jjulip