Repository navigation
ENH: Zivot-Andrews unit-root test (issue 4746) - #5455
JimVaranelli wants to merge 20 commits into
Conversation
|
Even after ensuring my fork was synced I still get this merge error. Very annoying. |
|
my guess is that you didn't branch off current master. (github doesn't show the parent of a branch or commit anymore.) BTW it is better to also add the topic to the branch name instead of just the issue number. That makes it easier to keep track of branches locally. |
|
Checking the history of this branch locally: |
|
OK I'll use the more informative branch name. I forced the most recent checkout of the two conflict files and merged in my changes and pushed the commit but I am still seeing the merge conflict. And the 'Resolve Conflicts' button just spins and never shows the conflict. |
|
To resolve the merge conflicts and update to current master we use rebase. We avoid merging master into a feature branch because it makes the commit history messy and more difficult to work with.
where |
|
Also we are not using |
|
OK I will change the @ back to dot. I rebased but it is still showing the conflict here??????? |
|
It looks like the merge conflict is finally fixed with the @/dot change. The issue most likely traces back to cloning the incorrect version of master (5/29/18 instead of 1/9/19). What is the correct command to use when cloning a new branch to ensure the most recent commits are included? |
|
Finally got a clean build. The appveyor failure appears to be unrelated to this PR. Let me know if there is anything further I should do. |
Codecov Report
@@ Coverage Diff @@
## master #5455 +/- ##
==========================================
+ Coverage 82.46% 82.49% +0.03%
==========================================
Files 595 595
Lines 93776 93894 +118
Branches 10353 10364 +11
==========================================
+ Hits 77333 77462 +129
+ Misses 14046 14031 -15
- Partials 2397 2401 +4
Continue to review full report at Codecov.
|
|
Hello @JimVaranelli! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found: There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻 Comment last updated at 2019-05-31 18:44:34 UTC |
|
Fixed the Codacy white space issue. Should have a clean merge now. |
|
this might still need a clean rebase on current master (with possibly some squashing) |
| self._za_critical_values['t'] = np.asarray(self._t) | ||
| # constant + trend model | ||
| self._ct = ((0.001, -38.17800), (0.100, -6.43107), (0.200, -6.07279), | ||
| (0.300, -5.95496), (0.400, -5.86254), (0.500, -5.77081), |
There was a problem hiding this comment.
check indentation. if you're not familiar with the convention, you can run flake8 --isolated statsmodels/tsa/stattools.py and ignore all the alerts for the rest of the module.
There was a problem hiding this comment.
are these actually needed as attributes of self?
If these attributes are identical across all instances and never edited, no need to bother with __init__, just put them as class attributes
There was a problem hiding this comment.
-
I fixed the indentation although there seems to be some ambiguity between the different style parsers. The form I used (which seems to be the most preferred) is:
list = (
(x1,y1), ...
(x2,y2), ...
) -
I originally used init for the CV list specifically in case there is ever a desire/need to split out the routine as a base class then inherit for different distributions. The question of class attribute vs object attribute is not too important here since the use model (in a single-threaded context) is to instantiate once then re-use the object for multiple runs as opposed to instantiating a new object for each run. I left it as is for now but can certainly update if there is a strong preference.
| cv = [1.0, 5.0, 10.0] | ||
| crit_value = np.interp(cv, y, x) | ||
| cvdict = {"1%" : crit_value[0], "5%" : crit_value[1], | ||
| "10%" : crit_value[2]} |
There was a problem hiding this comment.
no space before colon
are there other names besides x, y that might be more informative? one-letter names make it tough to search a file for all-places-this-is-used
There was a problem hiding this comment.
Fixed the colon spacing and renamed to (pcnts, stats) rather than (x, y).
| raise ValueError( | ||
| 'ZA: auxiliary exog matrix is not full rank.\n \ | ||
| cols (exc intercept) = {} rank = {}'.format( | ||
| exog.shape[1] - 1, o.df_model)) |
There was a problem hiding this comment.
using modern string formatting here is nice, can you do the same above?
Also can you avoid the backslash and instead put single-quotes on both lines
There was a problem hiding this comment.
Updated the other string formatting commands and removed the '' as above.
| 'ZA: trim value must be a float in range [0, 0.333]') | ||
| x = np.asarray(x) | ||
| if x.ndim > 2 or (x.ndim == 2 and x.shape[1] != 1): | ||
| raise ValueError( |
There was a problem hiding this comment.
quick tests for the failure modes?
There was a problem hiding this comment.
Added failure mode tests to test_stattools.py.
| exog[:, 1] = t_const[(baselags + 2):(nobs + 1)] | ||
| exog[:(cutoff-1), 2] = 0 | ||
| exog[(cutoff-1):, 2] = t_const[0:(nobs - bp + 1)] | ||
| # check exog rank on first iteration |
There was a problem hiding this comment.
this method is doing a lot. are there any reasonable sub-scopes it could be split into?
There was a problem hiding this comment.
Split off the endog/exog creation/updating into two separate helper functions.
| assert_almost_equal(res[0], -3.48223, decimal=3) | ||
| assert_almost_equal(res[1], 0.69111, decimal=3) | ||
| assert_equal(res[3], 25) | ||
| assert_equal(res[4], 7071) |
There was a problem hiding this comment.
these should probably be 5 separate tests in a test class
for scalars assert_equal(res[3], 25) can just be assert res[3] == 25
There was a problem hiding this comment.
Changed to a test class and switched to assert_allclose (see below).
| else: | ||
| res = zivot_andrews(mdl, regression='c', autolag='t-stat') | ||
| assert_almost_equal(res[0], -3.48223, decimal=3) | ||
| assert_almost_equal(res[1], 0.69111, decimal=3) |
There was a problem hiding this comment.
im pretty sure assert_allclose is preferred to assert_almost_equal
There was a problem hiding this comment.
Now using assert_allclose.
|
Looks like the merge should be OK now. Not sure why the Mac 2.7 pytest failed as the log was empty. I'll crank the rest of these out today. |
|
Fixed the Codacy whitespace issue. Very surprised the IDE didn't catch this one. |
Initial commit for Zivot-Andrews structural-break unit-root test (issue 4746).