实验设计与分析(第6版,Montgomery)第5章析因设计引导5.7节思考题5.13 R语言解题
本文是实验设计与分析(第6版,Montgomery著,傅珏生译) 第5章析因设计引导5.7节思考题5.13 R语言解题。主要涉及方差分析,正态假设检验,残差分析,交互作用图。
dataframe<-data.frame(
y=c(36,18,30,39,20,37,36,22,33,32,20,34),
column=gl(4,3,12),
row=gl(3,1,12))
summary (dataframe)
dataframe.aov2 <- aov(y~column+row,data=dataframe)
summary (dataframe.aov2)
> summary (dataframe.aov2)
Df Sum Sq Mean Sq F value Pr(>F)
column 3 28.9 9.64 2.006 0.214717
row 2 580.5 290.25 60.399 0.000106 ***
Residuals 6 28.8 4.81
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
with(dataframe,interaction.plot(column,row,y,type="b",pch=19,fixed=T,xlab="column",ylab="y"))
plot.design(y~column*row,data=dataframe)
fit <-lm(y~column+row,data=dataframe)
anova(fit)
summary(fit)
par(mfrow=c(2,2))
plot(fit)
par(mfrow=c(2,2))
plot(as.numeric(dataframe$column), fit$residuals, xlab="column", ylab="Residuals", type="p", pch=16)
plot(as.numeric(dataframe$row), fit$residuals, xlab="row", ylab="Residuals", pch=16)