제목은 모든 것을 말하고 혼란스러워합니다. 다음은 R에서 반복 측정 aov ()를 실행하고 동등한 lm () 호출이라고 생각한 것을 실행하지만 다른 오차 잔차를 반환합니다 (제곱의 합은 동일하지만).
aov ()의 잔차와 적합치는 모델에서 사용 된 값입니다. 제곱합은 요약 (my.aov)에보고 된 각 모델 / 잔여 제곱합에 합산되기 때문입니다. 그렇다면 반복 측정 설계에 적용되는 실제 선형 모델은 무엇입니까?
set.seed(1)
# make data frame,
# 5 participants, with 2 experimental factors, each with 2 levels
# factor1 is A, B
# factor2 is 1, 2
DF <- data.frame(participant=factor(1:5), A.1=rnorm(5, 50, 20), A.2=rnorm(5, 100, 20), B.1=rnorm(5, 20, 20), B.2=rnorm(5, 50, 20))
# get our experimental conditions
conditions <- names(DF)[ names(DF) != "participant" ]
# reshape it for aov
DFlong <- reshape(DF, direction="long", varying=conditions, v.names="value", idvar="participant", times=conditions, timevar="group")
# make the conditions separate variables called factor1 and factor2
DFlong$factor1 <- factor( rep(c("A", "B"), each=10) )
DFlong$factor2 <- factor( rep(c(1, 2), each=5) )
# call aov
my.aov <- aov(value ~ factor1*factor2 + Error(participant / (factor1*factor2)), DFlong)
# similar for an lm() call
fit <- lm(value ~ factor1*factor2 + participant, DFlong)
# what's aov telling us?
summary(my.aov)
# check SS residuals
sum(residuals(fit)^2) # == 5945.668
# check they add up to the residuals from summary(my.aov)
2406.1 + 1744.1 + 1795.46 # == 5945.66
# all good so far, but how are the residuals in the aov calculated?
my.aov$"participant:factor1"$residuals
#clearly these are the ones used in the ANOVA:
sum(my.aov$"participant:factor1"$residuals ^ 2)
# this corresponds to the factor1 residuals here:
summary(my.aov)
# but they are different to the residuals reported from lm()
residuals(fit)
my.aov$"participant"$residuals
my.aov$"participant:factor1"$residuals
my.aov$"participant:factor1:factor2"$residuals
participant
처럼anova(lm(value ~ factor1*factor2*participant, DFlong))