analysis of covariance:
some experiments combine regression and ANOVA by fitting a series of regression lines, one in each of several levels of a given factor .
One-way ANOVA:
to compare several means, but it does this by comparing variances.
Assumptions of ANOVA:
random sampling;
equal variances;
independence of errors;
normal distribution of errors;
additivity of treatment effects.
example of one-way ANOVA
results <- read.table("c:\\temp\\yields.txt",header=T)
attach(results)
names(results)
sapply(list(sand,clay,loam),mean)
(frame <- stack(results))
names(frame) <- c("yield","soil")
attach(frame)
head(frame)
tapply(yield,soil,var)
We test for heteroscedasticity using the Fligner–Killeen test of homogeneity of variances:
fligner.test(y~soil)
bartlett.test(y~soil)
plot(yield~soil,col="green")
sum((yield-mean(yield))ˆ2)
sum(sapply(list(sand,clay,loam),function (x) sum((x-mean(x))ˆ2) ))
mean(tapply(yield,soil,var))
qf(.95,2,27)
1-pf(4.24,2,27)
summary(aov(yield~soil))
to check the assumptions of the aov model.
par(mfrow=c(2,2))
plot(aov(yield~soil))
Effect sizes
model <- aov(yield~soil)
model.tables(model,se=T)
model.tables(model,"means",se=T)
error.bars <- function(yv,z,nn)
{xv <- barplot(yv,ylim=c(0,(max(yv)+max(z)))col="green",names=nn,ylab=deparse(substitute(yv)))
for (i in 1:length(xv)) {arrows(xv[i],yv[i]+z[i],xv[i],yv[i]-z[i],angle=90,code=3,length=0.15)
}}
model <- aov(biomass~clipping)
summary(model)
table(clipping)
se <- rep(28.75,5)
labels <- levels(clipping)
ybar <- tapply(biomass,clipping,mean)
error.bars(ybar,se,labels)
error.bars(ybar,2.570582*se,labels)
lsd <- qt(0.975,10)*sqrt(2*4961/6)
lsdbars <- rep(lsd,5)/2
error.bars(ybar,lsdbars,labels)
附录:
参考文献:
1)box-and-whisker plots:
The box-and-whisker plot is good at showing the nature of the variation within each treatment, and also
whether there is skew within each treatment (e.g. for the control plots, there is a wider range of values between
the median and third quartile than between the median and first quartile).
Barplots with error
Barplots with error bars are preferred by many journal editors, and some people think that they make hypothesis testing easier
2)
LSD
(最小显著性差异法)
LSD(Least—SignificantDifference),最小显著性差异法,是Fisher于1935年提出的。用T检验完成各组间的配对比较,检验的敏感性高,各个水平间的均值存在微小的差异也有可能被检验出来,但此方法对第一类弃真错误的概率不进行控制和调整。


1万+

被折叠的 条评论
为什么被折叠?



