Take the 2-minute tour ×
Cross Validated is a question and answer site for people interested in statistics, machine learning, data analysis, data mining, and data visualization. It's 100% free, no registration required.

I am a novice to program R and have been trying to perform a repeated measures ANCOVA with Temperature as the dependent variable, Site as the independent variable, Date as the covariate and Year as the repeated measures.

My dataset consists of temperatures from 4 sites, over 20 days, during 2 different years. There appears to be a significant effect of site, date and year on temperature, but no significant interaction between site and year or site and date. I originally performed two separate ANCOVAs, but my coauthor wants them in a single model. As far as I can tell, there is no simple way to do a repeated measures ANCOVA as there is for ANOVA.

I have tried using: lm(formula = Temp~Site*Date + Year) , but wouldn't this just put year as an interaction that doesn't affect the model?

Any help you can provide would be GREATLY appreciated!

share|improve this question
    
1) From the text it sounds like you want to fit the Date:Year interaction, but not Site:Year or Site:Date; however, the lm code has the Site:Date interaction but not the others. 2) Why do you think there's no Site:Year interaction if you've only fit two separate ANCOVAs? –  Aaron Nov 28 '11 at 15:37
    
Also, sample data can greatly help in describing your setup and comparing possible solutions. I've posted an example as an answer; consider modifying (if necessary) and editing your answer to include it. –  Aaron Nov 28 '11 at 15:46
add comment

3 Answers

There is a list of tutorials on this subject here:

http://www.r-statistics.com/2010/04/repeated-measures-anova-with-r-tutorials/

Good luck.

share|improve this answer
add comment

Sample data?

set.seed(5)
d <- expand.grid(Site=LETTERS[1:4], Date=1:20, Year=factor(1:2))
d$Temp <- round(rnorm(nrow(d), mean=60, sd=15))
share|improve this answer
add comment

Maybe you can try

lm(formula = Temp~Site*(Date + Year))

In this way you will have two interactions with the Site, and there will be no interaction between Date and year

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.