[R-sig-ME] Rasch with lme4

Andy Fugard andy.fugard at sbg.ac.at
Tue Jun 9 19:36:38 CEST 2009


Andy Fugard wrote:
> 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.

You were correct!  (Estimate for "factor(Subject)371" is broken.) 
Thanks for a tip off-list from Daniel and Chuck that I check how I made 
up the participants' sex :-)

So then does something similar happen for some cases when you try to 
model items as fixed effects?

A


 > # Try again again
 > M1 = lmer(Reaction ~ Days + (1|Subject), sleepstudy)
 >
 > # Use the random intercept to make up a Male/Female IV
 > ranefs = ranef(M1)$Subject
 > sexDF = data.frame(Sex = 
cut(ranefs$"(Intercept)",2,labels=c("Female","Male")),
+                    Subject = rownames(ranefs))
 >
 > sleepstudy.sex = merge(sleepstudy,sexDF)
 >
 >
 > M2 = lm(Reaction ~ Days + Sex + factor(Subject), sleepstudy.sex)
 > summary(M2)

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

Residuals:
     Min      1Q  Median      3Q     Max
-85.970 -13.790   1.767  12.957  53.056

Coefficients: (1 not defined because of singularities)
                    Estimate Std. Error t value Pr(>|t|)
(Intercept)        257.3095    14.5333  17.705  < 2e-16 ***
Days                10.6920     0.9627  11.106  < 2e-16 ***
SexMale             59.7598    18.0982   3.302 0.001472 **
factor(Subject)309 -85.8306    18.8055  -4.564 1.92e-05 ***
factor(Subject)310 -79.1101    19.8317  -3.989 0.000153 ***
factor(Subject)330 -63.0263    16.9719  -3.714 0.000391 ***
factor(Subject)331 -47.4795    16.1890  -2.933 0.004452 **
factor(Subject)332 -73.4632    16.1945  -4.536 2.13e-05 ***
factor(Subject)333 -45.4487    16.9719  -2.678 0.009098 **
factor(Subject)334  -5.9602    19.8186  -0.301 0.764446
factor(Subject)335 -58.4926    18.8025  -3.111 0.002638 **
factor(Subject)337  14.6896    16.1818   0.908 0.366900
factor(Subject)349 -28.7516    18.8055  -1.529 0.130498
factor(Subject)350 -67.3889    16.1826  -4.164 8.26e-05 ***
factor(Subject)351 -26.1381    18.8055  -1.390 0.168665
factor(Subject)352 -35.0784    16.1890  -2.167 0.033425 *
factor(Subject)369 -52.4248    16.1945  -3.237 0.001799 **
factor(Subject)370 -25.4865    18.8055  -1.355 0.179400
factor(Subject)371       NA         NA      NA       NA
factor(Subject)372 -45.9271    16.9741  -2.706 0.008433 **
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 28.03 on 75 degrees of freedom
Multiple R-squared: 0.8089,     Adjusted R-squared: 0.763
F-statistic: 17.63 on 18 and 75 DF,  p-value: < 2.2e-16

 >
 > # Broken as promised!




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