User Tools

Site Tools


repeated_measure_anova

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
repeated_measure_anova [2022/05/10 10:29] hkimscilrepeated_measure_anova [2024/05/01 08:27] (current) hkimscil
Line 1: Line 1:
-See also, [[ANOVA]], [[:Factorial Anova|Factorial ANOVA]], [[:t-test#동일집단_간의_차이에_대해서_알아볼_때|paired sample t-test]] [[:r:repeated_measure_anova]] +See also, [[ANOVA]], [[:Factorial Anova|Factorial ANOVA]], [[:t-test#동일집단_간의_차이에_대해서_알아볼_때|paired sample t-test]] [[:r:repeated_measures_anova]] 
 ====== Repeated Measure ANOVA ====== ====== Repeated Measure ANOVA ======
 Introduction Introduction
Line 79: Line 79:
  
 -- Picture about here -- -- Picture about here --
 +{{:pasted:20240501-082722.png}} 
 +---- 
 +{{:pasted:20240501-082738.png}} 
 +----
   * but, $\text{SS}_\text{{within}}$ can be partitioned as    * but, $\text{SS}_\text{{within}}$ can be partitioned as 
     * $\text{SS}_{\text{ subjects}}$ and $\text{SS}_{\text{ error}}$     * $\text{SS}_{\text{ subjects}}$ and $\text{SS}_{\text{ error}}$
 +    * that is, some of the "within variation" are carried along in each individual.  
     * Among the two, we can exclude the first from SS<sub>within</sub>     * Among the two, we can exclude the first from SS<sub>within</sub>
     * and solely use the latter as SS<sub>error</sub>     * and solely use the latter as SS<sub>error</sub>
Line 100: Line 104:
 |  **Grand mean: 45.9**      ||||| |  **Grand mean: 45.9**      |||||
  
-We do this (and the below example) with an excel {{:repeated_measures_anova_eg.xlsx|spreadsheet}}. +We do this (and the below example) with an excel {{:r:repeated_measures_anova_eg.xlsx|spreadsheet}}. 
 We also require {{:ftable.pdf|fdistribution table}} to determine the null hypothesis test. We also require {{:ftable.pdf|fdistribution table}} to determine the null hypothesis test.
  
Line 125: Line 129:
  
 SS<sub>total</sub> = $\Sigma{(X-\overline{X})^2} $ = 3489.2 \\ SS<sub>total</sub> = $\Sigma{(X-\overline{X})^2} $ = 3489.2 \\
-SS<sub>participants</sub> = $w\Sigma{(\overline{X}_{participants}-\overline{X})}$ = 833.6 \\ + 
-SS<sub>weeks</sub> = $n\Sigma{(\overline{X}_{week} - \overline{X})}$ = 1934.\\ +SS<sub>between</sub> 
-SS<sub>residual</sub>  \\ += SS<sub>conditions</sub>  
-= SS<sub>error</sub> \\ += SS<sub>weeks</sub>  
-= SS<sub>total</sub> - SS<sub>participants</sub> - SS<sub>weeks</sub>  \\+= $n\Sigma{(\overline{X}_{week} - \overline{X})^2}$ = 1934.5 \\ 
 + 
 +SS<sub>within</sub>  
 += $ \Sigma \Sigma{(X_{s_i.t_j} - \overline{X_{t_j}})^2}$  
 += $ \Sigma (411.6, 836.0, 78.0, 93.6, 135.6) $  
 += 1554.7  
 +\\ 
 + 
 +SS<sub>participants</sub> = $w\Sigma{(\overline{X}_{participants}-\overline{X})^2}$ = 833.\\ 
 + 
 +SS<sub>residual</sub> 
 += SS<sub>error</sub>  
 += SS<sub>within</sub> - SS<sub>participants</sub> 
 += 1554.7 - 833.6 
 += 721.1 
 + 
 +OR 
 +SS<sub>residual</sub>
 += SS<sub>error</sub>  
 += (SS<sub>total</sub> - SS<sub>weeks(between)</sub>) - SS<sub>participants</sub>  
 = 721.1 \\ = 721.1 \\
 \\ \\
Line 236: Line 259:
 </code> </code>
  
 +see {{:r:repeated_measures_anova_eg.xlsx}}
 +===== demo 2 =====
 +<code>
 +# create 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
 +
 +# within sujbect anova
 +within.aov.mod <- aov(response~drug+Error(patient), data=df)
 +</code>
 +
 +<code>
 +> #create 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
 +   patient drug response
 +1        1    1       30
 +2        1    2       28
 +3        1    3       16
 +4        1    4       34
 +5        2    1       14
 +6        2    2       18
 +7        2    3       10
 +8        2    4       22
 +9        3    1       24
 +10          2       20
 +11          3       18
 +12          4       30
 +13          1       38
 +14          2       34
 +15          3       20
 +16          4       44
 +17          1       26
 +18          2       28
 +19          3       14
 +20          4       30
 +
 +> #within sujbect anova
 +> within.aov.mod <- aov(response~drug+Error(patient), data=df)
 +
 +
 +> summary(within.aov.mod)
 +
 +Error: patient
 +          Df Sum Sq Mean Sq F value Pr(>F)
 +Residuals  1   67.6    67.6               
 +
 +Error: Within
 +          Df Sum Sq Mean Sq F value Pr(>F)
 +drug         11.6   11.56   0.139  0.714
 +Residuals 17 1412.6   83.10 
 +</code>
 +The above is <fc #ff0000>**WRONG**</fc>.
 +<code>
 +within.aov.mod <- aov(response~factor(drug)+Error(factor(patient)), data=df)
 +
 +summary(within.aov.mod)
 +</code>
 +
 +<code>
 +> within.aov.mod <- aov(response~factor(drug)+Error(factor(patient)), data=df)
 +
 +
 +> summary(within.aov.mod)
 +
 +Error: factor(patient)
 +          Df Sum Sq Mean Sq F value Pr(>F)
 +Residuals  4  680.8   170.2               
 +
 +Error: Within
 +             Df Sum Sq Mean Sq F value   Pr(>F)    
 +factor(drug)  3  698.2   232.7   24.76 1.99e-05 ***
 +Residuals    12  112.8     9.4                     
 +---
 +Signif. codes:  
 +0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
 +
 +
 +</code>
 +====== two way ======
 <code> <code>
 demo1  <- read.csv("https://stats.idre.ucla.edu/stat/data/demo1.csv") demo1  <- read.csv("https://stats.idre.ucla.edu/stat/data/demo1.csv")
repeated_measure_anova.1652146181.txt.gz · Last modified: 2022/05/10 10:29 by hkimscil

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki