Skip to content
Prev 1417 / 20628 Next

Altering the intercept-vector in lme4?

On Fri, Sep 19, 2008 at 10:25 AM, Rense Nieuwenhuis
<contact at rensenieuwenhuis.nl> wrote:
I think that is the cause of the problem when you combine those
indicators with the indicators for sex.  The way that a model matrix
is constructed in R, if the intercept is removed then both indicators
are included for the first factor (sex in this case).  You can
circumvent this problem by creating a factor for schoolNR == 1 as
shown below.  In general you should avoid trying to create indicator
variables explicitly and use the model formula to create them
Linear mixed model fit by REML
Formula: IQ.perf ~ sex + schoolSES + (1 | schoolNR)
   Data: bdf
   AIC   BIC logLik deviance REMLdev
 10058 10087  -5024    10034   10048
Random effects:
 Groups   Name        Variance Std.Dev.
 schoolNR (Intercept) 0.17049  0.41291
 Residual             4.58623  2.14155
Number of obs: 2287, groups: schoolNR, 131

Fixed effects:
            Estimate Std. Error t value
(Intercept) 10.16620    0.26013   39.08
sex1        -0.46084    0.09063   -5.08
schoolSES    0.05676    0.01333    4.26

Correlation of Fixed Effects:
          (Intr) sex1
sex1      -0.146
schoolSES -0.960 -0.020
Linear mixed model fit by REML
Formula: IQ.perf ~ 0 + sch1 + sex + schoolSES + (1 | schoolNR)
   Data: bdf
   AIC   BIC logLik deviance REMLdev
 10058 10092  -5023    10033   10046
Random effects:
 Groups   Name        Variance Std.Dev.
 schoolNR (Intercept) 0.16993  0.41222
 Residual             4.58667  2.14165
Number of obs: 2287, groups: schoolNR, 131

Fixed effects:
          Estimate Std. Error t value
sch1N     10.21585    0.26491   38.56
sch1Y      9.62569    0.61365   15.69
sex1      -0.46154    0.09064   -5.09
schoolSES  0.05445    0.01353    4.03

Correlation of Fixed Effects:
          sch1N  sch1Y  sex1
sch1Y      0.242
sex1      -0.145 -0.055
schoolSES -0.961 -0.241 -0.019