Skip to content
Prev 1736 / 20628 Next

Is it right to specify a random slope for the dummy variables

By default, a categorical variable (factor) with n levels comes with
n-1 treatment contrasts. Therefore, in the fixed-effect part of the
model the intercept represents the reference level and the n-1
contrasts represent the mean differences between the other levels and
the reference level, assuming a balanced design. You can check your
specification with contrasts(factor). Of course, you should change
from treatment to other contrasts as required by your hypotheses. See
?contrasts.

Now suppose you have the variable group as random factor in the model
and you include the variable factor also in the random effects part:

lmer(y ~  factor + (factor|group))

Then, you can estimate the variance of the intercept (i.e., variance
of reference level for groups), variances of the n-1  difference
scores for group,  and correlations between intercept and difference
scores as random effects (i.e., you estimate varying intercepts and
varying differences and the correlations between them).

Thus, with categorical variables you are mostly looking at the
variance and correlation of difference scores between levels of a
factor rather than variance and correlation of slopes (which are also
a kind of difference score, of course).

Reinhold Kliegl
On Wed, Dec 31, 2008 at 9:45 AM, zhijie zhang <epistat at gmail.com> wrote: