Skip to content
Prev 6081 / 20628 Next

lme/anova vs paired t test query

Ben,

The "good ones" in your simulation correspond to cases where the classical
"ANOVA" estimate of the block variance component is greater than zero (i.e.
the F statistic for "tripsite" in the two way fixed effects anova is greater
than 1).

 > tmpf <- function(dat) {
+   t0 <- with(dat,t.test(prevalence[sex=="f"],prevalence[sex=="m"],paired=TRUE,var.equal=TRUE))
+   a1 <- anova(lme(prevalence~sex,random=~1|tripsite,data=dat,method="REML"))
+   a2 <- anova(lm(prevalence~sex+tripsite,data=dat))
+   fstat0 <- t0$statistic^2     ## 0.789627
+   fstat1 <- a1[["F-value"]][2] ## 0.8056624
+   fstat2 <- a2[["F value"]][2]
+   c(fstat0,fstat1,fstat2)
+ }
 >
 > set.seed(1001)
 > rr <- unlist(replicate(500,tmpf(transform(dat,prevalence=rnorm(nrow(dat))))))
 > table((abs(rr[1,]-rr[2,])<0.00002),(rr[3,]>=1))

         FALSE TRUE
   FALSE   246    0
   TRUE      3  251



Regards,   Rob Kushler
On 5/23/2011 4:10 PM, Ben Bolker wrote: