GLSAR incorrect initial condition in whiten

Bug #434420 reported by joep
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
statsmodels
New
Undecided
Unassigned

Bug Description

I started to verify GLSAR against a matlab implementation, and found
that the initial observations are not dropped from wexog and wendog
during whitening.

Shortening the arrays during whitening also will require a
redefinition of self.nobs, which is currently done in the top level
class Model. Is there any reason not to move this assignment down into
GLS ? What's the effect on GLM or RLM?
In GLS self.nobs could be taken from the whitened arrays, similar to
the way in class RegressionResults.

The alternative, that I have used in some other code is that the
superclass checks before an assignment whether the attribute has
already be assigned by the subclass.

e.g. in Model
if not hasattr(self, 'nobs'):
   self.nobs = float(self.endog.shape[0])

(written from memory, not tested for syntax errors)
This could also be used for other cases where a subclass needs to
overwrite some initial attribute assignment, e.g. for the degrees of
freedom.

I tried it but this doesn't work in this case because wendog is not known yet in __init__ of GLS class.
In my current fix, I overwrite self.nobs in initialize.

Never trust any code that hasn't been tested.
GLSAR looked good in the examples that I looked at before, but I used only statistical comparisons with large nobs, in that case initial conditions have only a small impact.

I have a correction that reproduces the comparison results for given rho (checked for params, bse and tstatistic), but convergence in iterative_fit is not completely the same. Difference in 3rd decimal. Need to check some more but will commit tomorrow.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.