1、Wilcoxon Signed Rank Test

Wilcoxon有符号秩检验(也称为Wilcoxon有符号秩和检验)是一种非参数检验。当统计数据中使用“非参数”一词时,并不意味着您对总体一无所知。这通常意味着总体数据没有正态分布。如果两个数据样本来自重复观察,那么它们是匹配的。利用Wilcoxon Signed-Rank检验,在不假设数据服从正态分布的前提下,判断出相应的数据总体分布是否相同如果数据对之间的差异是非正态分布的,则应使用Wilcoxon有符号秩检验。

The Wilcoxon signed rank test (also called the Wilcoxon signed rank sum test) is a non-parametric test. When the word “non-parametric” is used in stats, it doesn’t quite mean that you know nothing about the population. It usually means that you know the population data does not have a normal distribution. The Wilcoxon signed rank test should be used if the differences between pairs of data are non-normally distributed.

有两个稍微不同的测试版本:
Wilcoxon符号秩检验将样本中值与假设中值进行比较。
Wilcoxon匹配对有符号秩检验计算每组匹配对之间的差异,然后按照与有符号秩检验相同的步骤将样本与某个中值进行比较。

Two slightly different versions of the test exist:
The Wilcoxon signed rank test compares your sample median against a hypothetical median.
The Wilcoxon matched-pairs signed rank test computes the difference between each set of matched pairs, then follows the same procedure as the signed rank test to compare the sample against some median.

这个检验的零假设是两个样本的中位数相等。它通常用于:
作为单样本t检验或配对t检验的非参数替代。
对于没有数字刻度的有序(排序)分类变量。

The null hypothesis for this test is that the medians of two samples are equal. It is generally used:
As a non-parametric alternative to the one-sample t test or paired t test.
For ordered (ranked) categorical variables without a numerical scale.

2、How to Run the Test by Hand

运行测试的要求:
必须匹配数据。
因变量必须是连续的(即您必须能够区分小数点后第n位的值)。
你应该没有并列的队伍,以达到最高的准确性。如果等级是相等的,有一个变通方法(见下面步骤5之后)。

Requirements for running the test:
Data must be matched.
The dependent variable must be continuous (i.e. you must be able to distinguish between values at the nth decimal place).
You should have no tied ranks for maximum accuracy. If ranks are tied, there is a workaround (see below, after Step 5).

3、手动计算

样本问题:以下2组治疗数据的中值是否存在差异?

Step 1: 从治疗1中减去治疗2得到差异

注意:如果你只有一个样本,计算每个变量和0之间的差(假设中值),而不是对之间的差

Note: If you only have one sample, calculate the differences between each variable and zero (the hypothesized median) instead of the difference between pairs.

Step 2:将差异按顺序排列(下图第二列),然后进行排序。按顺序排列时忽略这个符号。

Step 3:创建第三列,并注意差异的符号(您在步骤2中忽略的那个)

Step 4: 计算负差的秩和(第3步图中带负号的秩和)。你在这里加起来,而不是实际的差异:

W = 1 + 2 + 4 = 7

Step 5:计算正差异的秩和(步骤3图中带正号的)。
W+ = 3 + 5.5 + 5.5 + 7 + 8 + 9 + 10 + 11 + 12 = 71

Step 6:使用带有Wilcoxin符号秩的正态逼近

