User Tools

Site Tools


c:ms:2024:w07_anova_note

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
c:ms:2024:w07_anova_note [2024/04/08 08:47] – created hkimscilc:ms:2024:w07_anova_note [2024/04/17 08:23] (current) hkimscil
Line 6: Line 6:
 # 가설 # 가설
 set.seed(201) set.seed(201)
 +ss <- 16
 rnorm2 <- function(n,mean,sd){ mean+sd*scale(rnorm(n)) } rnorm2 <- function(n,mean,sd){ mean+sd*scale(rnorm(n)) }
-A <- rnorm2(16, 26, sqrt(600/15)) +A <- rnorm2(ss, 26, sqrt(600/15)) 
-B <- rnorm2(16, 24, sqrt(750/15)) +B <- rnorm2(ss, 24, sqrt(750/15)) 
-C <- rnorm2(16, 19, sqrt(900/15))+C <- rnorm2(ss, 19, sqrt(900/15))
  
 A <- c(A) A <- c(A)
 B <- c(B) B <- c(B)
 C <- c(C) C <- c(C)
 +A
 +B
 +C
  
 # 평균구하기 # 평균구하기
Line 19: Line 23:
 mean(B) mean(B)
 mean(C) mean(C)
 +
 +# just checking
 +var(A)
 +var(B)
 +var(C)
 +
 +# 각 그룹의 SS값은?
  
 # 3 샘플을 합치기  # 3 샘플을 합치기 
Line 35: Line 46:
 mean.tot <- mean(comb3$values) mean.tot <- mean(comb3$values)
 ss.tot <- sum((comb3$values-mean.tot)^2) ss.tot <- sum((comb3$values-mean.tot)^2)
-df.tot <- 48-1 +df.tot <- length(comb3$values)-1 
-ms.tot <- ss.tot/df.tot+ms.tot <- ss.tot / df.tot 
 ss.tot ss.tot
 df.tot df.tot
Line 59: Line 71:
  
 ss.within <- ss.a + ss.b + ss.c ss.within <- ss.a + ss.b + ss.c
-ss.within <- ss.within 
  
-16*((m.a-mean.tot)^2) +# 3그룹이 전체평균에서 얼마나 떨어져서 분포되어 있나 보기 위해서  
-16*((m.b-mean.tot)^2) +# 전체평균에서 각 그룹의 평균이 얼마나 떨어져 있는지를 구한 후  
-16*((m.c-mean.tot)^2)+# (deviation score 혹은 error score), 이를 제곱한다  
 +# 위의 세 점수를 더하기 전에 각 그룹에 구성원은 16명씩이므로  
 +# (ss) 이를 곱한 후에 모두 더한다. 이것을 SS between group 
 +# 이라 부른다.  
 +ss*((m.a-mean.tot)^2) 
 +ss*((m.b-mean.tot)^2) 
 +ss*((m.c-mean.tot)^2) 
 +# 그리고 우리는 이것이 독립변인이 존재함으로써 밝혀진  
 +# SS값임을 알고 있다
 ss.bet <- 16*((m.a-mean.tot)^2) + 16*((m.b-mean.tot)^2) + 16*((m.c-mean.tot)^2) ss.bet <- 16*((m.a-mean.tot)^2) + 16*((m.b-mean.tot)^2) + 16*((m.c-mean.tot)^2)
 +ss.bet
 +
 +# 한편 ss.within은 각 그룹 내부에 구성원 간의 
 +# 변화도이므로 (variability) 독립변인이 있음에도
 +# 불구하고 랜덤하게 나타나는 SS이다
 +ss.within
  
 +# 그리고 ss.total은 
 +# 독립변인 때문에 설명되는 혹은 독립변인이 
 +# 있기 때문에 밝혀진 ss.between 값과 
 +# 랜덤하게 흩어진 그룹구성원 간의 ss.within
 +# 값으로 구성된다.
 ss.tot ss.tot
 ss.bet ss.bet
Line 71: Line 101:
 ss.bet + ss.within ss.bet + ss.within
  
 +# 이는 df값도 마찬가지이다. 
 df.tot  df.tot 
 df.within <- df.a + df.b + df.c df.within <- df.a + df.b + df.c
Line 84: Line 115:
 ms.within ms.within
 f.calculated  f.calculated 
 +
 # 이 점수에서의 F critical value = # 이 점수에서의 F critical value =
-fp.value <- pf(f.calculated, df1=2, df2=45, lower.tail = F)+fp.value <- pf(f.calculated, df1 = 2, df2 = 45, lower.tail = F)
 fp.value fp.value
  
Line 92: Line 124:
 fp.value fp.value
  
 +# 컴퓨터 계산이 쉬워지기 전에는 
 +# 아래처럼 0.5 level에서의 f값을 구한 후 
 +# 이것과 계산된 f값을 비교해봤었다. 
 +qf(.05, df1 = 2, df2 = 45, lower.tail = FALSE)
 +f.calculated
 +# 위에서 f.calculated > qf값이므로
 +# f.calculated 값으로 영가설을 부정하고
 +# 연구가설을 채택하면 판단이 잘못일 확률이 
 +# 0.05보다 작다는 것을 안다. 
 +# 그러나 컴퓨터계산이 용이해지고서는 qf대신에
 +# pf를 써서 f.cal 값에 해당하는 prob. level을 
 +# 알아본다. 
  
 a.res <- aov(values ~ group, data=comb3) a.res <- aov(values ~ group, data=comb3)
 a.res.sum <- summary(a.res) a.res.sum <- summary(a.res)
 a.res.sum a.res.sum
 +
 </code> </code>
  
c/ms/2024/w07_anova_note.1712533664.txt.gz · Last modified: 2024/04/08 08:47 by hkimscil

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki