User Tools

Site Tools


r:repeated_measures_anova

This is an old revision of the document!


Repeated measures ANOVA

demo1  <- read.csv("https://stats.idre.ucla.edu/stat/data/demo1.csv")
## Convert variables to factor
demo1 <- within(demo1, {
  group <- factor(group)
  time <- factor(time)
  id <- factor(id)
})

par(cex = .6)

with(demo1, interaction.plot(time, group, pulse,
  ylim = c(5, 20), lty= c(1, 12), lwd = 3,
  ylab = "mean of pulse", xlab = "time", trace.label = "group"))

demo1.aov <- aov(pulse ~ group * time + Error(id), data = demo1)
summary(demo1.aov)

> 
> demo1  <- read.csv("https://stats.idre.ucla.edu/stat/data/demo1.csv")
> ## Convert variables to factor
> demo1 <- within(demo1, {
+     group <- factor(group)
+     time <- factor(time)
+     id <- factor(id)
+ })
> 
> par(cex = .6)
> 
> with(demo1, interaction.plot(time, group, pulse,
+                              ylim = c(5, 20), lty= c(1, 12), lwd = 3,
+                              ylab = "mean of pulse", xlab = "time", trace.label = "group"))
> 
> demo1.aov <- aov(pulse ~ group * time + Error(id), data = demo1)
> summary(demo1.aov)

Error: id
          Df Sum Sq Mean Sq F value  Pr(>F)    
group      1 155.04  155.04    3721 1.3e-09 ***
Residuals  6   0.25    0.04                    
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Error: Within
           Df Sum Sq Mean Sq F value Pr(>F)
time        2 0.0833 0.04167       1  0.397
group:time  2 0.0833 0.04167       1  0.397
Residuals  12 0.5000 0.04167               
> 
> 
r/repeated_measures_anova.1591198948.txt.gz · Last modified: 2020/06/04 00:42 by hkimscil

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki