[R-sig-ME] Rasch with lme4

Andy Fugard andy.fugard at sbg.ac.at
Tue Jun 9 19:06:54 CEST 2009


Daniel Ezra Johnson wrote:
> In the output for this model:
> 
>>> M2 = lm(Reaction ~ Days + Sex + factor(Subject), sleepstudy)
>>> summary(M2)
> 
> You will see that one of the coefficients is NA. If you put
> factor(Subject) before Sex it would be SexMale that comes out NA.
> 
> Nested fixed effects will always return an error (or incomplete
> model), unless I'm completely mistaken.

Complete output pasted below.  It's been a long day, but I cannae see an 
NA!  Is your output different?

My intuition tells me that order of the variables shouldn't affect these 
estimates as addition is commutative.  I imagine they would affect a 
call to a (sequential) "anova" as this determines the order of nested 
model comparisons from the order of the variables.

A



 > M2a = lm(Reaction ~ Days + Sex + factor(Subject), sleepstudy)
 > summary(M2a)

Call:
lm(formula = Reaction ~ Days + Sex + factor(Subject), data = sleepstudy)

Residuals:
       Min        1Q    Median        3Q       Max
-101.4284  -17.2881    0.2311   15.2005  132.6242

Coefficients:
                     Estimate Std. Error t value Pr(>|t|)
(Intercept)         293.6628    10.8062  27.176  < 2e-16 ***
Days                 10.4511     0.8067  12.956  < 2e-16 ***
SexMale               2.4017     4.6864   0.512 0.609020
factor(Subject)309 -126.6607    13.8995  -9.113 3.18e-16 ***
factor(Subject)310 -111.1326    13.8915  -8.000 2.37e-13 ***
factor(Subject)330  -38.6722    13.8995  -2.782 0.006047 **
factor(Subject)331  -32.6978    13.8915  -2.354 0.019798 *
factor(Subject)332  -34.8318    13.8915  -2.507 0.013160 *
factor(Subject)333  -25.7353    13.8995  -1.852 0.065935 .
factor(Subject)334  -46.8318    13.8915  -3.371 0.000938 ***
factor(Subject)335  -91.8236    13.8995  -6.606 5.55e-10 ***
factor(Subject)337   33.5872    13.8915   2.418 0.016737 *
factor(Subject)349  -66.0592    13.8995  -4.753 4.44e-06 ***
factor(Subject)350  -28.5312    13.8915  -2.054 0.041618 *
factor(Subject)351  -51.7959    13.8995  -3.726 0.000269 ***
factor(Subject)352   -4.7123    13.8915  -0.339 0.734889
factor(Subject)369  -36.0992    13.8915  -2.599 0.010234 *
factor(Subject)370  -50.1919    13.8995  -3.611 0.000408 ***
factor(Subject)371  -47.1498    13.8915  -3.394 0.000868 ***
factor(Subject)372  -24.0075    13.8995  -1.727 0.086056 .
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 31.06 on 160 degrees of freedom
Multiple R-squared: 0.7282,     Adjusted R-squared: 0.6959
F-statistic: 22.56 on 19 and 160 DF,  p-value: < 2.2e-16

 >
 > M2b = lm(Reaction ~ Days + factor(Subject) + Sex, sleepstudy)
 > summary(M2b)

Call:
lm(formula = Reaction ~ Days + factor(Subject) + Sex, data = sleepstudy)

Residuals:
       Min        1Q    Median        3Q       Max
-101.4284  -17.2881    0.2311   15.2005  132.6242

Coefficients:
                     Estimate Std. Error t value Pr(>|t|)
(Intercept)         293.6628    10.8062  27.176  < 2e-16 ***
Days                 10.4511     0.8067  12.956  < 2e-16 ***
factor(Subject)309 -126.6607    13.8995  -9.113 3.18e-16 ***
factor(Subject)310 -111.1326    13.8915  -8.000 2.37e-13 ***
factor(Subject)330  -38.6722    13.8995  -2.782 0.006047 **
factor(Subject)331  -32.6978    13.8915  -2.354 0.019798 *
factor(Subject)332  -34.8318    13.8915  -2.507 0.013160 *
factor(Subject)333  -25.7353    13.8995  -1.852 0.065935 .
factor(Subject)334  -46.8318    13.8915  -3.371 0.000938 ***
factor(Subject)335  -91.8236    13.8995  -6.606 5.55e-10 ***
factor(Subject)337   33.5872    13.8915   2.418 0.016737 *
factor(Subject)349  -66.0592    13.8995  -4.753 4.44e-06 ***
factor(Subject)350  -28.5312    13.8915  -2.054 0.041618 *
factor(Subject)351  -51.7959    13.8995  -3.726 0.000269 ***
factor(Subject)352   -4.7123    13.8915  -0.339 0.734889
factor(Subject)369  -36.0992    13.8915  -2.599 0.010234 *
factor(Subject)370  -50.1919    13.8995  -3.611 0.000408 ***
factor(Subject)371  -47.1498    13.8915  -3.394 0.000868 ***
factor(Subject)372  -24.0075    13.8995  -1.727 0.086056 .
SexMale               2.4017     4.6864   0.512 0.609020
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 31.06 on 160 degrees of freedom
Multiple R-squared: 0.7282,     Adjusted R-squared: 0.6959
F-statistic: 22.56 on 19 and 160 DF,  p-value: < 2.2e-16




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