一、几种检验方法

先说结论:方差分析(或者用Kruskal Wallis)、秩和检验、Holm's method一定要做。

第一个用于确定所有算法有显著差异,第二个生成p-value用于对比,最后一个用于矫正临界值alpha。

如此对比结果才有说服力。

(1)方差分析(Analysis Of Variance,ANOVA)——推荐1

用于多组样本比较,方差齐,正态性。

(在两组和多组比较中,方差齐性的意思是比较各组的方差大小,看看各组的方差是不是差不多大小,如果差别太大,就认为是方差不齐,或方差不等。)

(2)T检验(T-test)

方差齐,正态性。不齐用矫正T检验。

详见:Python统计分析:[1]独立样本T检验

(3)秩和检验( Wilcoxon rank sum test)——推荐2

非参数检验。不满足上面做这个。

排秩中的秩是什么?

答:按照变量“数学”中的数据大小进行排秩的,数据最小的排为1,然后以此类推。重复的数据秩次一样,秩次大小为排秩的平均值。比如有2个64,排在第4、5位,平均秩就为4.5。

(4)邦费罗尼校正(Bonferroni Correction)

多重假设的检验中使用的多种p值校正方法的一种保守方法,容易错误地接受零假设。

(5)霍尔姆方法(Holm’s Sequential Bonferroni Procedure,Holm’s method)——推荐3

邦费罗尼校正的一种矫正版本,没有邦费罗尼校正那么严格的条件。更容易发现显著差异,计算难度和邦费罗尼校正一样。


二、Holm's method详解

计算Holm-Bonferroni的公式是:

Where:

  • Target alpha level = overall alpha level (usually .05),
  • n = number of tests.

计算过程为:(参考链接)

Question: Use the Holm-Bonferroni method to test the following four hypotheses and their associated p-values at an alpha level of .05:

  • H1 = 0.01.
  • H2 = 0.04
  • H3 = 0.03
  • H4 = 0.005

Note: we already know the p-values associated with each hypothesis. If you don’t know the p-values, run a test for each hypothesis before attempting to adjust FWER using the Holm-Bonferroni method. (使用之前,先计算p值)

Step 1: Order the p-values from smallest to greatest:  (p值从小到大排序)

  • H4 = 0.005
  • H1 = 0.01
  • H3 = 0.03
  • H2 = 0.04

Step 2: Work the Holm-Bonferroni formula for the first rank: (对第一个rank运行Holm-Bonferroni公式)
HB = Target α / (n – rank + 1)
HB = .05 / (4 – 1 + 1) = .05 / 4 = .0125.

Step 3: Compare the first-ranked (smallest) p-value from Step 1 to the alpha level calculated in Step 2:
Smallest p-value, in Step 1 (H4 = 0.005) < Alpha level in Step 2 (.0125).
If the p-value is smaller, reject the null hypothesis for this individual test.  (p值小于alpha,表明有显著差异)

The p-value of .005 is less than .0125, so the null hypothesis for H4 is rejected.  (第一步的最小p值和第二步的alpha值比较,前者小于后者,则拒绝空假设)

Step 4: Repeat the HB formula for the second rank (重复上述步骤给第二个rank)
HB = Target α / (n – rank + 1)
HB = .05 / (4 – 2 + 1) = .05 / 3 = .0167

Step 5: Compare the result from the HB formula in Step 4 to the second-ranked p-value:  
Second ranked p-value, in Step 1 (H1 = 0.01) < Alpha level in Step 2 (.0167).
The p-value of .01 is less than .0167, so the null hypothesis for H1 is rejected as well.

Step 6: Repeat the HB formula for the third rank.(重复上述步骤给第三个rank)
HB = Target α / (n – rank + 1)
HB = .05 / (4 – 3 + 1) = .05 / 2 = .025

Step 7: Compare the result from the HB formula in Step 6 to the third-ranked p-value: 
Third ranked p-value, in Step 1 (H3 = 0.03) > Alpha level in Step 6 (.025).
The p-value of .03 is greater than .025, so the null hypothesis for H3 is not rejected.

The testing stops when you reach the first non-rejected hypothesis. All subsequent hypotheses are non-significant (i.e. not rejected).   (当找到第一个不拒绝的假设时,步骤终止;所有后续假设失效)

Reference:
Holm, S. 1979. A simple sequential rejective multiple test procedure. Scandinavian Journal of Statistics 6:65-70

python代码:

