[R] nlme cross-over and fixed nested

Peter Dalgaard BSA p.dalgaard at biostat.ku.dk
Mon May 27 18:04:37 CEST 2002


"Dieter Menne" <dieter.menne at menne-biomed.de> writes:

> NSubj<-20
> # Placebo Phase
> # Seq: 1 for "Placebo first phase", 2 for "Verum first phase"
> glup<-data.frame(Patient=as.factor(1:NSubj),
>                 Seq=as.factor(rep(c(1,2),NSubj/2)),
>                 Treat=rep("Pla",NSubj),
>                 Glu=rnorm(NSubj,30,4)
>    )
> # Verum Phase
> gluv<-data.frame(Patient=as.factor(1:NSubj),
>                 Seq=as.factor(rep(c(1,2),NSubj/2)),
>                 Treat=rep("Ver",NSubj),
>                 Glu=glup$Glu-rnorm(NSubj,6,2)
>    )

I don't think you mean that. One of them wants to have 

Seq=as.factor(rep(c(2,1),NSubj/2))

otherwise patient 1 has two 1st phases, pt.2 has two 2nd phases, etc.

For a balanced design, I'd suggest

summary(aov(Glu~Treat*Seq+Error(Patient),data=glu))

which should show the wellknown crossover-design feature that the
interaction is compared to the Patient variation.


Or, put differently, it makes little sense to use the Seq variable, as
you define it, as a main effect. Rather, you'd want an indicator of
whether the current observation is the first or the second one, so

> glu <- transform(glu, first=as.factor((Seq==1)==(Treat=="Pla")))

> summary(aov(Glu~Treat*first+Error(Patient),data=glu))

Error: Patient
            Df Sum Sq Mean Sq F value Pr(>F)
Treat:first  1  14.96   14.96  0.2739 0.6071
Residuals   18 982.75   54.60               

Error: Within
          Df Sum Sq Mean Sq F value    Pr(>F)    
Treat      1 478.04  478.04 75.9305 7.106e-08 ***
first      1   2.66    2.66  0.4221    0.5241    
Residuals 18 113.32    6.30                      
---
Signif. codes:  0 `***' 0.001 `**' 0.01 `*' 0.05 `.' 0.1 ` ' 1 


Notice that this reverses the roles of interaction and main effect
relative to using Seq directly:

> summary(aov(Glu~Treat*Seq+Error(Patient),data=glu))

Error: Patient
          Df Sum Sq Mean Sq F value Pr(>F)
Seq        1  14.96   14.96  0.2739 0.6071
Residuals 18 982.75   54.60               

Error: Within
          Df Sum Sq Mean Sq F value    Pr(>F)    
Treat      1 478.04  478.04 75.9305 7.106e-08 ***
Treat:Seq  1   2.66    2.66  0.4221    0.5241    
Residuals 18 113.32    6.30                      
---
Signif. codes:  0 `***' 0.001 `**' 0.01 `*' 0.05 `.' 0.1 ` ' 1 





-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)             FAX: (+45) 35327907
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list