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 [2023/05/01 01:26] hkimscilfactorial_anova [2024/09/24 08:33] (current) – [예 1] hkimscil
Line 324: Line 324:
 10    1      2         9 10    1      2         9
 11    1      2         8 11    1      2         8
-12    1      2        12+12    1      2        10
 13    2      2        13 13    2      2        13
 14    2      2        15 14    2      2        15
Line 337: Line 337:
 23    2      3        10 23    2      3        10
 24    2      3        13 24    2      3        13
- 
 > de$type <- factor(de$type, level=c(1,2), label=c("super", "best")) > 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$w.temp <- factor(de$w.temp, level=c(1,2,3), label=c("cold", "warm", "hot"))
Line 353: Line 352:
 10 super   warm         9 10 super   warm         9
 11 super   warm         8 11 super   warm         8
-12 super   warm        12+12 super   warm        10
 13  best   warm        13 13  best   warm        13
 14  best   warm        15 14  best   warm        15
Line 366: Line 365:
 23  best    hot        10 23  best    hot        10
 24  best    hot        13 24  best    hot        13
- 
 > de.anova <- aov(cleanness ~ type * w.temp, data=de) > de.anova <- aov(cleanness ~ type * w.temp, data=de)
 > summary(de.anova) > summary(de.anova)
             Df Sum Sq Mean Sq F value   Pr(>F)                 Df Sum Sq Mean Sq F value   Pr(>F)    
-type          20.17   20.17   9.811  0.00576 **  +type             24   24.00   15.43 0.000986 *** 
-w.temp       200.33  100.17  48.730 5.44e-08 *** +w.temp          193   96.50   62.04 8.41e-09 *** 
-type:w.temp  16.33    8.17   3.973  0.03722   +type:w.temp     21   10.50    6.75 0.006496 **  
-Residuals   18  37.00    2.06                     +Residuals   18     28    1.56                     
 --- ---
 Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
 +
 +> 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>
- +{{:pasted:20240429-083635.png}}
-{{:pasted:20200529-165842.png}}+
  
 만약에 손으로 계산했다면 R에서  만약에 손으로 계산했다면 R에서 
 <code> <code>
-pf(9.8108108111, 18, lower.tail=F) +de <- read.csv("http://commres.net/wiki/_media/detergent.csv"sep ","header=T
-pf(48.72972973218, lower.tail=F+de 
-pf(3.972972973, 2, 18, lower.tail=F)+
  
 +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.typenova <- aov(cleanness ~ type * w.temp, data=de)
 +summary(de.typenova)
 +
 +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)))
 +
 +attach(de)
 +table(type, w.temp)
 +n.sub <- length(cleanness)
 +n.type.group <- 2
 +n.w.temp.group <- 3
 +
 +tapply(cleanness, list(type, w.temp), mean) # 각 셀에서의 평균
 +df.within.each <- tapply(cleanness, list(type, w.temp), length) -1  # 각 셀에서의 샘플숫자
 +n.within.each <- df.within.each + 1
 +df.within <- sum(df.within.each) # df within
 +
 +var.within <- tapply(cleanness, list(type, w.temp), var) # var.within
 +ss.within.each <- tapply(cleanness, list(type, w.temp), var) * df.within.each
 +ss.within.each
 +ss.within <- sum(ss.within.each) # ss.within
 +ss.within
 +
 +
 +interaction.plot(type, w.temp, cleanness)
 +
 +mean.type <- tapply(cleanness, list(type), mean)
 +mean.w.temp <- tapply(cleanness, list(w.temp), mean)
 +mean.type
 +mean.w.temp
 +
 +var.type <- tapply(cleanness, list(type), var)
 +var.w.temp <- tapply(cleanness, list(w.temp), var)
 +
 +
 +mean.tot <- mean(cleanness)
 +var.tot <- var(cleanness)
 +n.sub <- length(cleanness)
 +df.tot <- n.sub - 1 
 +ss.tot <- var.tot * df.tot
 +
 +## between
 +mean.each <- tapply(cleanness, list(type, w.temp), mean)
 +mean.each
 +mean.tot <- mean(cleanness)
 +mean.tot
 +n.each <- tapply(cleanness, list(type, w.temp), length)
 +n.each
 +n.type.each <- tapply(cleanness, list(type), length)
 +n.w.temp.each <- tapply(cleanness, list(w.temp), length)
 +
 +ss.w.bet <- sum(n.each*(mean.each-mean.tot)^2)
 +ss.w.bet
 +
 +ss.tot
 +ss.within
 +ss.w.bet
 +ss.w.bet + ss.within
 +
 +ss.type <- sum(n.type.each * ((mean.tot - mean.type)^2))
 +ss.w.temp <- sum(n.w.temp.each * ((mean.tot - mean.w.temp)^2))
 +ss.type
 +ss.w.temp
 +ss.type.w.temp <- ss.w.bet - (ss.type + ss.w.temp)
 +ss.type.w.temp
 +
 +ss.tot
 +ss.w.bet
 +ss.within
 +ss.type
 +ss.w.temp
 +ss.type.w.temp
 +
 +df.tot <- n.sub - 1
 +df.w.bet <- (n.type.group * n.w.temp.group) - 1
 +df.type <- n.type.group - 1
 +df.w.temp <- n.w.temp.group - 1
 +df.type.w.temp <- df.w.bet - (df.type + df.w.temp)
 +df.within <- sum(df.within.each)
 +
 +df.tot
 +df.w.bet
 +df.type
 +df.w.temp
 +df.type.w.temp
 +df.within
 +
 +ms.type <- ss.type / df.type
 +ms.w.temp <- ss.w.temp / df.w.temp
 +ms.type.w.temp <- ss.type.w.temp / df.type.w.temp
 +ms.within <- ss.within / df.within
 +
 +ms.type
 +ms.w.temp
 +ms.type.w.temp
 +ms.within
 +
 +
 +f.type <- ms.type / ms.within
 +f.w.temp <- ms.w.temp / ms.within
 +f.type.w.temp <- ms.type.w.temp / ms.within
 +
 +alpha <- .05
 +# confidence interval
 +ci <- 1 - alpha
 +
 +f.type
 +# 봐야할 F분포표에서의 F-value
 +# qt 처럼 qf 사용
 +# qf(alpha, df.w.between, df.within, lower.tail=F) 처럼 사용
 +qf(ci, df.type, df.within)
 +# 혹은 
 +# qf(alpha, df.type, df.within, lower.tail = F)
 +# 도 마찬가지
 +pf(f.type, df.type, df.within, lower.tail = F)
 +
 +f.w.temp
 +qf(ci, df.w.temp, df.within)
 +pf(f.w.temp, df.w.temp, df.within, lower.tail = F)
 +
 +f.type.w.temp
 +qf(ci, df.type.w.temp, df.within)
 +pf(f.type.w.temp, df.type.w.temp, df.within, lower.tail = F)
 +
 +# aov result
 +summary(de.typenova)
 </code> </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 ===== ===== 예 2.  cookie experiment =====
Line 483: Line 610:
 | a R Squared = .102 (Adjusted R Squared = .066)  |||||| | a R Squared = .102 (Adjusted R Squared = .066)  ||||||
  
- +데이터 파일
-{{http://commres.net/wiki/_media/cookies.csv|cookies.csv}} 데이터파일 위치+
 {{:r:cookies.csv}} {{:r:cookies.csv}}
 +손으로 계산하기
 {{:r:cookies.xlsx}} {{:r:cookies.xlsx}}
  
Line 755: Line 882:
 ====== Materials and links ====== ====== Materials and links ======
   * {{:AnovaData.sav}}   * {{:AnovaData.sav}}
-  * http://www.uwsp.edu/psych/stat/13/anova-2w.htm  
  
-  * http://faculty.vassar.edu/lowry/ch16pt1.html 
-  * http://faculty.vassar.edu/lowry/ch16pt2.html 
-  * http://faculty.vassar.edu/lowry/ch16pt3.html 
-  * http://faculty.vassar.edu/lowry/ch16pt4.html 
-  * http://faculty.vassar.edu/lowry/ch16pt5.html 
  
  
-{{tag>factorial anova, statisticsTwo-Factor Analysis of Variance, 팩토리얼 아노바, 상호작용효과, 주효과}}+{{tag>factorial_anova statistics Two-Factor_Analysis_of_Variance, 팩토리얼 아노바, 상호작용효과, 주효과}}
factorial_anova.1682872019.txt.gz · Last modified: 2023/05/01 01:26 by hkimscil

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki