'IV2SLS' 对象没有属性 'pinv_wexog'
'IV2SLS' object has no attribute 'pinv_wexog'
我从 statsmodels.sandbox.regression.gmm、
导入 IV2SLS
但是没能做到异方差鲁棒协方差
from statsmodels.sandbox.regression.gmm import IV2SLS
endog = cig_1995['lpackpc']
exog = cig_1995[['constant', 'lravgprs']]
instrument = cig_1995[['constant', 'rtaxso']]
results = IV2SLS(endog=endog,exog=exog,instrument=instrument).fit()
results = results.get_robustcov_results(cov_type='HC1')
AttributeError: 'IV2SLS' object has no attribute 'pinv_wexog'
您可以使用 linearmodels
包,其中包含 IV2SLS
. The syntax is nearly the same as that incomplete version in statsmodels
. The only difference is how you specify the covariance estimator, which is part of fit
.
的有效且经过测试的实现
from linearmodels import IV2SLS
endog = cig_1995['lpackpc']
exog = cig_1995[['constant', 'lravgprs']]
instrument = cig_1995[['constant', 'rtaxso']]
results = IV2SLS(endog=endog,exog=exog,instrument=instrument).fit(cov_type="robust")
我从 statsmodels.sandbox.regression.gmm、
导入 IV2SLS但是没能做到异方差鲁棒协方差
from statsmodels.sandbox.regression.gmm import IV2SLS
endog = cig_1995['lpackpc']
exog = cig_1995[['constant', 'lravgprs']]
instrument = cig_1995[['constant', 'rtaxso']]
results = IV2SLS(endog=endog,exog=exog,instrument=instrument).fit()
results = results.get_robustcov_results(cov_type='HC1')
AttributeError: 'IV2SLS' object has no attribute 'pinv_wexog'
您可以使用 linearmodels
包,其中包含 IV2SLS
. The syntax is nearly the same as that incomplete version in statsmodels
. The only difference is how you specify the covariance estimator, which is part of fit
.
from linearmodels import IV2SLS
endog = cig_1995['lpackpc']
exog = cig_1995[['constant', 'lravgprs']]
instrument = cig_1995[['constant', 'rtaxso']]
results = IV2SLS(endog=endog,exog=exog,instrument=instrument).fit(cov_type="robust")