6.7.6.3.2. statsmodels.sandbox.regression.onewaygls.OneWayLS

class statsmodels.sandbox.regression.onewaygls.OneWayLS(y, x, groups=None, het=False, data=None, meta=None)[source]

Class to test equality of regression coefficients across groups

This class performs tests whether the linear regression coefficients are the same across pre-specified groups. This can be used to test for structural breaks at given change points, or for ANOVA style analysis of differences in the effect of explanatory variables across groups.

Notes

The test is implemented by regression on the original pooled exogenous variables and on group dummies times the exogenous regressors.

y_i = X_i beta_i + u_i for all groups i

The test is for the null hypothesis: beta_i = beta for all i against the alternative that at least one beta_i is different.

By default it is assumed that all u_i have the same variance. If the keyword option het is True, then it is assumed that the variance is group specific. This uses WLS with weights given by the standard errors from separate regressions for each group. Note: het=True is not sufficiently tested

The F-test assumes that the errors are normally distributed.

original question from mailing list for equality of coefficients across regressions, and example in Stata FAQ

testing:

  • if constant is the only regressor then the result for the F-test is the same as scipy.stats.f_oneway (which in turn is verified against NIST for not badly scaled problems)
  • f-test for simple structural break is the same as in original script
  • power and size of test look ok in examples
  • not checked/verified for heteroscedastic case - for constant only: ftest result is the same with WLS as with OLS - check?
check: I might be mixing up group names (unique)
and group id (integers in arange(ngroups) not tested for groups that are not arange(ngroups) make sure groupnames are always consistently sorted/ordered Fixed for getting the results, but groups are not printed yet, still inconsistent use for summaries of results.
__init__(y, x, groups=None, het=False, data=None, meta=None)[source]

6.7.6.3.2.1. Methods

__init__(y, x[, groups, het, data, meta])
fitbygroups() Fit OLS regression for each group separately.
fitjoint() fit a joint fixed effects model to all observations
fitpooled() fit the pooled model, which assumes there are no differences across groups
ftest_summary() run all ftests on the joint model
lr_test() generic likelihood ration test between nested models
print_summary(res) printable string of summary