例子:玉米品种A有4个水平,分别是A1-A4,施肥B有两个水平,分别是B1-B2,重复三次,采用随机区组,数据如下:
数据录入:
> library(reshape);library(agricolae)
>df<-read.table(file="r3.3.1.2.csv",header=T,sep=",")
> df.2<-melt(df,id=c("A","B"))
> colnames(df.2)[3:4]<-c("Blk","y")
方差分析
> duncan.model<-aov(y~A*B+Blk,data=df.2)
> summary(duncan.model) # show ANOVA table
Df Sum Sq Mean Sq F value Pr(>F)
A 3 98.79 32.93 15.199 0.000111 ***
B 1 77.04 77.04 35.558 3.47e-05 ***
Blk 2 20.33 10.17 4.692 0.027567 *
A:B 3136.46 45.49 20.994 1.90e-05 ***
Residuals 14 30.33 2.17
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
> anova.tab(duncan.model) #方差格式整理
Df Sum Sq Mean Sq F value Pr(>F)
A 3 98.8 32.93 15.199 0.000111 ***
B 1 77.0 77.04 35.558 3.47e-05 ***
Blk 2 20.3 10.17 4.692 0.027567 *
A:B 3 136.5 45.49 20.994 1.90e-05 ***
Residuals 14 30.3 2.17
Total 23 363.0
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
由方差分析表可知A、B、AB互作均达到极显著水平,区组达到显著水平,下面进行多重比较。
多重比较
> duncan.test(duncan.model,"A",alpha=0.05,console=T) #对A因素进行多重比较
Study: duncan.model ~ "A"
Duncan's new multiple range test
for y
Mean Square Error: 2.166667
A, means
y std r Min Max
A1 12.00000 1.264911 6 10 13
A2 17.16667 2.926887 6 12 20
A3 13.00000 5.291503 6 7 19
A4 12.66667 3.829708 6 8 17
alpha: 0.05 ; Df Error: 14
Critical Range
2 3 4
1.822718 1.909920 1.963738
Means with the same letter are notsignificantly different.
Groups, Treatments and means
a A2 17.17
b A3 13
b A4 12.67
b A1 12
由上表可知,A2水平和其他水平相比差异显著,处理效果最好。
> duncan.test(duncan.model,"B",alpha=0.05,console=T) #对B因素进行多重比较
Study: duncan.model ~ "B"
Duncan's new multiple range test
for y
Mean Square Error: 2.166667
B, means
y std r Min Max
B1 15.50000 2.540580 12 12 19
B2 11.91667 4.420167 12 7 20
alpha: 0.05 ; Df Error: 14
Critical Range
2
1.288856
Means with the same letter are notsignificantly different.
Groups, Treatments and means
a B1 15.5
b B2 11.92
由上表可知,B1和B2相比较,差异显著。
> with(df.2, duncan.test(y, A:B, DFerror = 14, MSerror =2.17,console=T)) #对AB进行多重比较
Study: y ~ A:B
Duncan's new multiple range test
for y
Mean Square Error: 2.17
A:B, means
y std r Min Max
A1:B1 12.666667 0.5773503 3 12 13
A1:B2 11.333333 1.5275252 3 10 13
A2:B1 15.666667 3.5118846 3 12 19
A2:B2 18.666667 1.5275252 3 17 20
A3:B1 17.666667 1.5275252 3 16 19
A3:B2 8.333333 1.5275252 3 7 10
A4:B1 16.000000 1.0000000 3 15 17
A4:B2 9.333333 1.5275252 3 8 11
alpha: 0.05 ; Df Error: 14
Critical Range
2 3 4 5 6 7 8
2.579695 2.703112 2.779281 2.8307672.867363 2.894153 2.914097
Means with the same letter are notsignificantly different.
Groups, Treatments and means
a A2:B2 18.67
ab A3:B1 17.67
ab A4:B1 16
b A2:B1 15.67
c A1:B1 12.67
cd A1:B2 11.33
de A4:B2 9.333
e A3:B2 8.333
有互作的多重比较可知,A2:B2互作效果最好,显著高于A2:B1、A1:B1、A1:B2、A4:B2、A3:B2。
暂无数据