r:repeated_measures_anova
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
r:repeated_measures_anova [2020/06/04 00:43] – hkimscil | r:repeated_measures_anova [2020/06/04 00:53] (current) – [e.g. 4] hkimscil | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Repeated measures ANOVA ====== | ====== Repeated measures ANOVA ====== | ||
+ | ====== e.g. 1 ====== | ||
< | < | ||
demo1 <- read.csv(" | demo1 <- read.csv(" | ||
Line 9: | Line 10: | ||
}) | }) | ||
+ | demo1 | ||
+ | |||
+ | par(cex = .6) | ||
+ | |||
+ | with(demo1, interaction.plot(time, | ||
+ | ylim = c(5, 20), lty= c(1, 12), lwd = 3, | ||
+ | ylab = "mean of pulse", | ||
+ | |||
+ | demo1.aov <- aov(pulse ~ group * time + Error(id), data = demo1) | ||
+ | summary(demo1.aov) | ||
+ | |||
+ | </ | ||
+ | |||
+ | {{: | ||
+ | < | ||
+ | > | ||
+ | > demo1 <- read.csv(" | ||
+ | > ## Convert variables to factor | ||
+ | > demo1 <- within(demo1, | ||
+ | + group <- factor(group) | ||
+ | + time <- factor(time) | ||
+ | + id <- factor(id) | ||
+ | + }) | ||
+ | > | ||
> demo1 | > demo1 | ||
id group pulse time | id group pulse time | ||
Line 35: | Line 60: | ||
23 8 | 23 8 | ||
24 8 | 24 8 | ||
+ | > par(cex = .6) | ||
+ | > | ||
+ | > with(demo1, interaction.plot(time, | ||
+ | + ylim = c(5, 20), lty= c(1, 12), lwd = 3, | ||
+ | + ylab = "mean of pulse", | ||
+ | > | ||
+ | > demo1.aov <- aov(pulse ~ group * time + Error(id), data = demo1) | ||
+ | > summary(demo1.aov) | ||
+ | Error: id | ||
+ | Df Sum Sq Mean Sq F value Pr(> | ||
+ | group 1 155.04 | ||
+ | Residuals | ||
+ | --- | ||
+ | Signif. codes: | ||
+ | Error: Within | ||
+ | Df Sum Sq Mean Sq F value Pr(>F) | ||
+ | time 2 0.0833 0.04167 | ||
+ | group: | ||
+ | Residuals | ||
+ | > | ||
+ | > | ||
+ | </ | ||
+ | ====== e.g. 2 ====== | ||
+ | < | ||
+ | demo2 <- read.csv(" | ||
+ | ## Convert variables to factor | ||
+ | demo2 <- within(demo2, | ||
+ | group <- factor(group) | ||
+ | time <- factor(time) | ||
+ | id <- factor(id) | ||
+ | }) | ||
+ | |||
+ | demo2 | ||
par(cex = .6) | par(cex = .6) | ||
- | with(demo1, interaction.plot(time, | + | with(demo2, interaction.plot(time, |
- | ylim = c(5, 20), lty= c(1, 12), lwd = 3, | + | ylim = c(10, 40), lty = c(1, 12), lwd = 3, |
ylab = "mean of pulse", | ylab = "mean of pulse", | ||
- | demo1.aov <- aov(pulse ~ group * time + Error(id), data = demo1) | + | demo2.aov <- aov(pulse ~ group * time + Error(id), data = demo2) |
- | summary(demo1.aov) | + | summary(demo2.aov) |
</ | </ | ||
- | + | {{: | |
- | {{: | + | |
< | < | ||
> | > | ||
- | > demo1 | + | > demo2 <- read.csv(" |
> ## Convert variables to factor | > ## Convert variables to factor | ||
- | > demo1 <- within(demo1, { | + | > demo2 <- within(demo2, { |
+ group <- factor(group) | + group <- factor(group) | ||
+ time <- factor(time) | + time <- factor(time) | ||
+ id <- factor(id) | + id <- factor(id) | ||
+ }) | + }) | ||
+ | > | ||
+ | > demo2 | ||
+ | id group pulse time | ||
+ | 1 | ||
+ | 2 | ||
+ | 3 | ||
+ | 4 | ||
+ | 5 | ||
+ | 6 | ||
+ | 7 | ||
+ | 8 | ||
+ | 9 | ||
+ | 10 4 | ||
+ | 11 4 | ||
+ | 12 4 | ||
+ | 13 5 | ||
+ | 14 5 | ||
+ | 15 5 | ||
+ | 16 6 | ||
+ | 17 6 | ||
+ | 18 6 | ||
+ | 19 7 | ||
+ | 20 7 | ||
+ | 21 7 | ||
+ | 22 8 | ||
+ | 23 8 | ||
+ | 24 8 | ||
> | > | ||
> par(cex = .6) | > par(cex = .6) | ||
> | > | ||
- | > with(demo1, interaction.plot(time, | + | > with(demo2, interaction.plot(time, |
- | + ylim = c(5, 20), lty= c(1, 12), lwd = 3, | + | + ylim = c(10, 40), lty = c(1, 12), lwd = 3, |
+ ylab = "mean of pulse", | + ylab = "mean of pulse", | ||
> | > | ||
- | > demo1.aov <- aov(pulse ~ group * time + Error(id), data = demo1) | + | > demo2.aov <- aov(pulse ~ group * time + Error(id), data = demo2) |
- | > summary(demo1.aov) | + | > summary(demo2.aov) |
+ | |||
+ | Error: id | ||
+ | Df Sum Sq Mean Sq F value Pr(>F) | ||
+ | group 1 15.04 | ||
+ | Residuals | ||
+ | |||
+ | Error: Within | ||
+ | Df Sum Sq Mean Sq F value | ||
+ | time 2 978.2 | ||
+ | group: | ||
+ | Residuals | ||
+ | --- | ||
+ | Signif. codes: | ||
+ | > | ||
+ | </ | ||
+ | ====== e.g. 3 ====== | ||
+ | < | ||
+ | demo3 <- read.csv(" | ||
+ | ## Convert variables to factor | ||
+ | demo3 <- within(demo3, | ||
+ | group <- factor(group) | ||
+ | time <- factor(time) | ||
+ | id <- factor(id) | ||
+ | }) | ||
+ | |||
+ | demo3 | ||
+ | |||
+ | par(cex = .6) | ||
+ | |||
+ | with(demo3, interaction.plot(time, | ||
+ | ylim = c(10, 60), lty = c(1, 12), lwd = 3, | ||
+ | ylab = "mean of pulse", | ||
+ | |||
+ | demo3.aov <- aov(pulse ~ group * time + Error(id), data = demo3) | ||
+ | summary(demo3.aov) | ||
+ | </ | ||
+ | {{: | ||
+ | < | ||
+ | > demo3 <- read.csv(" | ||
+ | > ## Convert variables to factor | ||
+ | > demo3 <- within(demo3, | ||
+ | + group <- factor(group) | ||
+ | + time <- factor(time) | ||
+ | + id <- factor(id) | ||
+ | + }) | ||
+ | > | ||
+ | > demo3 | ||
+ | id group pulse time | ||
+ | 1 | ||
+ | 2 | ||
+ | 3 | ||
+ | 4 | ||
+ | 5 | ||
+ | 6 | ||
+ | 7 | ||
+ | 8 | ||
+ | 9 | ||
+ | 10 4 | ||
+ | 11 4 | ||
+ | 12 4 | ||
+ | 13 5 | ||
+ | 14 5 | ||
+ | 15 5 | ||
+ | 16 6 | ||
+ | 17 6 | ||
+ | 18 6 | ||
+ | 19 7 | ||
+ | 20 7 | ||
+ | 21 7 | ||
+ | 22 8 | ||
+ | 23 8 | ||
+ | 24 8 | ||
+ | > | ||
+ | > par(cex = .6) | ||
+ | > | ||
+ | > with(demo3, interaction.plot(time, | ||
+ | + ylim = c(10, 60), lty = c(1, 12), lwd = 3, | ||
+ | + ylab = "mean of pulse", | ||
+ | > | ||
+ | > demo3.aov <- aov(pulse ~ group * time + Error(id), data = demo3) | ||
+ | > summary(demo3.aov) | ||
Error: id | Error: id | ||
Df Sum Sq Mean Sq F value Pr(> | Df Sum Sq Mean Sq F value Pr(> | ||
- | group 1 155.04 155.04 3721 1.3e-09 *** | + | group 1 2035.0 2035.0 |
- | Residuals | + | Residuals |
--- | --- | ||
Signif. codes: | Signif. codes: | ||
Error: Within | Error: Within | ||
- | Df Sum Sq Mean Sq F value Pr(>F) | + | Df Sum Sq Mean Sq F value |
- | time 2 0.0833 0.04167 1 0.397 | + | time 2 2830.3 1415.2 |
- | group: | + | group: |
- | Residuals | + | Residuals |
+ | --- | ||
+ | Signif. codes: | ||
+ | > | ||
+ | </ | ||
+ | |||
+ | ====== e.g. 4 ====== | ||
+ | < | ||
+ | demo4 <- read.csv(" | ||
+ | ## Convert variables to factor | ||
+ | demo4 <- within(demo4, | ||
+ | group <- factor(group) | ||
+ | time <- factor(time) | ||
+ | id <- factor(id) | ||
+ | }) | ||
+ | |||
+ | demo4 | ||
+ | |||
+ | par(cex = .6) | ||
+ | |||
+ | with(demo4, interaction.plot(time, | ||
+ | | ||
+ | ylab = "mean of pulse", | ||
+ | |||
+ | demo4.aov <- aov(pulse ~ group * time + Error(id), data = demo4) | ||
+ | summary(demo4.aov) | ||
+ | |||
+ | </ | ||
+ | {{: | ||
+ | < | ||
> | > | ||
+ | > demo4 <- read.csv(" | ||
+ | > ## Convert variables to factor | ||
+ | > demo4 <- within(demo4, | ||
+ | + group <- factor(group) | ||
+ | + time <- factor(time) | ||
+ | + id <- factor(id) | ||
+ | + }) | ||
+ | > | ||
+ | > demo4 | ||
+ | id group pulse time | ||
+ | 1 | ||
+ | 2 | ||
+ | 3 | ||
+ | 4 | ||
+ | 5 | ||
+ | 6 | ||
+ | 7 | ||
+ | 8 | ||
+ | 9 | ||
+ | 10 4 | ||
+ | 11 4 | ||
+ | 12 4 | ||
+ | 13 5 | ||
+ | 14 5 | ||
+ | 15 5 | ||
+ | 16 6 | ||
+ | 17 6 | ||
+ | 18 6 | ||
+ | 19 7 | ||
+ | 20 7 | ||
+ | 21 7 | ||
+ | 22 8 | ||
+ | 23 8 | ||
+ | 24 8 | ||
+ | > | ||
+ | > par(cex = .6) | ||
+ | > | ||
+ | > with(demo4, interaction.plot(time, | ||
+ | + ylim = c(10, 60), lty = c(1, 12), lwd = 3, | ||
+ | + ylab = "mean of pulse", | ||
+ | > | ||
+ | > demo4.aov <- aov(pulse ~ group * time + Error(id), data = demo4) | ||
+ | > summary(demo4.aov) | ||
+ | |||
+ | Error: id | ||
+ | Df Sum Sq Mean Sq F value | ||
+ | group 1 2542.0 | ||
+ | Residuals | ||
+ | --- | ||
+ | Signif. codes: | ||
+ | |||
+ | Error: Within | ||
+ | Df Sum Sq Mean Sq F value | ||
+ | time 2 1 | ||
+ | group: | ||
+ | Residuals | ||
+ | --- | ||
+ | Signif. codes: | ||
> | > | ||
</ | </ |
r/repeated_measures_anova.1591198997.txt.gz · Last modified: 2020/06/04 00:43 by hkimscil