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