[R-sig-ME] random slopes in gamm4
Cesko Voeten
c@c@voeten @end|ng |rom hum@|e|denun|v@n|
Sat Apr 6 10:37:59 CEST 2019
Dear John,
A random slope in gamm4 is the same as a random slope in lme4, i.e.
(X1|ID) gives you separate linear slopes for X1 by IDs. If X1 is
numeric, this should be exactly identical to mgcv's s(ID,X1,bs='re').
It sounds like what you really want is a random smooth, which in mgcv is
called a factor smooth: s(ID,X1,bs='fs',xt=list(k=4),m=1). If you want
the *smooth* to vary across IDs, this is appropriate. Pass 'm=1' to
penalize the smooth a little bit more -- this is common for random smooths.
You can read more about this on
http://www.sfs.uni-tuebingen.de/~jvanrij/Tutorial/GAMM.html. If you use
a factor smooth, you do not need to add a separate random slope, btw.
Best,
Cesko
Op 05-04-2019 om 21:44 schreef René:
> Dear John,
>
> I almost tend to say, you should ask Simon Wood, Fabian Scheipl directly :))
> but, you know, in the gamm4 manual for formula they say: 'Note that ids for
> smooths and fixed smoothing parameters are not supported.'
> (Which I do not understand) But later it says:
>
> gamm4 allows the random effects specifiable with lmer to be combined with
> any number of any of the (single penalty) smooth terms available in gam from
> package mgcv as well as t2 tensor product smooths. Note that the model
> comparison on the basis of the (Laplace approximate) log likelihood is
> possible with GAMMs fitted by gamm4.
>
> Which I, honestly, again, absolutely do not understand. But it seems that
> random slopes are about penalty smooth terms (how much you like them
> to...). Interestingly, when clicking on 'gam' (to learn more), it redirects
> me to the same page... which almost feels like magic (or buddhist).
>
> And the second part of your question alarms me... it seems that you want
> to analyze residual terms (i.e. random errors, which by frequentist
> definition are random), is this the case? Otherwise, whether positive or
> negative, the mean of any random effect should be zero, and the residuals
> should be normally (or appropriately) distributed. I would argue (as others
> do), that any directed hypothesis should be part of the fixed effects. And
> maybe the question is, whether there are better packages to do this, and
> allow to predict the function parameters you are interested in (In case of
> interest, check 'brms' and its non-linear function applications. You might
> become happier with this, as it would be on you to define 'positive or
> negative', and also with respect to the support.)
>
> :)
>
>
> Best wishes, René
>
>
>
> Am Fr., 5. Apr. 2019 um 14:48 Uhr schrieb John Morrongiello <
> john.morrongiello using unimelb.edu.au>:
>
>> Hi all
>>
>>
>>
>> I posted this question back in 2015 but unfortunately didn't get a reply.
>> I'd like to use these models again so thought it worth another ask.
>>
>>
>>
>> Most GAMM examples involve the fitting of a model with just a random
>> intercept (e.g. M1 below). However, I'd like to explore the possibility of
>> each individual (ID) having a different X1 smoother 'slope', or even just
>> linear slope, akin to a random slope in lmer (M2).
>>
>>
>>
>> M1<-gamm4(response ~ s(X1,k=4), random =~(1|ID),data)
>>
>> M2<-gamm4(response ~ s(X1,k=4), random =~(X1|ID),data)
>>
>>
>>
>> However, I'm unsure how to interpret the random slope X1 in M2. If
>> positive, is it an overall increase in smoother 'wriggliness' i.e. increase
>> in edf (opposite for negative)? Or is it something else? Would someone know
>> how to visualise these 'random slopes' so I can get a feel for what is
>> going on?
>>
>>
>>
>> A manuscript by Pedersen and colleagues has recently been posted on PeeJ
>> that explores related models within the gam function
>> https://peerj.com/preprints/27320/. I'm happy to use these, but still
>> would like to understand the random slope in a gamm4 context.
>>
>>
>>
>> Cheers
>>
>>
>>
>> John
>>
>> [[alternative HTML version deleted]]
>>
>> _______________________________________________
>> R-sig-mixed-models using r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
>>
>
> [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-mixed-models using r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
>
More information about the R-sig-mixed-models
mailing list