什么是非参数检验?

非参数检验的优点及缺点

Index

Wilcoxon Signed Rank Test

wilconx.test()调用格式

Example 1

 insure<-c(4632,4728,5052,5064,5484,6972,7696,9048,14760,15013,18730,21240,22836,52788,67200) 
 wilcox.test(insure,mu=6064,conf.int=TRUE) 
## 
##  Wilcoxon signed rank test
## 
## data:  insure
## V = 101, p-value = 0.01807
## alternative hypothesis: true location is not equal to 6064
## 95 percent confidence interval:
##   6840 28926
## sample estimates:
## (pseudo)median 
##          13065

P=0.01807<0.05,故拒绝原假设,认为两年的中位数显著不同

Wilcoxon Rank Sum Test

Example 2

 normal<-c(34,43,35,33,34,26,30,31,31,27,28,27,30,37,32)
 diabetes<-c(42,44,38,52,48,46,34,44,38)
 wilcox.test(diabetes,normal,exact=FALSE,correct=FALSE) 
## 
##  Wilcoxon rank sum test
## 
## data:  diabetes and normal
## W = 128, p-value = 0.0003008
## alternative hypothesis: true location shift is not equal to 0

P=0.0003008<0.05,拒绝原价假设,认为这两组体重显著不同

Kruskal-Wallis Test

Kruskal.test()调用格式

Exapmle 3

 x <- list ( a = c(6.4,6.8,7.2,8.3,8.4,9.1,9.4,9.7)
            ,b = c(2.5,3.7,4.9,5.4,5.9,8.1,8.2)
            ,c = c(1.3,4.1,4.9,5.2,5.5,8.2))
 kruskal.test(x)
## 
##  Kruskal-Wallis rank sum test
## 
## data:  x
## Kruskal-Wallis chi-squared = 9.8491, df = 2, p-value = 0.007266

P=0.007266<0.05,故拒绝原假设,认为这三种酒品质不全相同

Spearman rank correlation

调用格式

Example 4

表 6-1 某地地方性甲状腺肿患病率(%)与其食品、水中含碘量的数据

调查地点 含碘量(I) 患病率(morb) 含碘量 患病率 d d2
1 201 0.2 1 7 -6 36
2 178 0.6 2 6 -4 16
3 155 1.1 3 4 -1 1
4 154 0.8 4 5 -1 1
5 126 2.5 5 3 2 4
6 81 4.4 6 2 4 16
7 71 16.9 7 1 6 36
 I <- c(201,178,155,154,126,81,71)
 morb <-c(0.2,0.6,1.1,0.8,2.5,4.4,16.9)
 cor(I,morb,method="spearman")
## [1] -0.9642857

此值大于“等级相关系数 rs 界值表”中的r0.01=0.929,故P<0.01,说明甲状腺肿患病率与当地食品水中含碘量之间呈负相关,即含碘量越高,患病率就越低。

## R version 3.3.3 (2017-03-06)
## Platform: x86_64-pc-linux-gnu (64-bit)
## Running under: Ubuntu 14.04.5 LTS
## 
## locale:
##  [1] LC_CTYPE=zh_CN.UTF-8       LC_NUMERIC=C              
##  [3] LC_TIME=zh_CN.UTF-8        LC_COLLATE=zh_CN.UTF-8    
##  [5] LC_MONETARY=zh_CN.UTF-8    LC_MESSAGES=zh_CN.UTF-8   
##  [7] LC_PAPER=zh_CN.UTF-8       LC_NAME=C                 
##  [9] LC_ADDRESS=C               LC_TELEPHONE=C            
## [11] LC_MEASUREMENT=zh_CN.UTF-8 LC_IDENTIFICATION=C       
## 
## attached base packages:
## [1] stats     graphics  grDevices utils     datasets  methods   base     
## 
## loaded via a namespace (and not attached):
##  [1] backports_1.0.5      magrittr_1.5         rprojroot_1.2       
##  [4] tools_3.3.3          htmltools_0.3.6      yaml_2.1.14         
##  [7] Rcpp_0.12.12         stringi_1.1.5        rmarkdown_1.6.0.9001
## [10] knitr_1.16           stringr_1.2.0        digest_0.6.12       
## [13] evaluate_0.10.1