I want to use breusch_pagan test in statsmodels, but i facea strange error:
print(het_breuschpagan(resid=lr.resid,exog_het=df['iq']))
File "C:\Users\aleks\PycharmProjects\statistics\venv\lib\site-packages\statsmodels\stats\diagnostic.py", line 810, in het_breuschpagan
nobs, nvars = x.shape
ValueError: not enough values to unpack (expected 2, got 1)
linear model:
lr = sm.OLS.from_formula('lw80~age80+iq+school80+expr80',df).fit()
Dataset:
rns rns80 mrt mrt80 smsa ... expr80 tenure tenure80 lw lw80
0 no no no yes yes ... 10.635 0 2 5.900 6.645
1 no no no yes yes ... 11.367 2 16 5.438 6.694
2 no no no yes yes ... 11.035 1 9 5.710 6.715
3 no no no yes yes ... 13.089 1 7 5.481 6.477
4 no no yes yes yes ... 14.402 3 5 5.927 6.332
I would like to test wether there is a heteroskadicity assuming that the variable leading to heteroskadicity is iq and only iq, but I don't know what parameters to use so that there are no errors
The bresuschpagan implementation in statsmodel compares the residuals to the X dataset used in your ols regression, so that would be
het_breuschpagan(resid=lr.resid, exog_het=df[['age80','iq','school80','expr80']])
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.