R: 2-way repeated measures ANOVA & pairwise.t.test -
using example proposed field in discovering statistics using r (pag 561) 1-way repeated measures anova:
participant <- gl(8, 4, labels = c("p1", "p2", "p3", "p4", "p5", "p6", "p7","p8" )) animal <- gl(4, 1, 32, labels = c("stick_insect", "kangaroo_testicle", "fish_eye", "witchetty_grub")) retch <- c(8, 7, 1, 6, 9, 5, 2, 5, 6, 2, 3, 8, 5, 3, 1, 9, 8, 4, 5, 8, 7, 5, 6, 7, 10, 2, 7, 2, 12, 6, 8, 1) longbush<-data.frame(participant, animal, retch) pairwise.t.test(longbush$retch, longbush$animal, paired=true, alternative="two.sided", p.adjust.method="none")
the result is:
stick_insect kangaroo_testicle fish_eye kangaroo_testicle 0.00202 - - fish_eye 0.00094 0.92007 - witchetty_grub 0.22673 0.29867 0.40204
change bit 'pairwise.t.test', dof (the number of subjects 8):
stick_insect kangaroo_testicle fish_eye kangaroo_testicle 7 - - fish_eye 7 7 - witchetty_grub 7 7 7
so far =)
let's simulate 2-way repeated measures anova:
participant <- gl(8, 8, labels = c("p1", "p2", "p3", "p4", "p5", "p6", "p7","p8" )) animal <- gl(4, 1*2, 64, labels = c("stick_insect", "kangaroo_testicle", "fish_eye", "witchetty_grub")) alive <- gl(2, 1, 64, labels = c("y", "n")) retch <- sample(c(1:12), 64, replace = true) longbush2 <- data.frame(participant, animal, alive, retch) pairwise.t.test(longbush2$retch, longbush2$animal, paired=true, alternative="two.sided", p.adjust.method="none");
the pairwise.t.test results are:
stick_insect kangaroo_testicle fish_eye kangaroo_testicle 0.022 - - fish_eye 0.202 0.584 - witchetty_grub 0.374 0.041 0.433
and dof:
stick_insect kangaroo_testicle fish_eye kangaroo_testicle 15 - - fish_eye 15 15 - witchetty_grub 15 15 15
instead, factor alive has 31 dof. interesting.
so, questions: why dof wrongly changed? do wrong?
thank in advance
cheers
Comments
Post a Comment