r:repeated_measure_anova
This is an old revision of the document!
###################################################
###################################################
###################################################
# data
df <- data.frame(patient=rep(1:5, each=4),
drug=rep(1:4, times=5),
response=c(30, 28, 16, 34,
14, 18, 10, 22,
24, 20, 18, 30,
38, 34, 20, 44,
26, 28, 14, 30))
#view data
df
write.csv(df, file="rep.meas.anova.csv")
#fit repeated measures ANOVA model
df$drug <- factor(df$drug)
df$patient <- factor(df$patient)
# Error(patient) = patient error should be isolated
m.aov <- aov(response ~ drug
+ Error(patient),
data = df)
#view model summary
summary(m.aov)
# check probability level (pr)
1 - pf(24.75886525, 3, 12)
# A one-way repeated measures ANOVA was conducted
# on five individuals to examine the effect that
# four different drugs had on response time.
# Results showed that the type of drug used lead
# to statistically significant differences in
# response time (F(3, 12) = 24.76, p < 0.001).
# the second
movrev <- data.frame(reviewer=rep(1:5, each=3),
movie=rep(1:3, times=5),
score=c(88, 84, 92,
76, 78, 90,
78, 94, 95,
80, 83, 88,
82, 90, 99))
#view data
movrev
write.csv(movrev, file="rep.meas.anova.mov.rev.csv")
movrev$movie <- factor(movrev$movie)
movrev$reviewer <- factor(movrev$reviewer)
# Error(reviewer) = reviewer error should be isolated
# The above is the same as Error(reviewer/movie)
m.aov <- aov(score ~ movie
+ Error(reviewer),
data = movrev)
#view model summary
summary(m.aov)
# pairwise.t.test(movrev$score, movrev$movie, paired = T, p.adjust.method = "bonf")
attach(movrev)
pairwise.t.test(score, movie, paired = T, p.adjust.method = "bonf")
# or
with(movrev,
pairwise.t.test(score, movie,
paired = T,
p.adjust.method = "bonf"))
r/repeated_measure_anova.1715123656.txt.gz · Last modified: by hkimscil