你可以利用以上资料做些什么?如果观测值/对 n(n+1)/2大于20,可以使用正态逼近。这组数据满足这个要求(12(12 + 1)/ 2 = 78。z分数公式有几个修改/注意事项:

使用W+或W-中较小的值作为测试统计量。
使用以下公式的意思是,μ:n(n + 1)/ 4。
使用以下公式σ:√(n(n + 1)(2 n + 1)/ 24)
如果你有tied ranks,你必须减少t3-tσ/ 48 t的行列。有两个并列排名(5.5 + 5.5),所以减少8-2/48σ= 0.125。

在z表中查找这个分数,我们得到面积为0.9880,等于双尾p值为0.012。这是一个很小的p值,这是一个强有力的迹象,表明中位数是显著不同的。

4、用R计算Wilcoxin

在名为immer的内建数据集中,记录了1931年和1932年同一领域的大麦产量。收益率数据显示在数据框的Y1和Y2列中。

问题(problem):在不假设数据为正态分布的情况下,以0.05显著性水平检验数据集immer中1931年和1932年的大麦产量是否具有相同的数据分布。

Solution:

零假设是两个样本年的大麦产量是相同的。为了验证这个假设,我们使用wilcox。测试函数对匹配的样本进行比较。对于配对测试,我们将“配对”参数设置为TRUE。由于p值为0.005318,小于0.05的显著性水平,我们拒绝原假设。

The null hypothesis is that the barley yields of the two sample years are identical populations. To test the hypothesis, we apply the wilcox.test function to compare the matched samples. For the paired test, we set the "paired" argument as TRUE. As the p-value turns out to be 0.005318, and is less than the .05 significance level, we reject the null hypothesis. 

wilcox.test(immer$Y1, immer$Y2, paired=TRUE) ,#其中其它参数如 exact, correct选择不同的话,可能p值结果不同,根据实际情况选择

5、python计算

import scipy.stats
x=[57.07168,46.95301,31.86423,38.27486,77.89309,76.78879,33.29809,58.61569,18.26473,62.92256,50.46951,19.14473,22.58552,24.14309]
y=[8.319966,2.569211,1.306941,8.450002,1.624244,1.887139,1.376355,2.521150,5.940253,1.458392,3.257468,1.574528,2.338976]
scipy.stats.ranksums(x, y)

Wilcoxon Signed Rank Test的更多相关文章

  1. 非参数检验|Sign test|Wilcoxon signed rank test|Wilcoxon rank sum test|Bootstrapping

    非参数检验条件没有参数,因此就没有分布,利用数据等级之间的差距,依次赋值之后再用参数方法测试.将连续型变量转化为离散型变量,即顺序变量.与参数检验相比,正态分布较弱(p值有可能不显著,浪费信息,比如最 ...

  2. r 随机数

    R软件一个显著的优点是它提供了丰富的随机数发生器,比SAS.Matlab方面很多,比Excel更不知方便到哪里去了.这无疑为统计学.工程学以及寿险精算学提供了很大的方便,比如我们要产生200个服从正态 ...

  3. Parametric Statistics

    1.What are “Parametric Statistics”? 统计中的参数指的是总体的一个方面,而不是统计中的一个方面,后者指的是样本的一个方面.例如,总体均值是一个参数,而样本均值是一个统 ...

  4. 曼-惠特尼U检验Mann–Whitney U Test

    sklearn实战-乳腺癌细胞数据挖掘(博主亲自录制视频教程) https://study.163.com/course/introduction.htm?courseId=1005269003&am ...

  5. How to Compare Means (均值比较)

    在比较数据的均值时,我们可能知道: 比较工厂当天生产的零件的长度是否合格 (length >= N mm),用 t-Test; 比较各一线城市的人均收入,用 ANOVA. 其实均值比较还有很多检 ...

  6. R in action读书笔记(7)-第七章:基本统计分析(下)

    7.3相关 相关系数可以用来描述定量变量之间的关系.相关系数的符号(±)表明关系的方向(正相关或负相关),其值的大小表示关系的强弱程度(完全不相关时为0,完全相关时为1).除了基础安装以外,我们还将使 ...

  7. Chapter 07-Basic statistics(Part4 t-tests&&nonparametric tests of group difference)

    一. t-tests 这一部分我们使用分布在MASS包中的UScrime数据集.它是关于美国47个州在1960年时,关于惩罚制度对犯罪率的影响. Prob:监禁(坐牢)的概率: U1:14到24岁的城 ...

  8. [R]统计工具包

    Wilcoxon Rank Sum and Signed Rank Tests data <-read.csv('XX.csv') wilcox.test(data$value1, data$v ...

  9. R中的各种概率统计分布

    名称 名称 R对应的名字 附加参数 β分布 beta beta shape1, shape2, ncp 二项式分布 binomial binom size, prob 柯西分布 Cauchy cauc ...

随机推荐

  1. C# Web Service 初级教学

    原文连接:http://www.codeproject.com/cs/webservices/myservice.asp作者:Chris Maunder Introduction Creating y ...

  2. spring扩展点之三:Spring 的监听事件 ApplicationListener 和 ApplicationEvent 用法,在spring启动后做些事情

    <spring扩展点之三:Spring 的监听事件 ApplicationListener 和 ApplicationEvent 用法,在spring启动后做些事情> <服务网关zu ...

  3. 2天时间终于把ntopng装好了

    1.环境centos6.7x642.安装步骤,首先把centos按优化步骤完成3.更改centos的yum源,更改为阿里云的源.4.[root@netmon ntopng]# cat /etc/yum ...

  4. TSubobjectPtr和C++传统指针的区别

    转自:http://aigo.iteye.com/blog/2282142 主要有以下区别(1和2的前提条件要满足:指针所在的class必须是UObjcct的子类): 1,TSubobjectPtr指 ...

  5. 最强数据集50个最佳机器学习公共数据,可以帮你验证idea!

    1.  寻找数据集の奥义 根据CMU的说法,寻找一个好用的数据集需要注意一下几点: 数据集不混乱,否则要花费大量时间来清理数据. 数据集不应包含太多行或列,否则会难以使用. 数据越干净越好,清理大型数 ...

  6. javascript变量作用域 — 全局变量

    javascript中,如果没有用var 声明一个变量,则该变量会被自动创建在全局作用域中,即使你是在某个函数中创建的,它也会成为全局变量,从而可以被另一个函数调用.

  7. Python3 引入sqlite3时出现错误:ModuleNotFoundError: No module named '_sqlite3'

    在Python3 中内置了SQLite3,但是在编译安装完之后执行: import sqlite3 出现错误: ModuleNotFoundError: No module named '_sqlit ...

  8. django的小操作,查询效率up, 引用art-template模板+djangorestframework

    Part1: 提高查询效率newses = News.objects.select_related('category', 'author').get(id=1) # category和author字 ...

  9. [Illuminate\Database\QueryException] SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using pas sword: NO) (SQL: select * from information_schema.tables where table_schema = la

    [Illuminate\Database\QueryException] SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost ...

  10. 关于pthreads的使用

    产品想实现PHP端的多线程下载 百度了下找到了一个方法,通常需要开启PHP线程安全策略,就是 编译安装的时候  --enable-maintainer-zts 然后安装pthreads扩展, 但是pt ...