'scheffe test'에 해당되는 글 1건

  1. 2015.11.05 R (4) 대비 (contrasts) : 샤페 검정법 (scheffe test) 2

지난 포스팅에서 (1) 한개의 요인에 대해 집단 간 평균을 비교하는 one-way ANOVA, (2) 짝을 이룬 두 집단간 사후 다중비교(post-hoc pair-wise multiple comparison) 방법으로 튜키 검정법(Tukey HSD(honestly significant difference) Test), 던칸 검정법(Duncan LSR(least significant range) Test) 에 대해서 알아보았습니다.  복습을 해보자면, 다중비교는 설정된 유의수준의 크기를 그대로 유지한 상태에서 모든 가능한 두 수준평균간의 차이에 대한 검정을 사후에 동시에 시행하는 방법이었습니다.

 

☞ one-way ANOVA 참고

☞ Tukey's HSD(honestly significant difference) test 참고

☞ Duncan's LSR(least significant range) test 참고

 

 

이번 포스팅에서는 (a) 다중비교 시에 표본의 크기가 다를 경우에도 우수한 검정력을 보여주며 (b) 세 개 이상의 요인 수준(factor levels) 간의 평균들을 비교할 때도 사용 가능한 샤페검정법(scheffe test)을 소개하도록 하겠습니다. 

 

 

"Scheffé's method is a single-step multiple comparison procedure which applies to the set of estimates of all possible contrasts among the factor level means, not just the pairwise differences considered by the Tukey–Kramer method"

 

* source : wikipedia 

 

 

Tukey HSD test와 Duncan LSR test 와 Scheffe test 간의 차이점 비교는 아래 도식화를 참고하시기 바라며, Scheffe test는 Duncan LSR test와 함께 상당히 보수적(conservative)인 검정법으로 알려져 있습니다. 

 

 

[categorization of test method by '# of factor levels' & 'sample size']

 

 

 

 

