User Tools

Site Tools


r:repeated_measures_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
r:repeated_measures_anova [2020/06/03 15:53] – [e.g. 4] hkimscilr:repeated_measures_anova [2026/04/27 04:51] (current) – [exer1] hkimscil
Line 335: Line 335:
 Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
  
 +</code>
 +
 +====== exer1 ======
 +<code>
 +exer1  <- read.csv("https://stats.idre.ucla.edu/stat/data/exer.csv")
 +str(exer1)
 +exer1 <- within(exer1, {
 +  diet <- factor(diet)
 +  exertype <- factor(exertype)
 +  time <- factor(time)
 +  id <- factor(id)
 +}) ## 이제 pulse만 제외하고 모두 factor로 변환된 데이터
 +
 +str(exer1)
 +with(exer1, interaction.plot(time, diet, pulse,
 +                             ylim = c(80, 120), lty = c(1, 12), lwd = 3,
 +                             ylab = "mean of pulse", xlab = "time", trace.label = "diet"))
 +with(exer1, interaction.plot(time, exertype, pulse,
 +                             ylim = c(80, 120), lty = c(1, 12), lwd = 3,
 +                             ylab = "mean of pulse", xlab = "time", trace.label = "exertype"))
 +with(exer1, interaction.plot(exertype, diet, pulse,
 +                             ylim = c(80, 120), lty = c(1, 12), lwd = 3,
 +                             ylab = "mean of pulse", xlab = "exertype", trace.label = "diet"))
 +
 +
 +exer1a.aov <- aov(pulse ~ exertype * time + Error(id/time), data = exer1)
 +summary(exer1a.aov)
 +
 +exer1b.aov <- aov(pulse ~ diet * time + Error(id/time), data = exer1)
 +summary(exer1b.aov)
 +
 +exer1c.aov <- aov(pulse ~ diet * exertype, data = exer1)
 +summary(exer1c.aov)
 +</code>
 +<code>
 +> exer1  <- read.csv("https://stats.idre.ucla.edu/stat/data/exer.csv")
 +> str(exer1)
 +'data.frame': 90 obs. of  5 variables:
 + $ id      : int  1 1 1 2 2 2 3 3 3 4 ...
 + $ diet    : int  1 1 1 1 1 1 1 1 1 1 ...
 + $ exertype: int  1 1 1 1 1 1 1 1 1 1 ...
 + $ pulse   : int  85 85 88 90 92 93 97 97 94 80 ...
 + $ time    : int  1 2 3 1 2 3 1 2 3 1 ...
 +> exer1 <- within(exer1, {
 ++   diet <- factor(diet)
 ++   exertype <- factor(exertype)
 ++   time <- factor(time)
 ++   id <- factor(id)
 ++ }) ## 이제 pulse만 제외하고 모두 factor로 변환된 데이터
 +
 +> str(exer1)
 +'data.frame': 90 obs. of  5 variables:
 + $ id      : Factor w/ 30 levels "1","2","3","4",..: 1 1 1 2 2 2 3 3 3 4 ...
 + $ diet    : Factor w/ 2 levels "1","2": 1 1 1 1 1 1 1 1 1 1 ...
 + $ exertype: Factor w/ 3 levels "1","2","3": 1 1 1 1 1 1 1 1 1 1 ...
 + $ pulse   : int  85 85 88 90 92 93 97 97 94 80 ...
 + $ time    : Factor w/ 3 levels "1","2","3": 1 2 3 1 2 3 1 2 3 1 ...
 +> with(exer1, interaction.plot(time, diet, pulse,
 ++                              ylim = c(80, 120), lty = c(1, 12), lwd = 3,
 ++                              ylab = "mean of pulse", xlab = "time", trace.label = "diet"))
 +> with(exer1, interaction.plot(time, exertype, pulse,
 ++                              ylim = c(80, 120), lty = c(1, 12), lwd = 3,
 ++                              ylab = "mean of pulse", xlab = "time", trace.label = "exertype"))
 +
 +> with(exer1, interaction.plot(exertype, diet, pulse,
 ++                              ylim = c(80, 120), lty = c(1, 12), lwd = 3,
 ++                              ylab = "mean of pulse", xlab = "exertype", trace.label = "diet"))
 +
 +
 +> exer1a.aov <- aov(pulse ~ exertype * time + Error(id/time), data = exer1)
 +> summary(exer1a.aov)
 +
 +Error: id
 +          Df Sum Sq Mean Sq F value   Pr(>F)    
 +exertype     8326    4163      27 3.62e-07 ***
 +Residuals 27   4163     154                     
 +---
 +Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
 +
 +Error: id:time
 +              Df Sum Sq Mean Sq F value   Pr(>F)    
 +time             2067  1033.3   23.54 4.45e-08 ***
 +exertype:time  4   2723   680.8   15.51 1.65e-08 ***
 +Residuals     54   2370    43.9                     
 +---
 +Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
 +
 +> exer1b.aov <- aov(pulse ~ diet * time + Error(id/time), data = exer1)
 +> summary(exer1b.aov)
 +
 +Error: id
 +          Df Sum Sq Mean Sq F value Pr(>F)  
 +diet         1262    1262   3.147 0.0869 .
 +Residuals 28  11227     401                 
 +---
 +Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
 +
 +Error: id:time
 +          Df Sum Sq Mean Sq F value   Pr(>F)    
 +time         2067  1033.3  11.808 5.26e-05 ***
 +diet:time  2    193    96.4   1.102    0.339    
 +Residuals 56   4901    87.5                     
 +---
 +Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
 +
 +> exer1c.aov <- aov(pulse ~ diet * exertype, data = exer1)
 +> summary(exer1c.aov)
 +              Df Sum Sq Mean Sq F value   Pr(>F)    
 +diet             1262    1262  11.465  0.00108 ** 
 +exertype         8326    4163  37.824 1.94e-12 ***
 +diet:exertype  2    816     408   3.706  0.02868 *  
 +Residuals     84   9245     110                     
 +---
 +Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
 +
 +</code>
 +{{.:pasted:20260427-045018.png}}
 +{{.:pasted:20260427-045026.png}}
 +{{.:pasted:20260427-045032.png}}
 +<code>
 +> exer1
 +   id diet exertype pulse time
 +1      1        1    85    1
 +2      1        1    85    2
 +3      1        1    88    3
 +4      1        1    90    1
 +5      1        1    92    2
 +6      1        1    93    3
 +7      1        1    97    1
 +8      1        1    97    2
 +9      1        1    94    3
 +10  4    1        1    80    1
 +11  4    1        1    82    2
 +12  4    1        1    83    3
 +13  5    1        1    91    1
 +14  5    1        1    92    2
 +15  5    1        1    91    3
 +16  6    2        1    83    1
 +17  6    2        1    83    2
 +18  6    2        1    84    3
 +19  7    2        1    87    1
 +20  7    2        1    88    2
 +21  7    2        1    90    3
 +22  8    2        1    92    1
 +23  8    2        1    94    2
 +24  8    2        1    95    3
 +25  9    2        1    97    1
 +26  9    2        1    99    2
 +27  9    2        1    96    3
 +28 10    2        1   100    1
 +29 10    2        1    97    2
 +30 10    2        1   100    3
 +31 11    1        2    86    1
 +32 11    1        2    86    2
 +33 11    1        2    84    3
 +34 12    1        2    93    1
 +35 12    1        2   103    2
 +36 12    1        2   104    3
 +37 13    1        2    90    1
 +38 13    1        2    92    2
 +39 13    1        2    93    3
 +40 14    1        2    95    1
 +41 14    1        2    96    2
 +42 14    1        2   100    3
 +43 15    1        2    89    1
 +44 15    1        2    96    2
 +45 15    1        2    95    3
 +46 16    2        2    84    1
 +47 16    2        2    86    2
 +48 16    2        2    89    3
 +49 17    2        2   103    1
 +50 17    2        2   109    2
 +51 17    2        2    90    3
 +52 18    2        2    92    1
 +53 18    2        2    96    2
 +54 18    2        2   101    3
 +55 19    2        2    97    1
 +56 19    2        2    98    2
 +57 19    2        2   100    3
 +58 20    2        2   102    1
 +59 20    2        2   104    2
 +60 20    2        2   103    3
 +61 21    1        3    93    1
 +62 21    1        3    98    2
 +63 21    1        3   110    3
 +64 22    1        3    98    1
 +65 22    1        3   104    2
 +66 22    1        3   112    3
 +67 23    1        3    98    1
 +68 23    1        3   105    2
 +69 23    1        3    99    3
 +70 24    1        3    87    1
 +71 24    1        3   132    2
 +72 24    1        3   120    3
 +73 25    1        3    94    1
 +74 25    1        3   110    2
 +75 25    1        3   116    3
 +76 26    2        3    95    1
 +77 26    2        3   126    2
 +78 26    2        3   143    3
 +79 27    2        3   100    1
 +80 27    2        3   126    2
 +81 27    2        3   140    3
 +82 28    2        3   103    1
 +83 28    2        3   124    2
 +84 28    2        3   140    3
 +85 29    2        3    94    1
 +86 29    2        3   135    2
 +87 29    2        3   130    3
 +88 30    2        3    99    1
 +89 30    2        3   111    2
 +90 30    2        3   150    3
 +>
 </code> </code>
r/repeated_measures_anova.1591199612.txt.gz · Last modified: by hkimscil

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki