4
$\begingroup$

Say, I have a dataset that looks at how many times my 5 babies chases a cat around the house . I'm trying to estimate 'y' which is the number of times the cat runs one complete round around the house as a function of the color of the dress the babies wear and the speed at which the babies are walking. But, I also have information about the type of food the babies ate and if the weather is cloudy or sunny on that specific day. What food the baby chooses to eat can be dependent on the weather.

I want to estimate y as fn of color and speed:

Now, my model is 'y'~color*speed+(1|baby)

But, I'm wondering if I can also add information about the food and weather, which are not part of my fixed effects into my model( without including interactions)

'y'~color*speed+(food||baby)+(food||weather)

$\endgroup$
5
$\begingroup$

But, I'm wondering if I can also add information about the food and weather, which are not part of my fixed effects into my model( without including interactions)

Yes, you can. By not including them as fixed effects, but including them as random slopes, you are saying that the overall mean slope is zero, but each individual subject (baby and weather in your model) will have it's own slope. Whether it makes sense in your modelling context, is another matter altogether.

Note that in your 2nd model you include weather as a grouping variable for random intercepts. You said that there are only 2 levels of weather - sunny or cloudy - so in this case that would not make sense becuase the software will try to estimate a variance for a normally distributed variable based on only 2 observations. So in this case you would specify weather as a fixed effect.

Also note that in your 2nd model the || syntax means, at least in the lme4 package, that the software will not estimate a correlation between the random slopes and the random intercepts

| cite | improve this answer | |
$\endgroup$
  • 1
    $\begingroup$ thank you for this! Could you explain the part that the overall mean slope is zero? @Robert Long $\endgroup$ – amarykya_ishtmella Jul 5 at 14:23
  • 1
    $\begingroup$ @anamika_sen_ranjput sure, there is no fixed effect for it, and the mean of the random effects is zero, so overall it will be zero. $\endgroup$ – Robert Long Jul 5 at 14:32
  • 1
    $\begingroup$ just to clarify again, it means that there is no fixed effect for weather & food...? Where, I'm having trouble is visualizing the 'x' and 'y' axis of such a model. Is there any link where I can visually understand better such a model? or could you use a pen and paper to may visually explain it.I know I'm asking too much, but I'm struggling to get an intuition around this. $\endgroup$ – amarykya_ishtmella Jul 5 at 14:41
  • 1
    $\begingroup$ Yes that is literally what you asked for in the question:*"But, I'm wondering if I can also add information about the food and weather, which are not part of my fixed effects into my model"*. Please ask a new question about how to visualise a mixed model with random slopes for a variable but no fixed effect for that variable in a simple model such as y ~ 1 + (var | subject) $\endgroup$ – Robert Long Jul 5 at 16:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.