sklearn实战-乳腺癌细胞数据挖掘(博主亲自录视频)
https://study.163.com/course/introduction.htm?courseId=1005269003&utm_campaign=commission&utm_source=cp-400000000398149&utm_medium=share
医药项目统计联系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
练习