#Biostatistics 301 #ANOVA FOR RANDOMIZED BLOCKS WITH REPLICATES M=read.table("machinesR.txt",header=TRUE) M attach(M) fMachine=factor(Machine) fWorker=factor(Worker) LM=lm(score~fMachine*fWorker) anova(LM) alpha = 0.05 MSA=anova(LM)[1,3] MSB=anova(LM)[2,3] MSAB=anova(LM)[3,3] MSE=anova(LM)[4,3] dfA=anova(LM)[1,1] dfB=anova(LM)[2,1] dfAB=anova(LM)[3,1] dfE=anova(LM)[4,1] #OMNIBUS F TEST FOR TREATMENT EFFECT: F=MSA/MSAB F C=qf(1-alpha,dfA,dfAB) C P=1-pf(F,dfA,dfAB) P #OMNIBUS F TEST FOR BLOCK EFFECT: F=MSB/MSE F C=qf(1-alpha,dfB,dfE) C P=1-pf(F,dfB,dfE) P #F TEST FOR TREATMENT BY BLOCK INTERACTION: F=MSAB/MSE F C=qf(1-alpha,dfAB,dfE) C P=1-pf(F,dfAB,dfE) P #CORRESPONDING R CODE FOR MIXED MODELS: library(nlme) #MODEL WITH NO INTERACTION: FM1=lme(score~Machine,random =~1|Worker) summary(FM1) anova(FM1) #MODEL WITH TREATMENT BY BLOCK INTERACTION: FM2=lme(score~Machine,random =~1|Worker/Machine) summary(FM2) anova(FM2) #TEST OF MODEL INCLUDING INTERACTION: anova(FM1,FM2)