문제

What is the generic code to perform a repeated measures ANOVA?

I am currently using the code:

summary(aov(Chlo~Site,data=alldata)). 

There are three different sites (Site) and four expirmental variables that I am testing individually (Chlo, SST, DAC and PAR). I am also assessing any differences in these variables and year (between 2003 and 2012):

summary(aov(Chlo~Year,data=year))

Any help would be appreciated!

도움이 되었습니까?

해결책

In general you should avoid performing multiple calls with aov and rather use a mixed effects linear model.

You can find several examples in this post by Paul Gribble

I often use the nlme package, such as:

require(nlme)
model <- lme(dv ~ myfactor, random = ~1|subject/myfactor, data=mydata)

Depending on the situation you may run in more complex situations, I would suggest to have a look at the very clear book by Julian Faraway "Extending the Linear Model with R: Generalized Linear, Mixed Effects and Nonparametric Regression Models".

Also, you may want to ask on CrossValidated if you have more specific statistical questions.

다른 팁

The trick using aov function is that you just need to add Error term. As one of the guides says: The Error term must reflect that we have "treatments nested within subjects".

So, in your case, if Site is a repeated measure you should use:

summary(aov(Chlo ~ Site + Error(subject/Site), data=alldata))
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top