McNemar test麦克尼马尔检验


 python金融风控评分卡模型和数据分析微专业课(博主亲自录制视频):http://dwz.date/b9vv

模型项目统计联系QQ:231469242

McNemar’s Test用于配对的2*2表格,例如如果你要比较两个医生对同一个病人治疗效果。一个病人自控,药物治疗前和治疗后结果比较。

McNemar’s Test用于检验(a+b)/N 和(a+c/N)是否显著?

McNemar’s Test的两个分类变量不是独立的,而是相关的,因为(a+b)/N 和(a+c/N)都包含a

McNemar’s Test This is a matched pair test for 2  *   2 tables. For example,
if you want to see if two doctors obtain comparable results
when checking (the same) patients, you would use this test.

 

 

 

 

 

http://www.doc88.com/p-7337013497692.html

 

 

 

 

 

 

 

 

 python代码测试一致

 

# -*- coding: utf-8 -*-
'''
QQ:231469242,by Toby
''' # Import standard packages import numpy as np import scipy.stats as stats import pandas as pd # additional packages from statsmodels.sandbox.stats.runs import cochrans_q, mcnemar #药物测试,对疾病是否治愈,要求相同对象群体 #obs = np.array([[101, 121],[59, 33]]) obs = np.array([[2, 4],[0, 4]]) def Mcnemar(obs): '''McNemars Test should be run in the "exact" version, even though approximate formulas are typically given in the lecture scripts. Just ignore the statistic that is returned, because it is different for the two options. In the following example, a researcher attempts to determine if a drug has an effect on a particular disease. Counts of individuals are given in the table, with the diagnosis (disease: present or absent) before treatment given in the rows, and the diagnosis after treatment in the columns. The test requires the same subjects to be included in the before-and-after measurements (matched pairs). ''' (statistic, pVal) = mcnemar(obs) print('\nMCNEMAR\'S TEST -----------------------------------------------------') print('p = {0:5.3f}'.format(pVal)) if pVal < 0.05: print("There was a significant change") else: print("There was no significant change") Mcnemar(obs) ''' p = 0.125 There was no significant change '''

 

 

 

 

例题2

 

python结果无显著差异

 

 

例题3

 

 

 

 

 

练习

 

 

 python机器学习生物信息学系列课(博主录制):http://dwz.date/b9vw

 

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM