Pregunta

I've successfully run statsmodels.WLS(Y, X, weights=1/cov), where cov is a vector of squared standard errors of the observations, matching the shape of the endogenous/response variable/regressand (Y).

What I want from the results is the sigma zero value, which is the square root of (v^TWv/degrees of freedom), where v is the residuals vector, and W is the Weight matrix, but I have no idea how to get it, and the docs aren't helping me much, presumably because of the different terminology. What should I be looking for in the results object?

I know the value's in there, because results.bse gives me correct standard errors for the parameter estimates, which can't be obtained without sigma zero.

¿Fue útil?

Solución

The weighted residual variance is available as attribute of the results instance, scale and mse_resid. see http://statsmodels.sourceforge.net/devel/generated/statsmodels.regression.linear_model.RegressionResults.html

>>> resw.scale
0.99139414802065384
>>> resw.mse_resid
0.99139414802065384

>>> np.dot(resw.wresid, resw.wresid) / resw.df_resid
0.99139414802065384

>>> (resw.resid * resw.model.weights * res.resid).sum() / resw.df_resid
0.99139414802065395

You need to take the sqrt if you want the standard deviation.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top