# -*- coding: utf-8 -*-# Import standard packages
import numpy as np
from scipy import stats
import pandas as pd
import os# Other required packages
from statsmodels.stats.multicomp import (pairwise_tukeyhsd,MultiComparison)
from statsmodels.formula.api import ols
from statsmodels.stats.anova import anova_lm#数据excel名
excel="sample.xlsx"
#读取数据
df=pd.read_excel(excel)
#获取第一组数据,结构为列表
group_mental=list(df.StressReduction[(df.Treatment=="mental")])
group_physical=list(df.StressReduction[(df.Treatment=="physical")])
group_medical=list(df.StressReduction[(df.Treatment=="medical")])multiComp = MultiComparison(df['StressReduction'], df['Treatment'])def Holm_Bonferroni(multiComp):''' Instead of the Tukey's test, we can do pairwise t-test通过均分a=0.05,矫正a,得到更小a'''# First, with the "Holm" correctionrtp = multiComp.allpairtest(stats.ttest_rel, method='Holm')print((rtp[0]))# and then with the Bonferroni correctionprint((multiComp.allpairtest(stats.ttest_rel, method='b')[0]))# Any value, for testing the program for correct executioncheckVal = rtp[1][0][0,0]return checkValHolm_Bonferroni(multiComp)

代码来自:https://www.cnblogs.com/webRobot/p/6912257.html , (作者:python_education)


三、补充知识

1. M个算法,每个运行N次得到数据集怎么称呼?

microarray data,微阵列数据。每个算法运行N次运行结果为一行(或一列)。

gene list,基因列表。每条基因是一个算法运行N次的结果。

2. 为什么要用Holm’s method

详见 多重检验中p-value的校正

Multiple testing corrections adjust p-values derived from multiple statistical tests to correct for occurrence of false positives. In microarray data analysis, false positives are genes that are found to be statistically different between conditions, but are not in reality.

以Bonferroni correction 为例:

The p-value of each gene is multiplied by the number of genes in the gene list (一个算法重复运行多次得到的一组数据叫做一个基因,每次运行得到基因上的一个基因项). If the
corrected p-value is still below the error rate, the gene will be significant:
Corrected P-value= p-value * n (number of genes in test) <0.05
As a consequence, if testing 1000 genes at a time, the highest accepted individual pvalue
is 0.00005, making the correction very stringent. With a Family-wise error rate
of 0.05 (i.e., the probability of at least one error in the family), the expected number
of false positives will be 0.05.

3. 为什么p值小于0.05很重要?

详见:https://www.jianshu.com/p/4c9b49878f3d

大部分时候,我们假设错误地拒绝H0的概率为0.05,所以如果p值小于0.05,说明错误地拒绝H0的概率很低,则我们有理由相信H0本身是错误的,而非检验错误导致。
大部分时候p-value用于检验独立变量与输入变量的关系,H0假设通常为假设两者没有关系,所以若p值小于0.05,则可以推翻H0(两者没有关系),推出H1(两者有关系)。

例如: 不同的供应区域是否会对商品单价产生统计显著效果?我们做如下假设:

H0:不同供应区域的商品单价没有差异。(零假设)

H1:不同供应区域的商品单价有显著差异,至少有一个供应区域有不同的商品单价。(非零假设)

如果 p_value > α,我们不能拒绝零假设,表明不同供应区域之间的单价并没有显著差异。

代码表示如下:

if p<0.05:print('There is a significant difference.')
else:print('No significant difference.')

另一篇参考文献:http://www.iikx.com/news/statistics/3567.html ,从中可得出,当后续p值被截胡、失去比较机会时,默认是接受空假设,即没有显著差异。

【算法分析】多个对比算法的统计检验方法相关推荐

  1. 基于matlab频率估计算法对比,包括统计M.Westlund算法,BTDT,CZT,ZOOM-FFT 等的

    1.软件版本 matlab2017b 2.仿真对比分析 1统计同步算法:  统计同步算法的基本思路,主要是通过多次采样测试,然后计算对应的概率分布,来确定其同步时刻.测试信号和频率点为: 最后得到的信 ...

  2. 机器学习初学者手抄本:数学基础、机器学习经典算法、统计学习方法等

    机器学习怎么学?当然是系统地学习了.没有时间这么办呢?利用碎片时间学习!很多人一天要花 2 个小时通勤,通勤路上有很多时间看手机.于是我把一些机器学习的基础知识做成了在线的机器学习手册,只需打开微信收 ...

  3. 数学基础、机器学习经典算法、统计学习方法,这份机器学习在线手册来帮你...

    机器学习怎么学?当然是系统地学习了.没有时间这么办呢?利用碎片时间学习!很多人一天要花 2 个小时通勤,通勤路上有很多时间看手机.于是我把一些机器学习的基础知识做成了在线的机器学习手册,只需打开微信收 ...

  4. 不同长度的字符串/中文串相似度对比算法

    1.背景介绍 今天在公司接到一个需求,大概是这样的.我们ERP系统数据库有张customer(客户)表,其中有个字段是小区名称(plotName),当初在录入数据时没有对这一字段做界定和规范,由人工手 ...

  5. 数据结构与算法笔记:抽象思维之对比算法,发现共性(下楼梯台阶和象棋跳马问题算法重构)

    关于抽象思维 我们需要快速应对世界的复杂多变性,我们就需要有抽象思维 抽象思维可以帮助我们提取共性,应对变化 抽象思维是我们认识和表达复杂世界的关键 抽象思维可以帮助我们分析藏在复杂现象背后的本质和规 ...

  6. 如何选择适合自己数据的统计检验方法

    ## 链接 https://statsandr.com/blog/what-statistical-test-should-i-do/ 偶然间发现的一个博文 ![What-statistical-te ...

  7. 26.Vue列表渲染中key的作用与原理(内含虚拟DOM的对比算法详解)

    目录 1.暴露问题,使用index作为key 2.使用唯一标识p.id作为key 3.不写key的配置 4.key的工作原理及虚拟DOM的对比算法 5.总结 25.Vue列表渲染_爱米酱的博客-CSD ...

  8. 人头检测算法,人流量统计,人头计数,人员聚集分析,人脸测温

    人头检测算法,人流量统计,人头计数,人员聚集分析,人脸测温 应用环境:ARM 边缘设备.PC服务器设备 人头检测在安防监控中是比较常用的功能,而公交车.商场或者大型场馆的拥挤人群计数的精准性也非常重要 ...

  9. 富文本对比算法的java实现源码,实现类似word修订记录功能

    富文本对比算法的java实现 文本比较算法利用了两种比较算法,Needleman/Wunsch算法以及google-diff-match-patch算法,对Needleman/Wunsch进行了些许改 ...

最新文章

  1. php zend框架入门,Zend Framework 入门——快速上手
  2. 卷积层和全连接层的区别_1*1的卷积核和全连接层有什么异同?
  3. libevent中的hash表
  4. photoshop(ps) cs6中文版
  5. Python于*args 和**kwargs使用
  6. java继承与覆盖_简单的继承,方法重载与方法覆盖
  7. VB案例:打印输出图形与文本
  8. Leetcode每日一题:376.wiggle-subsequence(摆动的序列)
  9. 南瑞科技服务器型号,南瑞--NSC通讯概述
  10. python数据结构二叉树的查找算法_在路上---学习篇(一)Python 数据结构和算法 (5)二分查找、二叉树遍历...
  11. 华为天才少年年薪201万,作息时间表曝光:所有的逆袭,都是蓄谋已久
  12. key组合按键,长短按键,连续按键 识别方案
  13. Django中F对象,Q对象与运算符
  14. 关闭Linux防火墙
  15. 夏普给鸿海带来哪些改变?
  16. 写一个自己的前端手脚架(1)
  17. 华为mate20 pro Android,华为mate20和mate20pro区别 华为Mate20和Mate20pro对比
  18. mnist数据集常见格式.pkl.gz版本的下载与读取
  19. 在线旅游价格战升级 最高返现5成
  20. 查全国银行CNAPS CODE的地址

热门文章

  1. freeswitch部署及网关调试
  2. 华为一级产品线介绍(部分)
  3. pycharm查找替换快捷键
  4. “守法规知礼让、安全文明出行”背后需要良好的交通环境支撑 | 聚焦守法知礼...
  5. 慧据价值 链接未来丨第八届数据技术嘉年华大会全议程精彩呈现
  6. 16MnCr5齿轮钢板成分|性能|执行标准|淬火+回火|产地舞钢
  7. 大数据时代下的小公益
  8. CAD中插入外部参照字体会变繁体_为什么CAD插入外部参照时有些文字消失了?
  9. Android UI + Function
  10. safari支持Ajax同步请求吗,在同步“Ajax”请求之前强制在Webkit(Safari和Chrome)中重绘UI...