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 [2024/04/29 08:43] – [예 1] hkimscilfactorial_anova [2024/09/24 08:33] (current) – [예 1] hkimscil
Line 387: Line 387:
 만약에 손으로 계산했다면 R에서  만약에 손으로 계산했다면 R에서 
 <code> <code>
-pf(15.431, 18, lower.tail=F) +de <- read.csv("http://commres.net/wiki/_media/detergent.csv"sep ","header=T
-pf(62.04218, lower.tail=F+de 
-pf(6.75, 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(15.43, 1, 18, lower.tail=F) +
-[1] 0.000985713 +
-> pf(62.04, 2, 18, lower.tail=F) +
-[1] 8.40729e-09 +
-> pf(6.75, 2, 18, lower.tail=F) +
-[1] 0.006496173 +
->  +
-> </code>+
  
 ===== 예 2.  cookie experiment ===== ===== 예 2.  cookie experiment =====
Line 759: 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 statistics Two-Factor_Analysis_of_Variance, 팩토리얼 아노바, 상호작용효과, 주효과}} {{tag>factorial_anova statistics Two-Factor_Analysis_of_Variance, 팩토리얼 아노바, 상호작용효과, 주효과}}
factorial_anova.1714347809.txt.gz · Last modified: 2024/04/29 08:43 by hkimscil

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki