User Tools

Site Tools


factorial_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
factorial_anova [2018/10/30 07:36] hkimscilfactorial_anova [2023/05/08 13:13] (current) – [Materials and links] hkimscil
Line 1: Line 1:
 {{keywords>factorial anova, statistics, research methods, Two-Factor Analysis of Variance, 팩토리얼 아노바, 통계, 조사방법론, 상호작용, 상호작용효과, 주효과}} {{keywords>factorial anova, statistics, research methods, Two-Factor Analysis of Variance, 팩토리얼 아노바, 통계, 조사방법론, 상호작용, 상호작용효과, 주효과}}
 See [[:anova]], [[:repeated measure anova]] See [[:anova]], [[:repeated measure anova]]
-====== Factorial Design ======+====== Factorial ANOVA ======
 t-test와 ANOVA의 섹션까지 다룬것은 모두 하나의 독립변인([[types_of_variables#independent|Independent Variable]])과 하나의 종속변인([[types_of_variables#dependent|Dependent Variable]]) 간의 관계에 대한 규명을 하는 것이었다.  t-test와 ANOVA의 섹션까지 다룬것은 모두 하나의 독립변인([[types_of_variables#independent|Independent Variable]])과 하나의 종속변인([[types_of_variables#dependent|Dependent Variable]]) 간의 관계에 대한 규명을 하는 것이었다. 
  
Line 285: Line 285:
   - Given that the between-treatments SS is equal to 100, what is the SS for the interaction?   - Given that the between-treatments SS is equal to 100, what is the SS for the interaction?
   - Calculate the within-treatments SS, df, and MS for these data.   - Calculate the within-treatments SS, df, and MS for these data.
 +===== 예 1 =====
 +{{detergent.csv}}
 +detergent 는 세탁의 정도를 세제의 종류와 물온도를 독립변인으로 (팩터로) 가설검증을 한 것이다. 데이터는 위의 {{detergent.csv}} 이다. 또한 손으로 Factorial ANOVA를 하기 위해 이 데이터를 엑셀에 정리하여 {{:detergent.anova.by.hand.xlsx}}로 올려 두었다.
  
-===== 예 =====+<code> 
 +de <- read.csv("http://commres.net/wiki/_media/detergent.csv", sep = ",", header=T) 
 +de  
 + 
 +de$type <- factor(de$type, level=c(1,2), label=c("super", "best")) 
 +de$w.temp <- factor(de$w.temp, level=c(1,2,3), label=c("cold", "warm", "hot")) 
 +de 
 + 
 +de.anova <- aov(cleanness ~ type * w.temp, data=de) 
 +summary(de.anova) 
 + 
 +with(de, interaction.plot(x.factor=type,  
 +  trace.factor=w.temp, response=cleanness,  
 +  fun=mean, type="b", legend=T, 
 +  ylab="cleanness", main="Interaction Plot (type by temp)", 
 +  pch=c(1,19))) 
 +   
 + 
 +</code> 
 + 
 +<code> 
 +> de <- read.csv("http://commres.net/wiki/_media/detergent.csv", sep = ",", header=T) 
 +> de  
 +   type w.temp cleanness 
 +1          1         4 
 +2          1         5 
 +3          1         6 
 +4          1         5 
 +5          1         6 
 +6          1         6 
 +7          1         4 
 +8          1         4 
 +9          2         7 
 +10    1      2         9 
 +11    1      2         8 
 +12    1      2        12 
 +13    2      2        13 
 +14    2      2        15 
 +15    2      2        12 
 +16    2      2        12 
 +17    1      3        10 
 +18    1      3        12 
 +19    1      3        11 
 +20    1      3         9 
 +21    2      3        12 
 +22    2      3        13 
 +23    2      3        10 
 +24    2      3        13 
 +>  
 +> de$type <- factor(de$type, level=c(1,2), label=c("super", "best")) 
 +> de$w.temp <- factor(de$w.temp, level=c(1,2,3), label=c("cold", "warm", "hot")) 
 +> de 
 +    type w.temp cleanness 
 +1  super   cold         4 
 +2  super   cold         5 
 +3  super   cold         6 
 +4  super   cold         5 
 +5   best   cold         6 
 +6   best   cold         6 
 +7   best   cold         4 
 +8   best   cold         4 
 +9  super   warm         7 
 +10 super   warm         9 
 +11 super   warm         8 
 +12 super   warm        12 
 +13  best   warm        13 
 +14  best   warm        15 
 +15  best   warm        12 
 +16  best   warm        12 
 +17 super    hot        10 
 +18 super    hot        12 
 +19 super    hot        11 
 +20 super    hot         9 
 +21  best    hot        12 
 +22  best    hot        13 
 +23  best    hot        10 
 +24  best    hot        13 
 +>  
 +> de.anova <- aov(cleanness ~ type * w.temp, data=de) 
 +> summary(de.anova) 
 +            Df Sum Sq Mean Sq F value   Pr(>F)     
 +type          20.17   20.17   9.811  0.00576 **  
 +w.temp       2 200.33  100.17  48.730 5.44e-08 *** 
 +type:w.temp  2  16.33    8.17   3.973  0.03722 *   
 +Residuals   18  37.00    2.06                      
 +--- 
 +Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 
 +>  
 +</code> 
 + 
 +{{:pasted:20200529-165842.png}} 
 + 
 +만약에 손으로 계산했다면 R에서  
 +<code> 
 +pf(9.810810811, 1, 18, lower.tail=F) 
 +pf(48.72972973, 2, 18, lower.tail=F) 
 +pf(3.972972973, 2, 18, lower.tail=F) 
 + 
 + 
 +</code> 
 +<code> 
 +> pf(9.810810811, 1, 18, lower.tail=F) 
 +[1] 0.00575844 
 +> pf(48.72972973, 2, 18, lower.tail=F) 
 +[1] 5.439849e-08 
 +> pf(3.972972973, 2, 18, lower.tail=F) 
 +[1] 0.03722434 
 +>  
 +> </code> 
 + 
 +===== 예 2.  cookie experiment =====
   * {{:AnovaData.sav}} SPSS 데이터    * {{:AnovaData.sav}} SPSS 데이터 
  
Line 297: Line 410:
 $SS_{total}=\Sigma{X^2}-\frac{G^2}{N}$ $SS_{total}=\Sigma{X^2}-\frac{G^2}{N}$
 $SS_{\text{between}}=\Sigma{\frac{T^2}{n}}-\frac{G^2}{N}$ $SS_{\text{between}}=\Sigma{\frac{T^2}{n}}-\frac{G^2}{N}$
-$SS_{within} \Sigma{SS_{each \treatment}} $+$SS_{\text{within}= \Sigma{SS_{\text{each treatment}}} $
  
-$df_{between} k - 1$ +$df_{\text{between} k - 1$ 
-$df_{within} \Sigma{df_{each \; treatment}} $+$df_{\text{within}= \Sigma{df_{each \; treatment}} $
  
 $SS_{total} = SS_{between} + SS_{within}$ $SS_{total} = SS_{between} + SS_{within}$
Line 341: Line 454:
  
   * $SS_{within}$   * $SS_{within}$
-    * $SS_{within} = \Sum{SS_{within}} = 1502 + 940 + 1062 + 1084 = 4588$+    * $SS_{within} = \Sigma{SS_{within}} = 1502 + 940 + 1062 + 1084 = 4588$
   * $SS_{between}$   * $SS_{between}$
     * $SS_{between} = 5108 - 4588 = 520 $     * $SS_{between} = 5108 - 4588 = 520 $
   * $SS_A$   * $SS_A$
   * $SS_B$   * $SS_B$
-  * $SS_{AxB}$+  * $SS_{\text{AxB}}$
 MS MS
   * $MS_{A}$   * $MS_{A}$
   * $MS_{B}$   * $MS_{B}$
-  * $MS_{AxB}$+  * $MS_{\text{AxB}}$
   * $MS_{Within}$   * $MS_{Within}$
 F-ratio F-ratio
   * $F_{A}$   * $F_{A}$
   * $F_{B}$   * $F_{B}$
-  * $F_{AxB}$+  * $F_{\text{AxB}}$
  
 Tests of Between-Subjects Effects  Tests of Between-Subjects Effects
Line 370: Line 483:
 | a R Squared = .102 (Adjusted R Squared = .066)  |||||| | a R Squared = .102 (Adjusted R Squared = .066)  ||||||
  
-<code>cookies <- read.csv("http://commres.net/wiki/_media/cookies.csv"+데이터 파일 
-cookies +{{:r:cookies.csv}} 
-str(cookies) +손으로 계산하기 
-</code>+{{:r:cookies.xlsx}} 
 + 
 +<code> 
 +cookies <- read.csv("http://commres.net/wiki/_media/cookies.csv"
 +cookies 
 + 
 +str(cookies) 
 + 
 +cookies$weight = factor(cookies$weight, levels=c(1,2), labels=c("normal","obese")) 
 +cookies$fullness = factor(cookies$fullness, levels=c(1,2), labels=c("empty","full")) 
 + 
 +str(cookies) 
 +cookies 
 + 
 +with(cookies, interaction.plot(x.factor=fullness,  
 +  trace.factor=weight, response=ncookies,  
 +  fun=mean, type="b", legend=T, 
 +  ylab="num of cookies", main="Interaction Plot", 
 +  pch=c(1,19)))
  
-<code>> cookies$weight <- factor(cookies$weight+cookies.aov <- aov(ncookies ~ weight * fullness, data=cookies) 
-> cookies$fullness <- factor(cookies$fullness)+summary(cookies.aov)
 </code> </code>
  
 <code> <code>
-attach(cookies) +cookies <- read.csv("http://commres.net/wiki/_media/cookies.csv"
-> cookies.aov <- aov(ncookies weight fullness, data=cookies)+> cookies 
 +   weight fullness ncookies 
 +1              1       15 
 +2              1       17 
 +3              1       32 
 +4              1       12 
 +5              1       34 
 +6              1       27 
 +7              1       13 
 +8              1       24 
 +9              1       41 
 +10      1        1       20 
 +11      1        1       23 
 +12      1        1       25 
 +13      1        1        9 
 +14      1        1       21 
 +15      1        1       22 
 +16      1        1       26 
 +17      1        1       26 
 +18      1        1       28 
 +19      1        1       22 
 +20      1        1        3 
 +21      1        2       22 
 +22      1        2        7 
 +23      1        2       15 
 +24      1        2        6 
 +25      1        2        8 
 +26      1        2       18 
 +27      1        2       24 
 +28      1        2       19 
 +29      1        2       11 
 +30      1        2        9 
 +31      1        2       24 
 +32      1        2       19 
 +33      1        2        9 
 +34      1        2       19 
 +35      1        2       29 
 +36      1        2        9 
 +37      1        2       18 
 +38      1        2       17 
 +39      1        2        3 
 +40      1        2       14 
 +41      2        1        7 
 +42      2        1       19 
 +43      2        1        8 
 +44      2        1       23 
 +45      2        1        6 
 +46      2        1       11 
 +47      2        1       18 
 +48      2        1       23 
 +49      2        1       22 
 +50      2        1       16 
 +51      2        1       28 
 +52      2        1       19 
 +53      2        1        2 
 +54      2        1       27 
 +55      2        1       20 
 +56      2        1       25 
 +57      2        1       23 
 +58      2        1       10 
 +59      2        1       19 
 +60      2        1       14 
 +61      2        2       14 
 +62      2        2       21 
 +63      2        2       16 
 +64      2        2       14 
 +65      2        2       17 
 +66      2        2       20 
 +67      2        2       20 
 +68      2        2       21 
 +69      2        2       32 
 +70      2        2       26 
 +71      2        2        9 
 +72      2        2       14 
 +73      2        2       16 
 +74      2        2       15 
 +75      2        2        6 
 +76      2        2        5 
 +77      2        2       12 
 +78      2        2       23 
 +79      2        2       27 
 +80      2        2       32 
 +>  
 +> str(cookies) 
 +'data.frame': 80 obs. of  3 variables: 
 + $ weight  : int  1 1 1 1 1 1 1 1 1 1 ... 
 + $ fullness: int  1 1 1 1 1 1 1 1 1 1 ... 
 + ncookies: int  15 17 32 12 34 27 13 24 41 20 ... 
 +>  
 +> cookies$weight = factor(cookies$weight, levels=c(1,2), labels=c("normal","obese")) 
 +> cookies$fullness = factor(cookies$fullness, levels=c(1,2), labels=c("empty","full")) 
 +>  
 + 
 +> str(cookies) 
 +'data.frame': 80 obs. of  3 variables: 
 + $ weight  : Factor w/ 2 levels "normal","obese": 1 1 1 1 1 1 1 1 1 1 ... 
 + $ fullness: Factor w/ 2 levels "empty","full": 1 1 1 1 1 1 1 1 1 1 ... 
 + $ ncookies: int  15 17 32 12 34 27 13 24 41 20 ... 
 +>  
 +> cookies 
 +   weight fullness ncookies 
 +1  normal    empty       15 
 +2  normal    empty       17 
 +3  normal    empty       32 
 +4  normal    empty       12 
 +5  normal    empty       34 
 +6  normal    empty       27 
 +7  normal    empty       13 
 +8  normal    empty       24 
 +9  normal    empty       41 
 +10 normal    empty       20 
 +11 normal    empty       23 
 +12 normal    empty       25 
 +13 normal    empty        9 
 +14 normal    empty       21 
 +15 normal    empty       22 
 +16 normal    empty       26 
 +17 normal    empty       26 
 +18 normal    empty       28 
 +19 normal    empty       22 
 +20 normal    empty        3 
 +21 normal     full       22 
 +22 normal     full        7 
 +23 normal     full       15 
 +24 normal     full        6 
 +25 normal     full        8 
 +26 normal     full       18 
 +27 normal     full       24 
 +28 normal     full       19 
 +29 normal     full       11 
 +30 normal     full        9 
 +31 normal     full       24 
 +32 normal     full       19 
 +33 normal     full        9 
 +34 normal     full       19 
 +35 normal     full       29 
 +36 normal     full        9 
 +37 normal     full       18 
 +38 normal     full       17 
 +39 normal     full        3 
 +40 normal     full       14 
 +41  obese    empty        7 
 +42  obese    empty       19 
 +43  obese    empty        8 
 +44  obese    empty       23 
 +45  obese    empty        6 
 +46  obese    empty       11 
 +47  obese    empty       18 
 +48  obese    empty       23 
 +49  obese    empty       22 
 +50  obese    empty       16 
 +51  obese    empty       28 
 +52  obese    empty       19 
 +53  obese    empty        2 
 +54  obese    empty       27 
 +55  obese    empty       20 
 +56  obese    empty       25 
 +57  obese    empty       23 
 +58  obese    empty       10 
 +59  obese    empty       19 
 +60  obese    empty       14 
 +61  obese     full       14 
 +62  obese     full       21 
 +63  obese     full       16 
 +64  obese     full       14 
 +65  obese     full       17 
 +66  obese     full       20 
 +67  obese     full       20 
 +68  obese     full       21 
 +69  obese     full       32 
 +70  obese     full       26 
 +71  obese     full        9 
 +72  obese     full       14 
 +73  obese     full       16 
 +74  obese     full       15 
 +75  obese     full        6 
 +76  obese     full        5 
 +77  obese     full       12 
 +78  obese     full       23 
 +79  obese     full       27 
 +80  obese     full       32 
 +>  
 + 
 +> with(cookies, interaction.plot(x.factor=fullness,  
 ++                                trace.factor=weight, response=ncookies,  
 ++                                fun=mean, type="b", legend=T, 
 ++                                ylab="num of cookies", main="Interaction Plot", 
 ++                                pch=c(1,19))) 
 +
 </code> </code>
  
 +{{:pasted:20200602-132951.png}}
 <code> <code>
 +> cookies.aov <- aov(ncookies ~ weight * fullness, data=cookies)
 > summary(cookies.aov) > summary(cookies.aov)
- +                Df Sum Sq Mean Sq F value Pr(>F)   
-                Df Sum Sq Mean Sq F value Pr(>F) +weight               20    20.0   0.331 0.5666   
-weight               20    20.0   0.331 0.5666 +fullness            180   180.0   2.982 0.0883 . 
-fullness            180   180.0   2.982 0.0883 +weight:fullness  1    320   320.0   5.301 0.0241 * 
-weight:fullness  1    320   320.0   5.301 0.0241 +Residuals       76   4588    60.4                 
-Residuals       76   4588    60.4                +
-                  +
-weight            +
-fullness        . +
-weight:fullness * +
-Residuals        +
 --- ---
-Signif. codes:   +Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
-0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1+
  
 </code> </code>
- 
- 
 ===== Interpreting interaction ===== ===== Interpreting interaction =====
 +위에서 두개 독립변인에 대한 주효과가 없었으므로 각 독립변인의 종류 (특성) 별로 어디에서 차이가 났는가를 살피는 것은 의미가 없음. 따라서 아래는 필요한 절차가 아님. 
 <code>> TukeyHSD(cookies.aov, which="weight") <code>> TukeyHSD(cookies.aov, which="weight")
   Tukey multiple comparisons of means   Tukey multiple comparisons of means
Line 451: Line 764:
  
  
-{{tag>factorial anova, statisticsTwo-Factor Analysis of Variance, 팩토리얼 아노바, 상호작용효과, 주효과}}+{{tag>factorial_anova statistics Two-Factor_Analysis_of_Variance, 팩토리얼 아노바, 상호작용효과, 주효과}}
factorial_anova.1540852566.txt.gz · Last modified: 2018/10/30 07:36 by hkimscil

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki