Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GLSAR incorrect initial condition in whiten #62

Closed
wesm opened this issue Aug 25, 2011 · 3 comments

Comments

Projects
None yet
3 participants
@wesm
Copy link
Member

commented Aug 25, 2011

Original Launchpad bug 434420: https://bugs.launchpad.net/statsmodels/+bug/434420
Reported by: josef-pktd (joep).

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.

@josef-pkt

This comment has been minimized.

Copy link
Member

commented Oct 6, 2011

Not sure what's the status on this, but GLSAR needs a general checkup

@jseabold

This comment has been minimized.

Copy link
Member

commented Oct 28, 2012

Removed the 0.4 milestone from this.

@josef-pkt

This comment has been minimized.

Copy link
Member

commented Aug 15, 2013

this was fixed, I think with PR #293
has tests against Stata
some review/refactoring issues for GLSAR are still open

@josef-pkt josef-pkt closed this Aug 15, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.