使用Statsmodels的McNemar测试和python输入类型错误

时间:2019-03-19 19:32:32

标签: python-3.x statistics statsmodels

我试图用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''
'''

0 个答案:

没有答案