분산분석에서는 둘 이상의 수준(factor levels) 평균들을 포함하는 비교를 하기 위해 각 수준들의 평균 μi 를 하나의 직선식으로 표현한 것을 대비(Contrasts)라고 하며 L로 표기하면, L의 추정량(estimated contrast L^)과 추정량의 분산(estimated variance of L^), 샤폐계수 T (scheffe's T statistics)는 아래와 같습니다.

 

 

[ Scheffe's T statistics ]

 

 

 

 

Scheffe Test 의 가설과 검정 방법은 아래와 같습니다.

 

 

 

 


 

 

R에서 scheffe test를 하기 위해 agricolae package scheffe.test() 함수를 사용하였습니다. 

 

그리고 데이터는 agricolae package에 내장되어있는 sweetpotato dataframe을 사용하였습니다.  virus 라는 1개의 요인(one-way)에 대해서 cc, fc, ff, oo 의 4개의 수준(4 factor levels)에 대해 감자 생산량(yield)의 차이가 있는지를 동시에 비교 평가하기 위해 scheffe test를 적용해보았습니다.  (요인수준 4개에 대해 동시에 비교하기 위해 scheffe test 적용함.  유의수준 α = 0.05)

 

one-way ANOVA 분석 들어가기 전에 탐색적 분석 차원에서 boxplot을 그려보고, 기초통계량(doBy package의 summaryBy 함수 사용)을 뽑아보았습니다.  참고하시구요.

 

 

> ##--------------------------------------------------------------
> ## single-step multiple comparison, contrasts : scheffe.test()
> ##--------------------------------------------------------------
> 
> install.packages("agricolae")
Installing package into ‘C:/Users/user/Documents/R/win-library/3.2’
(as ‘lib’ is unspecified)
trying URL 'http://cran.rstudio.com/bin/windows/contrib/3.2/agricolae_1.2-3.zip'
Content type 'application/zip' length 920587 bytes (899 KB)
downloaded 899 KB

package ‘agricolae’ successfully unpacked and MD5 sums checked

The downloaded binary packages are in
	C:\Users\user\AppData\Local\Temp\RtmpyASqz8\downloaded_packages
> library(agricolae)
> data(sweetpotato)
> 
> str(sweetpotato)
'data.frame':	12 obs. of  2 variables:
 $ virus: Factor w/ 4 levels "cc","fc","ff",..: 1 1 1 2 2 2 3 3 3 4 ...
 $ yield: num  28.5 21.7 23 14.9 10.6 13.1 41.8 39.2 28 38.2 ...
> 
> # boxplot of yield of sweetpatoto, dealt with different virus
> attach(sweetpotato)
> boxplot(yield ~ virus, 
+         main = "Yield of sweetpotato, Dealt with different virus", 
+         xlab = "Virus", 
+         ylab = "Yield")
> detach(sweetpotato)
>

 

 

 
> 
> # statistics summary by group("virus")
> install.packages("doBy")
Installing package into ‘C:/Users/user/Documents/R/win-library/3.2’
(as ‘lib’ is unspecified)
trying URL 'http://cran.rstudio.com/bin/windows/contrib/3.2/doBy_4.5-13.zip'
Content type 'application/zip' length 3431380 bytes (3.3 MB)
downloaded 3.3 MB

package ‘doBy’ successfully unpacked and MD5 sums checked

The downloaded binary packages are in
	C:\Users\user\AppData\Local\Temp\RtmpyASqz8\downloaded_packages
> library(doBy)
필요한 패키지를 로딩중입니다: survival
> summaryBy(yield ~ virus, data=sweetpotato, FUN = c(mean, sd, min, max))
  virus yield.mean yield.sd yield.min yield.max
1    cc   24.40000 3.609709      21.7      28.5
2    fc   12.86667 2.159475      10.6      14.9
3    ff   36.33333 7.333030      28.0      41.8
4    oo   36.90000 4.300000      32.1      40.4
> 
> 
> # ANOVA test
> aov_sweetpotato <- aov(yield~virus, data=sweetpotato)
> summary(aov_sweetpotato)
            Df Sum Sq Mean Sq F value   Pr(>F)    
virus        3 1170.2   390.1   17.34 0.000733 ***
Residuals    8  179.9    22.5                     
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
> 
> 
> # scheffe test
> comparison <- scheffe.test(aov_sweetpotato, # ANOVA model 
+                            "virus", # vector treatment applied to each experimental unit
+                            alpha = 0.05, # significant level
+                            group=TRUE, 
+                            console=TRUE, # print out
+                            main="Yield of sweetpotato\nDealt with different virus")

Study: Yield of sweetpotato
Dealt with different virus

Scheffe Test for yield 

Mean Square Error  : 22.48917 

virus,  means

      yield      std r  Min  Max
cc 24.40000 3.609709 3 21.7 28.5
fc 12.86667 2.159475 3 10.6 14.9
ff 36.33333 7.333030 3 28.0 41.8
oo 36.90000 4.300000 3 32.1 40.4

alpha: 0.05 ; Df Error: 8 
Critical Value of F: 4.066181 

Minimum Significant Difference: 13.52368 

Means with the same letter are not significantly different.

Groups, Treatments and means
a 	 oo 	 36.9 
a 	 ff 	 36.33 
ab 	 cc 	 24.4 
b 	 fc 	 12.87

 

 

위의 scheffe test 수행 결과를 보니 virus (treatement) 'oo'와 'ff'는 같은 'a' group으로 묶였으며 0.05 유의수준 하에서 차이가 없는 것(귀무가설 H0 채택)으로 나왔습니다. virus (treatement) 'fc'는 'b' group으로 따로 묶였으며, 유의수준 0.05 에서 'oo', 'ff'와는 차이가 있는 것(귀무가설 H0 기각)으로 판단할 수 있습니다. virus (treatment) 'cc'는 'a'와 'b' group 사이에 애매하게 끼어서 차이가 없는 것으로 나왔네요.  위에 파란색으로 해놓은 'Minimum Significant Difference: 13.52368' 를 보면 'cc' virus 에 의한 감자 생산량 평균 '24.4'가 'fc' virus에 의한 생산량 '12.86'과의 차이가 '13.52368'보다는 작으며, 'ff' virus에 의한 생산량 '36.33'과의 차이도 역시 '13.5268'보다는 작음을 알 수 있습니다.

 

많은 도움 되셨기를 바랍니다.

 

☞ one-way ANOVA 참고

☞ Tukey's HSD(honestly significant difference) test 참고

☞ Duncan's LSR(least significant range) test 참고

 

 

이번 포스팅이 도움이 되었다면 아래의 '공감 ~♡'를 꾸욱 눌러주세요. ^^

 

728x90
반응형
Posted by Rfriend
,