[R-sig-ME] Removing random correlation parameter for categorical variable in lmer

Ben Bolker bbolker at gmail.com
Sun Jan 17 02:04:09 CET 2016


Douglas Bates <bates at ...> writes:

> 
> For a numeric covariate x, the model expression 0 + x produces a model
> matrix with a single column so you can suppress the correlation by using
> terms like (1 | subject) + (0 + x | subject).  However, for a categorical
> covariate like relatedness with 2 levels the expressions (g | subject), (1
> + g | subect) and (0 + g | subject) are equivalent in terms of the
> predictions from the fitted model.  The only difference between the last
> two is in the "contrasts" that they generate.
> 
> If you really want independent random effects for intercept and for the
> effect of relatedness you should convert the relatedness factor to a
> numeric covariate.  One possibility is (1 | subject) + (0 +
> I(as.integer(relatedness) - 1) | subject).


   Another (equivalent but more readable) possibility is to use the dummy

(1|subject) + (0+dummy(unrelated,"1"))

  (I *think* this is right -- if I am reading correctly, you have
 a categorical variable coded as "0", "1", which is a little confusing ...



More information about the R-sig-mixed-models mailing list