Chapter 31 Nonparametric methods

31.1 The sign test.

The non-parametric alternative to the one sample or paired t-test

## 
##  Paired t-test
## 
## data:  before and after
## t = -0.3954, df = 4, p-value = 0.7127
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -155.6259  116.8259
## sample estimates:
## mean of the differences 
##                   -19.4
## [1] 2
## 
##  Exact binomial test
## 
## data:  2 and 5
## number of successes = 2, number of trials = 5, p-value = 1
## alternative hypothesis: true probability of success is not equal to 0.5
## 95 percent confidence interval:
##  0.05274495 0.85336720
## sample estimates:
## probability of success 
##                    0.4

31.2 Performing sign tests in R

Alternatively, the wilcox.test() function performs a paired sample test of the Wilcoxon signed rank test of the null that the distribution of x - y (in the paired two sample case) is symmetric about mu.

## 
##  Wilcoxon signed rank test
## 
## data:  before and after
## V = 8, p-value = 1
## alternative hypothesis: true location shift is not equal to 0

31.3 A more interesting example.

Generating two random samples or 300 values fron uniform distributions that differ slightly

## [1] 127
## 
##  Exact binomial test
## 
## data:  sum(diff1 < 0) and 300
## number of successes = 127, number of trials = 300, p-value =
## 0.009261
## alternative hypothesis: true probability of success is not equal to 0.5
## 95 percent confidence interval:
##  0.3667592 0.4814368
## sample estimates:
## probability of success 
##              0.4233333
## 
##  Wilcoxon signed rank test with continuity correction
## 
## data:  before1 and after1
## V = 19195, p-value = 0.02462
## alternative hypothesis: true location shift is not equal to 0
## 
##  Paired t-test
## 
## data:  before1 and after1
## t = -2.2709, df = 299, p-value = 0.02387
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -0.102153061 -0.007300815
## sample estimates:
## mean of the differences 
##             -0.05472694

31.4 The Mann-Whitney test.

An alternative to two sample t-test

## 
##  Wilcoxon rank sum test
## 
## data:  sample2 and sample1
## W = 11, p-value = 0.9048
## alternative hypothesis: true location shift is not equal to 0

A more interesting example. generating two random samples or 300 values fron uniform distributions that differ slightly

## [1] -0.109044
## [1] 0.544414
## 
##  Wilcoxon rank sum test with continuity correction
## 
## data:  sample3 and sample4
## W = 39269, p-value = 0.006952
## alternative hypothesis: true location shift is not equal to 0
## 
##  Welch Two Sample t-test
## 
## data:  sample3 and sample4
## t = -2.7738, df = 595.89, p-value = 0.005714
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -1.116131 -0.190785
## sample estimates:
## mean of x mean of y 
## -0.109044  0.544414

31.5 Spearman (rank) correlation

## 
##  Pearson's product-moment correlation
## 
## data:  tumor.grade and gene.expression
## t = 2.9897, df = 6, p-value = 0.02433
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  0.1513500 0.9567115
## sample estimates:
##       cor 
## 0.7735248
## Warning in cor.test.default(tumor.grade, gene.expression, method =
## "spearman"): Cannot compute exact p-value with ties
## 
##  Spearman's rank correlation rho
## 
## data:  tumor.grade and gene.expression
## S = 19.007, p-value = 0.02427
## alternative hypothesis: true rho is not equal to 0
## sample estimates:
##       rho 
## 0.7737226

31.5.1 Comparing spearman and pearson correlation

Will often look similar, but for the example below they differ

## 
##  Pearson's product-moment correlation
## 
## data:  data1 and data2
## t = -4.2488, df = 18, p-value = 0.0004829
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.8758744 -0.3859614
## sample estimates:
##       cor 
## -0.707623
## 
##  Spearman's rank correlation rho
## 
## data:  data1 and data2
## S = 2660, p-value = 5.976e-06
## alternative hypothesis: true rho is not equal to 0
## sample estimates:
## rho 
##  -1