[R] Problems with lm()

Peter Dalgaard p.dalgaard at biostat.ku.dk
Sat Jun 21 10:00:52 CEST 2008


<oops, this got sent as reply to Andrew only>

Andrew Robinson wrote:
> In your data, subject is nested within sequence.  Was that your
> intention?
>
>   
Presumably yes. This looks like a standard cross-over design.

I fail to see what the interaction between subject and sequence might
mean, so I also have no idea what SPSS might have done. (The list does
not allow .doc attachments).

Since this is a balanced design, you can get almost the right analysis by

> m <- lm(Max ~ sequence + subject + period +
+ drug, data=Data)
> anova(m)
Analysis of Variance Table

Response: Max
           Df Sum Sq Mean Sq F value Pr(>F)
sequence   1    585     585  0.0160 0.9014
subject   12 634325   52860  1.4469 0.2660
period     1  63175   63175  1.7293 0.2131
drug       1  58149   58149  1.5917 0.2311
Residuals 12 438395   36533

in which you have to know that sequence is aliased with the drug:period
interaction, AND that it needs to be compared with the intersubject
variation. I.e. the F test is wrong and should be replaced with F=
585/52860 = 0.011on 1 and 12 df.

However, a better way is

> summary(aov(Max ~ period*drug + Error(subject), data=Data))

Error: subject
             Df Sum Sq Mean Sq F value Pr(>F)
period:drug  1    585     585  0.0111  0.918
Residuals   12 634325   52860

Error: Within
           Df Sum Sq Mean Sq F value Pr(>F)
period     1  63175   63175  1.7293 0.2131
drug       1  58149   58149  1.5917 0.2311
Residuals 12 438395   36533



-- 
    O__  ---- Peter Dalgaard             Øster Farimagsgade 5, Entr.B
   c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
  (*) \(*) -- University of Copenhagen   Denmark      Ph:  (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)              FAX: (+45) 35327907



More information about the R-help mailing list