Contents

[-]
1 Wilcoxon rank sum test
2 Wilcoxon signed rank test
3 Mood Test
4 Kurskal-Wallis Test
5 median.test


비모수 검정이다.

1 Wilcoxon rank sum test #

  • 두 집단이 정규분포가 아닌 경우 메디안 차이 검정
  • 균등 분포나 Cauchy 분포와 같은 대칭 분포를 따르는 것으로 가정
  • 대칭성의 가정을 확인할 수 없는 경우에는 대칭 분포를 가정하지 않는 Wilcoxon signed rank test을 사용
  • 두 집단의 모양이 같다면 사용
x1 <- c(0.80, 0.83, 1.89, 1.04, 1.45, 1.38, 1.91, 1.64, 0.73, 1.46)
x2 <- c(1.15, 0.88, 0.90, 0.74, 1.21)

모양이 같냐?
> ks.test(x1, x2)

	Two-sample Kolmogorov-Smirnov test

data:  x1 and x2
D = 0.6, p-value = 0.1658
alternative hypothesis: two-sided

중앙값이 같냐?
> wilcox.test(x1, x2)

	Wilcoxon rank sum test

data:  x1 and x2
W = 35, p-value = 0.2544
alternative hypothesis: true location shift is not equal to 0

2 Wilcoxon signed rank test #

두 집단이 Paired이고, 정규분포가 아닌 경우 메디안 차이 검정
> x1 <- c(1.83,  0.50,  1.62,  2.48, 1.68, 1.88, 1.55, 3.06, 1.30)
> x2 <- c(0.878, 0.647, 0.598, 2.05, 1.06, 1.29, 1.06, 3.14, 1.29)
> wilcox.test(x1, x2, paired=T)

	Wilcoxon signed rank test

data:  x1 and x2 
V = 40, p-value = 0.03906
alternative hypothesis: true location shift is not equal to 0 

3 Mood Test #

x1 <- c(0.80, 0.83, 1.89, 1.04, 1.45, 1.38, 1.91, 1.64, 0.73, 1.46)
x2 <- c(1.15, 0.88, 0.90, 0.74, 1.21)
mood.test(x1, x2)

> mood.test(x1, x2)

	Mood two-sample test of scale

data:  x1 and x2
Z = 1.3827, p-value = 0.1668
alternative hypothesis: two.sided
귀무가설 지지

4 Kurskal-Wallis Test #

  • 실제 데이터 값 대신 데이터의 순위를 분석에 사용
  • 비모수 검정

> kruskal.test(weight ~ group, data=datasets::PlantGrowth)
	Kruskal-Wallis rank sum test

data:  weight by group 
Kruskal-Wallis chi-squared = 7.9882, df = 2, p-value = 0.01842
  • 가설
    • 귀무가설: 3그룹의 메디안이 같다.
    • 대립가설: 3그룹의 메디안이 다름.
  • p-value = 0.01842 이므로 유의한 차이가 있음.

> library("pgirmess")
> kruskalmc(weight ~ group, data=datasets::PlantGrowth)
Multiple comparison test after Kruskal-Wallis 
p.value: 0.05 
Comparisons
          obs.dif critical.dif difference
ctrl-trt1    4.40     9.425108      FALSE
ctrl-trt2    6.65     9.425108      FALSE
trt1-trt2   11.05     9.425108       TRUE

> levels(warpbreaks$wool)
[1] "A" "B"
> levels(warpbreaks$tension)
[1] "L" "M" "H"
> kruskal.test(breaks ~ wool*tension, data=warpbreaks)

	Kruskal-Wallis rank sum test

data:  breaks by wool by tension 
Kruskal-Wallis chi-squared = 1.3261, df = 1, p-value = 0.2495
  • 가설
    • 귀무가설: 3그룹의 메디안이 같다.
    • 대립가설: 3그룹의 메디안이 다름.
  • p-value = 0.2495 이므로 유의한 차이가 없음.

5 median.test #

--출처: http://www.mail-archive.com/r-help@r-project.org/msg95278.html
median.test<-function(y1,y2){ 
  z<-c(y1,y2) 
  g <- rep(1:2, c(length(y1),length(y2))) 
  m<-median(z) 
  fisher.test(z<m,g)$p.value 
} 

median.test(x1, x2)
Retrieved from http://w.databaser.net/moniwiki/wiki.php/중앙값차이에대한검정
last modified 2018-04-13 23:12:54