我试图用StatsModels在Python中运行McNemar的测试,但是我遇到了不同类型的类型错误。尝试了文档和在线示例,但没有帮助。
import pandas as pd
from statsmodels.stats.contingency_tables import mcnemar
contingency_table_hosp_allCauseHRU_v1 = [ [420, 525],
[113, 133]]
contingency_table_hosp_allCauseHRU = {'AllCausePreIndex':[420, 113], 'AllCausePostIndex':[525, 133]}
contingency_table_hosp_allCauseHRU_v2 = pd.DataFrame(data=contingency_table_hosp_allCauseHRU)
stat, p = mcnemar(contingency_table_hosp_allCauseHRU_v2, exact=False, correction=True)
'''Errors:
with contingency_table_hosp_allCausHRU_v1 as parameter -> 'TypeError: '_Bunch' object is not iterable'
with contingency_table_hosp_allCauseHRU_v2 as parameter -> 'TypeError: '<' not supported between instances of 'str' and 'int''
'''