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

Granger cleanup and nobs check #1018

Closed

Conversation

guyrt
Copy link
Contributor

@guyrt guyrt commented Aug 2, 2013

Addresses issue #347.

I've included two tests. First is a restriction on the number of observations required for a given max lag.

Second is a test that catches co-linearity between two time series. For now, this actually raises a ValueError. I did this because I was already getting an error and this one is much cleaner. Suggestions welcome.

@josef-pkt
Copy link
Member

From a quick read-through the caching of condno and eigenvalues looks fine.
maybe verbose condition_number given that it will be a public attribute

Second is a test that catches co-linearity between two time series. For now, this actually raises a ValueError. I did this because I was already getting an error and this one is much cleaner. Suggestions welcome.

What error did you get here?

My "impression": multicollinearity (even perfect) within a time series is irrelevant for the hypothesis test, because we are not testing individual coefficients, but a joint hypothesis for a group of coefficients.
Maybe there will be some differences across test in this case, but I doubt that it will be the case.

@guyrt
Copy link
Contributor Author

guyrt commented Aug 6, 2013

@josef-pkt You are correct. I kept the caching in the OLS results because it clears a few TODOs in the code, but I removed a check I had placed in the granger section. Happy to split this into to PRs if you prefer.

@guyrt
Copy link
Contributor Author

guyrt commented Sep 23, 2013

@josef-pkt This should be ready to go.

@coveralls
Copy link

Coverage Status

Coverage remained the same when pulling 4e0c77c on guyrt:granger-cleanup-and-nobs-check into 16365ed on statsmodels:master.

@@ -464,12 +462,12 @@ def pacf_yw(x, nlags=40, method='unbiased'):
This solves yule_walker for each desired lag and contains
currently duplicate calculations.
'''
xm = x - x.mean()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks like a bug not cleanup #1039

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

xm is never used below. Maybe a typo / copy-paste-o.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, I'm pretty sure that the call to yule_walker should use xm and not x.
(But I just did a quick check with pdb in nosetests and didn't look at all the details yet. It doesn't look like x is demeaned before calling pacf_yw.)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

False alarm here, I closed #1039 again, we have unittests and yule_walker demeans by default.
removing this line is good, and it won't get me confused next time

@guyrt
Copy link
Contributor Author

guyrt commented Oct 24, 2013

This is now rebased on master.

@coveralls
Copy link

Coverage Status

Coverage remained the same when pulling d058613 on guyrt:granger-cleanup-and-nobs-check into 1bc6576 on statsmodels:master.


# create lagmat of both time series
dta = lagmat2ds(x, mxlg, trim='both', dropex=1)

#add constant
if addconst:
dtaown = add_constant(dta[:,1:mxlg+1], prepend=False)
dtajoint = add_constant(dta[:,1:], prepend=False)
dtaown = add_constant(dta[:, 1:mxlg+1], prepend=False)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the rule now also says spaces around operators in slices

I think it's [:, 1 : mxlg + 1] what we started to use. (pep-8 now says not spaces around the innermost operator, but we don't adjust for that, except **)

@josef-pkt
Copy link
Member

Thanks, looks good and it's a clean rebase.

cosmetic comments to cosmetic changes

@josef-pkt
Copy link
Member

after the rebase the second commit message "ENH: Added condno and eigenvalue caches to OLS and Quantile regression " is now inappropriate. maybe an interactive rebase to edit the commit message to STY ...

In general, we try not to make style/pep-8 changes and substantial changes in the same commit. It's difficult to quickly see what the relevant change is in the commit. (for the future)

@josef-pkt josef-pkt closed this in 01fd4a2 Dec 19, 2013
@josef-pkt
Copy link
Member

@guyrt Thank you, merged after interactive rebase

There has been unfortunately some delay, given the confusion about what to do with the commits for 0.5.1
During the interactive rebase (edit and squash), I accidentally changed the author in the second commit. Sorry about that.

In the description you mention checking for collinearity, but I didn't see any code related to that. Was there some in an earlier version?

PierreBdR pushed a commit to PierreBdR/statsmodels that referenced this pull request Sep 2, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants