2017-03-26 6 views
1

Mann-Whitney-U 테스트를 실행하고 싶습니다. 그러나 R의 wilcox.test(x~y, conf.int=TRUE)은 이러한 통계를 제공하지 않습니다. N, 평균 순위, 두 요인의 순위, Z 값의 합계. SPSS만큼 많은 정보를 제공하기 위해 R이 필요합니다 (see here)SPSS와 같은 R Mann-Whitney-U 테스트 출력

몇 가지 옵션을 선택하지 않았는지 또는 설치할 수있는 패키지가 있는지 궁금합니다.

감사합니다.

답변

1

R에서는 SPSS의 다양한 출력을 별도로 계산해야합니다. 예를 들어, dplyr::summarise을 사용하는 경우 :

library(dplyr) 
mt_filt <- mtcars %>% 
    filter(cyl > 4) 
mt_filt %>% 
    group_by(cyl) %>% 
    summarise(n = n(), 
      mean_rank_mpg = mean(rank(mpg)), 
      sum_rank_mpg = sum(rank(mpg))) 
# # A tibble: 2 × 4 
#  cyl  n mean_rank_mpg sum_rank_mpg 
#  <dbl> <int>   <dbl>  <dbl> 
# 1  6  7   4.0   28 
# 2  8 14   7.5   105 

# Number in first group 
n1 <- sum(as.integer(factor(mt_filt$cyl)) == 1) 

wilcox.test(mpg ~ cyl, mt_filt) %>% 
    with(data_frame(U = statistic, 
      W = statistic + n1 * (n1 + 1)/2, 
      Z = qnorm(p.value/2), 
      p = p.value)) 
# # A tibble: 1 × 4 
#  U  W   Z   p 
# <dbl> <dbl>  <dbl>  <dbl> 
# 1 93.5 121.5 -3.286879 0.001013045 
+0

두 샘플 상황에 대해 반환되는 통계는 실제로 "W"로 표시됩니다. –

+0

@ 42- 그러나 Mann Whitney U 테스트에서 U와 동일합니다. W의 다른 정의가 있습니다 - http://stats.stackexchange.com/questions/79843/is-the-w-statistic-output-by-wilcox-test-in-r-the-same-as-the- u-statistic –

+0

그것은 정확하게 내 요점이었습니다. –