[R-lang] Main effects of categorical predictors in lmer

hossein karimi karimihussein@gmail.com
Mon Oct 10 07:05:10 PDT 2011


Dear R users,

I’m using mixed effects models (lmer) to predict a binary dependent variable
as a function of 1.a categorical predictor (A)with 2 levels (A1 and A2) , 2.
another categorical predictor (B) with three levels (B1, B2 and B3) and 3.
The interaction between these two predictors. I have tried two models but
they return different results and I’m not sure which one is correct. I’m
interested in the main effect of B and the interaction between A and B
(because A alone has a significant effect in both models). My problem is
that there seem to be two sensible ways of examining the main effect of B:
1. to helmert code and 2. to center.  But these two methods produce opposite
results! I don’t know which one I should use. Here are the two models with
some details and their outputs:


Model 1: ‘A’ is centered. ‘B’ is helmert coded (‘B1’(baseline)=2, ‘B2’=-1,
‘B3’=-1) so that I can get a main effect of B by checking to see whether
baseline condition in B differs from the mean of B1 and B2 . The lmer output
returns a significant effect of B and no significant AxB interaction.
However, as is highlighted below (in pink), the correlation between B and
the ‘AxB’ interaction is high (-54%).



> model.1<-lmer(response~A*B+(A+1|sub)+(1|item), mydata, family="binomial")

> print(model.1)

Generalized linear mixed model fit by the Laplace approximation

Formula: response ~ A * B+ (A + 1 | sub) + (1 | item)

   Data: mydata

 AIC   BIC logLik deviance

 783 822.6 -383.5      767

Random effects:

 Groups Name        Variance Std.Dev. Corr

 item   (Intercept) 0.7293   0.85399

 sub    (Intercept) 2.0871   1.44468

        A          1.3812   1.17524  0.562

Number of obs: 1038, groups: item, 42; sub, 36



Fixed effects:

                  Estimate Std. Error z value Pr(>|z|)

(Intercept)        1.05261    0.30283   3.476 0.000509 ***

A                -3.91080    0.32239 -12.131  < 2e-16 ***

B                  0.36128    0.09751   3.705 0.000211 ***

A:B            -0.29638    0.18681  -1.586 0.112626

---

Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1



Correlation of Fixed Effects:

                        (Intr)   A      B

A                  0.155

B                  0.160 -0.278

A:B              -0.156  0.238 -0.540



Model 2: ‘A’ and ‘B’ are both centered. The lmer output returns no
significant effect of B but the A:B interaction is significant. The
correlations between predictors are generally lower and the correlation
between B and A:B is reduced to -26%.


Generalized linear mixed model fit by the Laplace approximation

Formula: resonse ~ A * B + (A + 1 | sub) + (1 | item)

   Data: mydata

   AIC   BIC logLik deviance

 756.1 795.7 -370.1    740.1

Random effects:

 Groups Name        Variance Std.Dev. Corr

 item   (Intercept) 0.87028  0.93289

 sub    (Intercept) 2.41707  1.55469

        A         1.23669  1.11206  0.533

Number of obs: 1038, groups: item, 42; sub, 36



Fixed effects:

                Estimate Std. Error z value Pr(>|z|)

(Intercept)       1.1004     0.3239   3.398 0.000679 ***

A               -4.0941     0.3248 -12.605  < 2e-16 ***

B                -0.1461     0.1400  -1.043 0.296851

A:B             1.7923     0.2818   6.360 2.01e-10 ***

---

Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1



Correlation of Fixed Effects:

                       (Intr)      A        B

A                    0.138

B                   -0.148  0.185

A:B                0.106 -0.292 -0.265



I personally think Model 2 is better but the thing is that I have centered a
categorical predictor with *three* levels. In my searches in the web, I have
never seen a three-level predictor to be centered; they were all two-level
categorical predictors.

I have used the scale() function to center the predictors (I first converted
them to numeric variables and then used the scale () function to center
them). As I mentioned, my problem is that I don’t know how to get a main
effect of B as well as a *main* A:B interaction. On the one hand, it seems
logical to compare ‘B1’ (baseline) with the mean of the other two B
conditions to see if the B manipulation has a general effect. On the other
hand, I hear that one needs to center variables to get a main effect.


I would be grateful of you could please help me


Regards,


Hossein
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucsd.edu/pipermail/ling-r-lang-l/attachments/20111010/c52807be/attachment-0001.html 


More information about the ling-r-lang-L mailing list