def het_breuschpagan(resid, exog_het):
 x = np.asarray(exog_het)
 y = (np.asarray(resid) ** 2)
 (nobs, nvars) = x.shape
 resols = OLS(y, x).fit()
 fval = resols.fvalue
 fpval = resols.f_pvalue
 lm = (nobs * resols.rsquared)
 return (lm, stats.chi2.sf(lm, (nvars - 1)), fval, fpval)

def het_breuschpagan ( resid , exog_het ) : x = np . asarray ( exog_het ) y = ( np . asarray ( resid ) ** 2 ) ( nobs , nvars ) = x . shape resols = OLS ( y , x ) . fit ( ) fval = resols . fvalue fpval = resols . f_pvalue lm = ( nobs * resols . rsquared ) return ( lm , stats . chi2 . sf ( lm , ( nvars - 1 ) ) , fval , fpval )
breusch-pagan lagrange multiplier test for heteroscedasticity the tests the hypothesis that the residual variance does not depend on the variables in x in the form :math: sigma_i = sigma * f homoscedasticity implies that $alpha=0$ parameters resid : arraylike .