-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
need help to clarify ewma() using adjust =TRUE #8861
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
Comments
cc @seth-p |
I never liked the term "adjustment" -- which predates me. Suppose you had a series with an infinite history:
(since the denominator is equal to Now it's pretty easy to see that the
So far so good. Now in reality of course we do not have series with infinite histories. So how do we define the exponentially weighted averages for finite series? There are (at least) two plausible definitions: The first option, which in Pandas is specified using
The second option, which in Pandas is specified using
These two methods will in general produce different results (though the difference will decrease the farther out one goes). Personally I find Other than the unfortunate choice of the parameter name I am not familiar with "adaptive-repose single exponential smoothing", but suspect that that is something different. |
Thank you very much for your effort in explaining this into details! It is now much more clear to me! |
@seth-p if you'd like to do a PR to add this somewhere in the docs....... |
I'd go even further and say that the unadjusted formula is not only less intuitive, but incorrect for finite series. In order to use it you have to assume that "weight" series is already infinite-ish and the first element is not an ordinary value, but rather a prior knowledge of the whole infinite-ish series. Intuitively this gives the first value much more weight and that corresponds to the maths. This is a valid scenario, for example, when you're calculating ewma for some time series data period-by-period and you are rolling over to the next period. This is when you'd prepend the weighted last element to the next period series changing it from
to
and use the "unadjusted" formula. Maybe the kwarg could be renamed to "assume_infinite_history" or something alike. Or, going more radical, maybe we could use replace it with |
DOC: added exp weighting clarifications from #8861
This was closed by #11361 |
Lucky to find this answer after 10 years! Could some nice guy also explain |
Hi!
Can someone please help me understand how


adjust = True
in the functionewma()
works mathematically?I understand the idea of simple exponential smoothing and it's basic formula when
adjust = FALSE
,then alpha is constant, as in the equation:
When
adjusted = True
then I assume that, alpha does not stay constant and it is adjusted "automatically".But what is the mathematical representaiton for such case? I've looked into Pandas documentationhttp://pandas.pydata.org/pandas-docs/stable/computation.html#exponentially-weighted-moment-functions
and there it says that when it is adjusted, then the function uses this weights:
It is still not clear to me how this adjustment is working.
The only simple exponential method using an adaptive/adjusting alpha that I know of, is from Rob Hyndman's book: "Forecasting Methods and Application" .There I found a variation of the simple exponential smoothing (p.155-157), where alpha is adjusted automatically, called "adaptive-respose single exponential smoothing" (ARRSES). Unfortunately I got different results from each, so I guess this is not the one.
Does anybody know how to explain this specific case mathematically? or knows a good reference?
Thanks!
The text was updated successfully, but these errors were encountered: