# [R-sig-ME] random intercept, random slope plus intercept, no random slope alone?

Phillip Alday phillip@@ld@y @ending from mpi@nl
Tue Aug 14 12:50:31 CEST 2018

```Not directly answering your question, but I don't think your models m3
and m4 are what you want.

Each LizardID presumably only has one mum, so having a slope for mum
that's allowed to vary by ID doesn't make any sense.

Maybe you want the nested effect

random=~1|mum/LizardID

?

Which will give a by-mum intercept (offset) and a by-lizard intercept.

Best,
Phillip

On 08/14/2018 11:40 AM, Mathew Vickers wrote:
> Dear all,
>
> I measured running speed of 70 individual lizards. The lizards were
> siblings born of 7 mothers, 10 offspring each. The Lizards ran at 3
> different temperatures, A, B, and C, where A < B < C, and I recorded how
> fast they ran.
>
> I want, particularly, to examine whether a given lizard running speed of a
> lizard increases, is static, or decreases. I want to know if there is
> consistency (or not) in this effect between the 7 maternal lines.
>
> The models I have now are:
> m1 <- gls(speed ~ (clim + mum)^2, data=mydf, method="ML")
> # fixed effects only
>
> m2 <- lme(speed ~ (temperature + mum)^2, random=~1|LizardID, data=mydf,
> control = lmeControl(opt = "optim"), method="ML")
> # random intercept model (i.e., one intercept of running speed~temperature
> per individual, nested within mother, a common slope per all individuals
> within mother  )
>
> m3 <- lme(speed ~ (temperature + mum)^2, random=~1+mum||LizardID,
> data=mydf, control = lmeControl(opt = "optim"), method="ML")
> # random intercept and slope model (i.e., one slope and one intercept of
> running speed~temperature per individual, nested within mother  )
>
>
> m4 <- lme(speed ~ (temperature + mum)^2, random=~0+mum||LizardID,
> data=mydf, control = lmeControl(opt = "optim"), method="ML")
> # uncorrelated random slope and intercept - same as last, but slope and
> intercept are uncorrelated.
>
>
> anova(m1, m2, m3, m4)
> # this should tell me which model is the best, using AIC or loglik in
> combination with the p-value.
>
> Are all of these models and my understanding right?
>
> What I really want to test is random slope among individuals nested within
> mother. As I see this set of models, it appears that I can test random
> intercept alone, and compare it to the random intercept and slope model,
> but I cannot test random slope alone. Is that true, or is there a model
> formulation I am missing to test only slope of running speed per individual
> nested within mother?
>
> And one other question:
> Given that I am particularly interested in the questions: a) is the slope
> different among individuals, and b) is the slope more consistent within
> mothers than between mothers, do I need this kind of model selection?
>
>
> Thanks heaps,
>
> Mat.
>
>

```