#Biostatistics 250 #ONE-WAY ANOVA TABLE #MULTIPLE t-TESTS ZAR=read.table("ZarEX10.3R.txt") ZAR attach(ZAR) Y=potassium X=factor(variety) options(digits=12) #DESCRIPTIVE STATISTICS: X1bar=mean(Y[X=="1"]) X1bar X2bar=mean(Y[X=="2"]) X2bar X3bar=mean(Y[X=="3"]) X3bar n1=length(Y[X=="1"]) n1 n2=length(Y[X=="2"]) n2 n3=length(Y[X=="3"]) n3 s1=sqrt(var(Y[X=="1"])) s1 s2=sqrt(var(Y[X=="2"])) s2 s3=sqrt(var(Y[X=="3"])) s3 #GENERATING ANOVA TABLE: anova(lm(Y~X)) #PAIRWISE COMPARISON OF MEANS: #MULTIPLE t-TEST/FISHER'S LSD: pairwise.t.test(Y,X,p.adj="none",alternative="two.sided") #BONFERRONI COMPARISON OF MEANS: pairwise.t.test(Y,X,p.adj="bonferroni",alternative="two.sided") #HOLM COMPARISON OF MEANS: pairwise.t.test(Y,X,p.adj="holm",alternative="two.sided") #CALCULATING C FROM THE STUDENTIZED RANGE DISTRIBUTION: alpha=0.05 N=18 k=3 qtukey(1-alpha,k,N-k) #CALCULATING P FROM THE STUDENTIZED RANGE DISTRIBUTION: #q-STATISTICS FROM MATHCAD: q1=3.053251732725 q2=5.951908441386 q3=9.00516017411 options(digits=12) #FOR SAMPLE 1 VS 2: P1=1-ptukey(q1,k,N-k) P1 #FOR SAMPLE 1 VS 3: P2=1-ptukey(q2,k,N-k) P2 #FOR SAMPLE 2 VS 3: P3=1-ptukey(q3,k,N-k) P3 #TUKEY HSD TEST: TukeyHSD(aov(Y~X),conf.level=0.95)