repeated_measures_anova
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
repeated_measures_anova [2018/05/30 08:28] – hkimscil | repeated_measures_anova [2020/06/11 15:16] – [demo2] hkimscil | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | See also, [[ANOVA]], [[: | + | See also, [[ANOVA]], [[: |
- | ====== Repeated | + | ====== Repeated |
Introduction | Introduction | ||
* one-way ANOVA for // | * one-way ANOVA for // | ||
Line 65: | Line 65: | ||
| j | 2 | 50 | | | j | 2 | 50 | | ||
| k | 3 | 80 | | | k | 3 | 80 | | ||
- | | k | 3 | 50 | | + | | l | 3 | 50 | |
- | | k | 3 | 60 | | + | | m | 3 | 60 | |
- | | k | 3 | 60 | | + | | n | 3 | 60 | |
- | | k | 3 | 40 | | + | | o | 3 | 40 | |
LOGICS | LOGICS | ||
* $\text{independent ANOVA: } F = \displaystyle \frac{MS_{between}}{MS_{within}} = \frac{MS_{between}}{MS_{error}}$ | * $\text{independent ANOVA: } F = \displaystyle \frac{MS_{between}}{MS_{within}} = \frac{MS_{between}}{MS_{error}}$ | ||
- | |||
* $\text{rep measures ANOVA: } F = \displaystyle \frac{MS_{between}}{MS_{within}} = \displaystyle \frac{MS_{conditions}}{MS_{error}}$ | * $\text{rep measures ANOVA: } F = \displaystyle \frac{MS_{between}}{MS_{within}} = \displaystyle \frac{MS_{conditions}}{MS_{error}}$ | ||
+ | |||
+ | 주> | ||
+ | * " | ||
-- Picture about here -- | -- Picture about here -- | ||
Line 143: | Line 145: | ||
| C | 38 | 18 | 40 | | | C | 38 | 18 | 40 | | ||
| D | 45 | 32 | 43 | | | D | 45 | 32 | 43 | | ||
+ | ====== in r ====== | ||
+ | ===== demo1 ===== | ||
+ | |||
+ | [[https:// | ||
+ | <WRAP box info> | ||
+ | data files in e.gs: | ||
+ | {{: | ||
+ | {{: | ||
+ | {{: | ||
+ | {{: | ||
+ | {{: | ||
+ | </ | ||
+ | |||
+ | < | ||
+ | demo1 <- read.csv(" | ||
+ | demo1 | ||
+ | str(demo1) ## 모든 변인이 int이므로 (숫자) factor로 바꿔야 한다 | ||
+ | |||
+ | ## Convert variables to factor | ||
+ | demo1 <- within(demo1, | ||
+ | group <- factor(group) | ||
+ | time <- factor(time) | ||
+ | id <- factor(id) | ||
+ | }) ## 이제 pulse만 제외하고 모두 factor로 변환된 데이터 | ||
+ | |||
+ | str(demo1) | ||
+ | </ | ||
+ | |||
+ | demo1 data는 아래와 같다. | ||
+ | < | ||
+ | id group pulse time | ||
+ | 1 1 10 1 | ||
+ | 1 1 10 2 | ||
+ | 1 1 10 3 | ||
+ | 2 1 10 1 | ||
+ | 2 1 10 2 | ||
+ | 2 1 10 3 | ||
+ | 3 1 10 1 | ||
+ | 3 1 10 2 | ||
+ | 3 1 10 3 | ||
+ | 4 1 10 1 | ||
+ | 4 1 10 2 | ||
+ | 4 1 10 3 | ||
+ | 5 2 15 1 | ||
+ | 5 2 15 2 | ||
+ | 5 2 15 3 | ||
+ | 6 2 15 1 | ||
+ | 6 2 15 2 | ||
+ | 6 2 15 3 | ||
+ | 7 2 16 1 | ||
+ | 7 2 15 2 | ||
+ | 7 2 15 3 | ||
+ | 8 2 15 1 | ||
+ | 8 2 15 2 | ||
+ | 8 2 15 3 | ||
+ | </ | ||
+ | 이를 정리해보면 | ||
+ | |||
+ | || || time |||||||| | ||
+ | || || t1 || t2 || t3 || mean \\ of the \\ same person' | ||
+ | || 1 || 10 || 10 || 10 || 10 || | ||
+ | || 2 || 10 || 10 || 10 || 10 || | ||
+ | || 3 || 10 || 10 || 10 || 10 || | ||
+ | || 4 || 10 || 10 || 10 || 10 || | ||
+ | || 5 || 15 || 15 || 15 || 15 || | ||
+ | || 6 || 15 || 15 || 15 || 15 || | ||
+ | || 7 || 16 || 15 || 15 || 15.333 | ||
+ | || 8 || 15 || 15 || 15 || 15 || | ||
+ | || mean \\ across \\ the time || 12.625 | ||
+ | |||
+ | |||
+ | < | ||
+ | demo1.within.only.aov <- aov(pulse ~ time + Error(id), data = demo1) | ||
+ | summary(demo1.within.only.aov) | ||
+ | </ | ||
+ | |||
+ | < | ||
+ | > demo1.within.only.aov <- aov(pulse ~ time + Error(id), data = demo1) | ||
+ | > summary(demo1.within.only.aov) | ||
+ | |||
+ | Error: id | ||
+ | Df Sum Sq Mean Sq F value Pr(>F) | ||
+ | Residuals | ||
+ | |||
+ | Error: Within | ||
+ | Df Sum Sq Mean Sq F value Pr(>F) | ||
+ | time 2 0.0833 0.04167 | ||
+ | Residuals 14 0.5833 0.04167 | ||
+ | > | ||
+ | </ | ||
+ | |||
+ | < | ||
+ | demo1 <- read.csv(" | ||
+ | demo1 | ||
+ | str(demo1) ## 모든 변인이 int이므로 (숫자) factor로 바꿔야 한다 | ||
+ | |||
+ | ## Convert variables to factor | ||
+ | demo1 <- within(demo1, | ||
+ | group <- factor(group) | ||
+ | time <- factor(time) | ||
+ | id <- factor(id) | ||
+ | }) ## 이제 pulse만 제외하고 모두 factor로 변환된 데이터 | ||
+ | |||
+ | str(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) | ||
+ | </ | ||
+ | |||
+ | < | ||
+ | > 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 | ||
+ | |||
+ | </ | ||
+ | {{: | ||
+ | |||
+ | ===== demo2 ===== | ||
+ | < | ||
+ | demo2 <- read.csv(" | ||
+ | ## Convert variables to factor | ||
+ | demo2 <- within(demo2, | ||
+ | group <- factor(group) | ||
+ | time <- factor(time) | ||
+ | id <- factor(id) | ||
+ | }) | ||
+ | demo2 | ||
+ | |||
+ | with(demo2, interaction.plot(time, | ||
+ | ylim = c(10, 40), lty = c(1, 12), lwd = 3, | ||
+ | ylab = "mean of pulse", | ||
+ | |||
+ | demo2.aov <- aov(pulse ~ group * time + Error(id), data = demo2) | ||
+ | summary(demo2.aov) | ||
+ | </ | ||
+ | |||
+ | {{: | ||
+ | |||
+ | < | ||
+ | > demo2 <- read.csv(" | ||
+ | > ## Convert variables to factor | ||
+ | > demo2 <- within(demo2, | ||
+ | + group <- factor(group) | ||
+ | + time <- factor(time) | ||
+ | + 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 | ||
+ | > | ||
+ | > with(demo2, interaction.plot(time, | ||
+ | + ylim = c(10, 40), lty = c(1, 12), lwd = 3, | ||
+ | + ylab = "mean of pulse", | ||
+ | > | ||
+ | > demo2.aov <- aov(pulse ~ group * time + Error(id), data = demo2) | ||
+ | > 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: | ||
+ | > | ||
+ | </ | ||
====== reference ====== | ====== reference ====== |