首页 > 解决方案 > 如何从 Python 中的有序 logit 模型中检索残差?

问题描述

我已使用此代码在 Python 中运行有序的 logit:

import numpy as np
import pandas as pd
import scipy.stats as stats 
pip install git+https://github.com/statsmodels/statsmodels
from statsmodels.miscmodels.ordinal_model import OrderedModel

mod_log = OrderedModel(df_final5['ADJUST_5']
                       ,df_final5[['STRESS_2','ISO_4','ADJUST_1','WRKIND_1','HOMENV_3','WLBAL_1','WLBAL_2','ITSKIL_2','ORGCHAR_4','SUPP_1','INDGIVEN_1','DEMO_1','DEMO_3','GENWFH_2','GENWFH_3','FAM_2','ORGCHAR_2','ORGCHAR_3','GENDER','SWEXP','COMTYPE']]
                       ,distr='logit')

res_log = mod_log.fit(method='bfgs', disp=False)
print_logit = res_log.summary()
print(print_logit)

我现在正在努力从模型中检索残差。我尝试过使用与 OLS 相同的代码:

res=res_log.resid

但不幸的是,该模型没有 resid 属性。

你有解决办法吗?

标签: pythonstatistics

解决方案


推荐阅读