Skip to content
Prev 15360 / 20628 Next

Continuous variable as random slope and the minimum number of levels for a categorical variable to be treated as random

Dear all,

I've recently read in this page (https://dynamicecology.
wordpress.com/2015/11/04/is-it-a-fixed-or-random-effect/) the following
text "First you CANNOT treat a continuous variable as a random effect. So
if you are putting area or temperature or body size is in they may be a
nuisance/control variable but they are a fixed effect. Of course you are
only estimating one parameter (the slope) so there is no degree of freedom
cost to treating it as random. And it makes no sense to ask what is the
variance across a continuous variable."
Actually I don't know why it doesn't make any sense ask what is the
variance across a continuous variable.
I've seen the classical example on sleepstudy data which treats a cntinuous
variable as random slope:
fm1 <- lmer (Reaction~Days+(Days|Subject), sleepstudy)
with sleepstudy$Days being a continuous variable, and lmer estimates the
variance of the Days slope.

So... is it OK to use a continuous variable as random slope or not?

Furthermore the post says: "[...] you should not treat a categorical
variable with only two levels (e.g. two sites), also known as a binary
variable, as a random effect. You wouldn?t take two measures and then try
to estimate variance, but that is what you?re asking R to do if you treat
it as random. Beyond that there is a lot of debate. But many people think
<http://stats.stackexchange.com/questions/37647/minimum-number-of-levels-for-a-random-effects-factor>
you
should have at least 5 levels (e.g. 5 sites) before you treat something as
random"

Actually I've seen a lot of GLMMs done with random factors with just 2
levels. Is it acceptable or not?

Thanks in advance,

Michele