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
Next revisionBoth sides next revision
factorial_anova [2019/02/20 21:45] hkimscilfactorial_anova [2020/06/02 14:01] – [예] hkimscil
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 = "\t", 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>
 +
 +{{:pasted:20200529-165842.png}}
  
 ===== 예 ===== ===== 예 =====
Line 370: Line 395:
 | 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 
-> str(cookies) 
-</code> 
  
-<code>cookies$weight <- factor(cookies$weight) +{{http://commres.net/wiki/_media/cookies.csv|cookies.csv}} 데이터파일 위치 
-cookies$fullness <- factor(cookies$fullness)+<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))) 
 + 
 +cookies.aov <- aov(ncookies ~ weight * fullness, data=cookies) 
 +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")
factorial_anova.txt · Last modified: 2023/05/08 13:13 by hkimscil

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki