Repository navigation
Conversation
* For pacf with "method=ols", results differ quite a lot from
"method={yw, ld}" (biased and unbiased setting)
* Demeaning and minor changes in the OLS parameters improves the
result for smaller time series (emprirically evaluated)
* Added "unbiased" parameter for ols
* Added reference in docstring
|
Well, seeing travis' results, I haven't seen the tests in the first place. Let's discuss the suggested fix at first. |
|
I didn't think about the details yet. Where does the bias correction come from, is this in Box Jenkins. (I don't remember much about bias corrections for (auto-)correlation coefficients) Given the comments by Skipper and past changes, we might have to make this optional. AFAIR, Skipper had changed away from demeaning to match the Stata results. |
|
@nikhaas general question: We had a discussion many years ago, but I never saw much of a difference, with the exception that the existing ols version uses a different assumption on the mean. |
|
+1 for fixing this. That comment |
I think that comment refers to the initial version which, AFAIU, is the same as the version proposed here. |
I continue to offer positive reinforcement. |
|
About my motivation: I need I am particularly interested because
For the bias correction: Partial Autocorrelation is not so straightforward (and mainstream) as the ACF, and literature is more sparse. But for ACF, the denominator in the following formula is performing the bias correction: So all i did was "mimicking" this for PACF, and the results correspond to the unbiased and biased options (`method={"ld", "ldb"} ) This was a zero-shot, I don't know if this is true. But a changed denominator is often a consequence of unbiasing. All I did was following straightforward the proposal from the Box-Jenkins book:
I already spend a few hours on theoretical research, and I cannot spend more time on this. I neither have (full) access to the literature, so from a theoretical POV, this is the best I can propose. |
|
to make sure about the comparison with Stata, I checked a quick example We agree at floating point precision of OLS with Stata, This means
difference pacf_ols versus Stata (with added 1 at zero lag: This means it's not a BUG, adding more options would be an enhancement, which is no problem. |
|
Thanks for validating with a quick example. Is the
I managed to get access to Matlab and - surprisingly to me - their results coincide with the already implemented OLS results. It surprises me, because from my experience, the methods See the following plot (with my well-known AR process): Conclusion
|
|
Thanks for checking against matlab Now that the "correctness" issue is out of the way: I still like the proposed implementation, and "When in doubt, add options." is my favorite policy for this kind of decisions. There is a small sample bias in OLS for estimating coefficients for the lagged variables, I just don't remember a reference nor the details for the bias correction (and I thought I remember that the coefficient is downward and not upward biased). The nice feature of your bias correction, at least based on your plots, is that it prevents the higher lag pacf to increase. I have seen that problem before and seen it mentioned in some reference or blog, which can make pacf at higher lags misleading. It's also nice that OLS can replicate the other versions based on autocorrelation, acf. So, the two questions are
|
Can you explain this in more detail? I do not get what you want to say. In the end, I do not want to disimprove anything. What are the major differences to the prior OLS implementation:
How is this possible? Imho, the only robust suggestions that are left from the discussion are:
One last investigation: AR(1) and |
|
Maybe I misinterpreted some plots, and I need to go over it again when I'm less distracted. Aside: my coint csv file was the first time series file in my stata work directory that I found. Based on the file name, I think it is the write_csv of https://github.com/statsmodels/statsmodels/pull/3146/files#diff-8d4eb599f6121222f9a183e3a7205f9bR269 |
|
it Looks like this reached a concensus that the comment about the function being wrong is itself incorrect. Is this acccurate? |
|
There is nothing "incorrect". The current code corresponds to the intended definitions (which follow other packages). |
|
Woah there cowboy. Reflexive disagreement is a great heuristic, I get it, but I'm literally referring to a comment that says So yes. Something is incorrect. Either the code or the comment itself. Unless the comment is referring to itself and we've |
|
I was referring to code and definitions, not docs or code comments. It's and ENH issue and not a BUG issue. |
|
Right, and I was referring to the comment (the way you can tell is by reading what I wrote "that the comment about the function being wrong is itself incorrect") because someone might accidentally read it and get the wrong idea. If the function is correct, then this is anti-documentation. |
|
So... the conclusion here is that "X" and "not X" are not mutually exclusive, so all of ZFC needs to be scrapped? |
| res = OLS(x0[k:], xlags[k:, :k+1]).fit() | ||
| #np.take(xlags[k:], range(1,k+1)+[-1], | ||
| for k in range(1, nlags + 1): | ||
| res = OLS(x0, xlags[:, :k]).fit() |
There was a problem hiding this comment.
I like this PR but would make much more sense to avoid OLS and just call either pinv or lstsq directly . OLS computes a ton of stuff that isn't needed.
|
@nikhase needs rebase. |
|
see #3862 (comment) This PR cannot be merged because it changes the algorithm/definition and looses Stata (and matlab) and backwards compatibility, and it's not a BUG fix. |
Add option to use text book estiamtor closes statsmodels#3839 closes statsmodels#3862
Add option to use text book estiamtor closes statsmodels#3839 closes statsmodels#3862
Add option to use text book estiamtor closes statsmodels#3839 closes statsmodels#3862
Add option to use text book estiamtor closes statsmodels#3839 closes statsmodels#3862
|
@bashtage I see that you did pick the PACF up and brought it to a state that it might be ready to be merged. Sorry, I was away for some time and I felt that the issue was kinda dead in 2017. Can I do something to help you? |
|
I think it is good to go. Thanks.
…On Fri, Sep 21, 2018, 15:31 Niklas Haas ***@***.***> wrote:
@bashtage <https://github.com/bashtage> I see that you did pick the PACF
up and brought it to a state that it might be ready to be merged. Sorry, I
was away for some time and I felt that the issue was kinda dead in 2017.
Can I do something to help you?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#3862 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AFU5RQ6VO3FsGq5pWrbbRCahAhzHmz2dks5udPgkgaJpZM4OvlLO>
.
|
Add option to use text book estiamtor closes statsmodels#3839 closes statsmodels#3862




see #3839
For pacf with "method=ols", results differ quite a lot from
"method={yw, ld}" (biased and unbiased setting)
Demeaning and minor changes in the OLS parameters improves the
result for smaller time series (emprirically evaluated)
Added "unbiased" parameter for ols
Added reference in docstring