Repository navigation
Description
Good news. We're almost done with the "what was the intention here?" issues. A little over half of whats left are in results_arma or results_arima.
results_arima: it looks like maybe older results came from a different package and were commented out (instead of deleted) for [some reason?]. I don't see any indication of why these are still useful, or why they one set of results is preferred over the other.
https://github.com/statsmodels/statsmodels/blob/master/statsmodels/tsa/tests/results/results_arima.py#L430
https://github.com/statsmodels/statsmodels/blob/master/statsmodels/tsa/tests/results/results_arima.py#L332
https://github.com/statsmodels/statsmodels/blob/master/statsmodels/tsa/tests/results/results_arima.py#L212
https://github.com/statsmodels/statsmodels/blob/master/statsmodels/tsa/tests/results/results_arima.py#L91
https://github.com/statsmodels/statsmodels/blob/master/statsmodels/tsa/tests/results/results_arima.py#L58
https://github.com/statsmodels/statsmodels/blob/master/statsmodels/tsa/tests/results/results_arima.py#L46
results_arma: pretty much the same deal, but with less readable formatting.
https://github.com/statsmodels/statsmodels/blob/master/statsmodels/tsa/tests/results/results_arma.py#L731
https://github.com/statsmodels/statsmodels/blob/master/statsmodels/tsa/tests/results/results_arma.py#L721
https://github.com/statsmodels/statsmodels/blob/master/statsmodels/tsa/tests/results/results_arma.py#L687
https://github.com/statsmodels/statsmodels/blob/master/statsmodels/tsa/tests/results/results_arma.py#L678
https://github.com/statsmodels/statsmodels/blob/master/statsmodels/tsa/tests/results/results_arma.py#L670
https://github.com/statsmodels/statsmodels/blob/master/statsmodels/tsa/tests/results/results_arma.py#L659
https://github.com/statsmodels/statsmodels/blob/master/statsmodels/tsa/tests/results/results_arma.py#L610
https://github.com/statsmodels/statsmodels/blob/master/statsmodels/tsa/tests/results/results_arma.py#L596
https://github.com/statsmodels/statsmodels/blob/master/statsmodels/tsa/tests/results/results_arma.py#L548
https://github.com/statsmodels/statsmodels/blob/master/statsmodels/tsa/tests/results/results_arma.py#L478
https://github.com/statsmodels/statsmodels/blob/master/statsmodels/tsa/tests/results/results_arma.py#L410
https://github.com/statsmodels/statsmodels/blob/master/statsmodels/tsa/tests/results/results_arma.py#L358
https://github.com/statsmodels/statsmodels/blob/master/statsmodels/tsa/tests/results/results_arma.py#L315
https://github.com/statsmodels/statsmodels/blob/master/statsmodels/tsa/tests/results/results_arma.py#L257
https://github.com/statsmodels/statsmodels/blob/master/statsmodels/tsa/tests/results/results_arma.py#L202
https://github.com/statsmodels/statsmodels/blob/master/statsmodels/tsa/tests/results/results_arma.py#L138
https://github.com/statsmodels/statsmodels/blob/master/statsmodels/tsa/tests/results/results_arma.py#L75
Activity
josef-pkt commentedon Mar 18, 2018
I only spot checked a few.
In general those comments or commented out results represent a large amount of work. I don't know about the specific case in here, but for other cases outside of tsa that I know better, it took some time to figure out how results and definitions differ across packages and which ones we replicate and which ones we don't.
E.g. there are several possibilities for cov_params (one comment mentions OPG instead of hessian, which is now an option in SARIMAX) and many packages drop constant terms from llf/aic/...
Those comments are in general helpful as documentation across packages and for debugging. They are not really necessary for the unit tests, but it's a good location for storing those (easy to find for debugging).
There might be some obsolete comments or comparison numbers, but for a maintainer it's better to keep them than to throw out the good with the bad.
(Two unrelated examples:
GLM negative binomial follows R for dispersion which I didn't know and wouldn't have used if I had written that part.
GLM aic/bic have inconsistent definitions that I don't like but those were written following the definitions in Stata. Comments in unit tests are very helpful for those kind of cases.)
jbrockmendel commentedon Mar 18, 2018
I'll see if these answers can help me fix any of them, follow up with remaining in smaller pieces.
The parts that are comments serve as documentation. The parts that are commented-out code are like anti-documentation. At best they are useful for one reader: you.
For e.g https://github.com/statsmodels/statsmodels/blob/master/statsmodels/tsa/tests/results/results_arima.py#L430
This could be made useful if proceeded by a comment to the effect of
# The following results for tvalues, pvalues, cov_params, and bse are based on results from [...]. We do not use them because of [...], but they are retained for reference.Without something like that, this is worse-than-useless to a reader.josef-pkt commentedon Mar 18, 2018
Note, the
elsestarts withand the later part switches to Gretl
This is not for "casual" readers who might find it useless.
I am also an outsider for this code, but both comments and code comments with reference numbers would give me a huge head (
*) start if I had or have to debug something in here, or have to answer a question about why statsmodels doesn't replicate xxx.(
*) getting a head start doesn't mean that it provides a full answer, but unit test writers don't have the time to write an article about comparing packages.If I were the only debugger, then it still would be useful to keep those. But my guess is that it is useful for anyone who has to figure out what's going on.
Commented out reference numbers are also useful to see the original numbers if they have been fixed in the mean time in the comparison package.
jbrockmendel commentedon Mar 19, 2018
It is not clear to me what parts of the code the gretl comment refers to. "Everything from here on down" is a reasonable guess, but so is "from here until the next line break"
Right. In this case I am the reader, and I'm asking you to take my word for it when I say that I find these unhelpful. But we're getting closer to fleshing them out into something useful.
There's also a Bayesian aspect to this. There's a ton of code that is commented out without a clear reason, e.g. in nearly every
summarymethod. Or even code that explicitly tells the reader to get rid of it (#4358, orsandbox.panel.sandwich_covariance). "This is here because someone refuses to hit delete" is a reasonable hypothesis.jbrockmendel commentedon Mar 19, 2018
So in results_arma, there are a bunch of comments "# Note bse, cov_params, and t are from R", and then there are commented-out versions of each of those three variables next to non-commented-out versions. Is the implication that a) everything other than those three variables is from some other package and b) the commented-out versions are from that same other package?
josef-pkt commentedon Mar 19, 2018
to the last comment:
Yes, that's what I think it is. In some cases Skipper stitched together results from several packages that match our results, Other packages might not have the results available or use a different definition.
If I have to debug in this, then one of the first things I would do is to try to replicate the results in Stata, R and Gretl. (I'm currently more familiar and faster with Stata, than R and Gretl.)
If this information is not available, then I would have to try "blind", reading documentation, articles or books and figuring out what's going on from scratch.
(It's partially an attitude question: I have been debugging python statistics code for almost 10 years, mostly code written by other developers and also my own code written years ago. I prefer to figure out what the intention and reasons of the original author were before making "arbitrary" changes. Some developers rewrite from scratch which in my experience requires more work, knowledge and decisions than fixing existing code even if writing a new version is more "fun".)
(another aside: In the sandwiches I intentionally didn't follow Stata's small sample corrections. The only place where I can find the details for the differences between Stata and statsmodels is in the unit tests, mostly in the
corr_fact.)That's partially my pattern. The main problem or issue is "When in doubt whether information will still be useful, then err on not deleting it".
This is also a question on code stability:
If the code is stable, i.e. we don't expect any changes anymore, then we only need minimal maintainer documentation and the rest can go into git history. If we expect that code will still need bug-fixes, refactorings and enhancements, then hints hiding in dirty comments are still useful.
Furthermore, if we deprecate AR(I)MA in favor of SARIMAX, then these parts can go into the git history.