简体   繁体   English

R中的重复测量方差分析?

[英]Repeated Measures ANOVA in R?

I am looking at average home range size on two sites (one that has undergone habitat restoration and the other is an experimental control) during three phases of the restoration process (before, during, and two years after). 我在恢复过程的三个阶段(之前,期间和之后两年)观察两个站点(一个经历了栖息地恢复,另一个是实验控制)的平均家庭范围大小。 I am wanting to see if differences in mean home range size differ across sites and periods. 我想看看不同站点和时段的平均家庭范围大小的差异是否不同。 Based on having two categorical variables (site and period), I assume this would be done using a repeated measures ANOVA? 基于具有两个分类变量(站点和时段),我假设这将使用重复测量ANOVA来完成? I was needing to see what code would be used since I have never done an ANOVA in R before. 我需要查看将使用哪些代码,因为我之前从未在R中进行过ANOVA。

rm (list = ls())
hrdata=read.csv(xxx)
hrdata

I think you could do this with a linear model, but see ( https://stats.stackexchange.com/questions/20002/regression-vs-anova-discrepancy-aov-vs-lm-in-r ) for a discussion of anova vs regression. 我认为你可以用线性模型做到这一点,但请参阅( https://stats.stackexchange.com/questions/20002/regression-vs-anova-discrepancy-aov-vs-lm-in-r )进行讨论anova vs回归。

the code would look something like this: 代码看起来像这样:

lm1 <- lm(HRS ~ Site * Period, data=hrdata)

The first bit of this code is simply storing this linear model ( lm ) as an R object, which we have named lm1 . 这段代码的第一部分就是将这个线性模型( lm )存储为R对象,我们将其命名为lm1

then you can do: 然后你可以这样做:

summary(lm1)

This would look at the effects of Site (habitat restoration vs control), Period (before, during, and after), and the interaction between the two. 这将考察Site(栖息地恢复与控制),Period(之前,期间和之后)以及两者之间的相互作用的影响。

There are lots of posts about interpreting these summary results. 有很多关于解释这些摘要结果的帖子。 I have posted some below. 我在下面贴了一些。 This first one may be useful if you aren't sure how to interpret the interaction terms: 如果您不确定如何解释交互术语,则第一个可能很有用:

https://stats.stackexchange.com/questions/56784/how-to-interpret-the-interaction-term-in-lm-formula-in-r https://stats.stackexchange.com/questions/56784/how-to-interpret-the-interaction-term-in-lm-formula-in-r

https://stats.stackexchange.com/questions/59250/how-to-interpret-the-output-of-the-summary-method-for-an-lm-object-in-r https://stats.stackexchange.com/questions/59250/how-to-interpret-the-output-of-the-summary-method-for-an-lm-object-in-r

https://stats.stackexchange.com/questions/115304/interpreting-output-from-anova-when-using-lm-as-input https://stats.stackexchange.com/questions/115304/interpreting-output-from-anova-when-using-lm-as-input

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM