Repository navigation
Conversation
Started Exponential Model off of code from dfrusdn and heavily modified. Handles 15 different models.
|
Thanks @ccsv and thanks @dfrusdn for getting this started. I'm not very familiar with the details of exponential smoothing and how it is used. For the user interface, we will need to look at some other packages, for example Hyndman's, to see what would be a good design and required results. We should also get much of the data and date handling from the current tsa classes. It's still missing unittests, some of the examples could be converted into unit tests. I don't know what is usually done to estimate the smoothing parameters. However, what I think is very good about the current PR is that it isolates the smoothing filter. I think we should keep it that way and it should be and can be easily converted to a cython module, after the initial open question have been resolved. (It will be slow as python loop for any longer time series.) great work on docstrings. |
|
For the initial values with single exponential smoothing, Minitab uses the simple average of the first |
There was a problem hiding this comment.
Could you remove these blank lines between the different parameters in the docs? I think it'll make it easier to read at the console.
There was a problem hiding this comment.
You just don't need the blank lines in the parameter section between the parameters. E.g.,
y : array
Time series data
alpha : float
Smoothing factor for data.
|
@TomAugspurger initializing data starts around 157 to 200 or search for the comment @josef-pkt is there a specific way to do the summary? I know there are summary formats in other models. I found mostly what I need in |
remove lines some style
|
@jseabold Done. But it is not all Pep8 because I am not familiar. Also if anyone can vectorize the |
|
Yeah, that doesn't look good. Especially with the if/else statements within the for loop. |
|
@jseabold I have not been programming very long so I am having a hard time fixing that problem |
|
Sure, no problem. Will see if we can have a look at it and work through it. |
|
Just added everyone as collaborators. So you can make minor edits (grammar/syntax) or whatever helps |
|
@ccsv I agree with Tom the |
Changed title for cython move recommended by josef
I don't think there is any way to vectorize this type of iterative/recursive loops, and scipy.signal doesn't have any precompiled code for this case. That's why I think we have to go to cython for it. |
|
Stata doesn't seem to provide much http://www.stata.com/manuals13/tstssmoothexponential.pdf |
|
http://cran.ms.unimelb.edu.au/web/packages/forecast/forecast.pdf description of |
There was a problem hiding this comment.
need full references, authors, ...
|
@josef-pkt I looked at most of the equations and they seem to match the dampened season models from Exponential smoothing: The state of the art Part II. on p. 8 http://www.bauer.uh.edu/gardner/Exponential-Smoothing.pdf From what I saw I am pretty sure they are just the different dampened models with season and trend components. Minimizing MSE usually how the methods are chosen. But I read that some articles using MMSE as a better alternative because MSE does not do a good job on seasons. In literature there are multiple books and articles that give different initial values such as mean of first 3 numbers (NIST.gov) or an average of all the data. |
added authors per josef
|
Went ahead and made josef's edits @josef-pkt Found a place to run exponential smoothing R code but I don't know if it is accurate or what is used for the start values From those loops I saw notice that parts such as |
|
The way I see it after browsing a bit some references and Hyndman's blog. The main parts besides adding unit tests for the smoother is to start a Model and Results classes to get Hyndman mentions that the parameters should be constraint to [0.1, 0.9] to impose stability on the system. He also mentions the possibility of local minima, which we could try to work around by scipy's basinhoppin which is already connected to LikelihoodModel.fit and will come for "free". Since this is mainly used for forecasting and not for analysing effects and parameter estimates, we will need to got My impression is that we should target Hyndman's We will need a reasonably long seasonal dataset for the unit tests (a few hundred observations) to reduce the effect of differences in initial conditions on the results. http://robjhyndman.com/hyndsight/estimation/ (That's how I see it, but I need to go back to other work and won't have time to read the 5 or 10 articles that I downloaded to understand the details. It will be great to get more contributors and reviewers for statsmodels.tsa, since this is one of our popular parts and relies currently mainly on Skipper's work.) |
|
On Sun, Jan 5, 2014 at 9:03 AM, Josef Perktold [email protected]:
The seasonal plotting PR I just made includes (in the main script) the co2 I think we can also include it, but I haven't checked for license yet. |
|
Is this still being worked on? If so, it needs some tests. If tests aren't forthcoming, at the least it would be great to see some comparisons to working code in another package for a comparison. R or Stata preferred but really whatever. |
There was a problem hiding this comment.
Why does this use future values of y. Every reference I think this should be y[i] unless this is doing something I haven't seen.
There was a problem hiding this comment.
I think I see the alignment intentions here, but this doesn't work as is AFAICT.
|
Ok, I'm cleaning this up and correcting and writing tests (fun!). Will submit a PR soon I hope. Pushing parts to Cython might have to wait, though I've abstracted it so that it will be trivial to do so. |
There was a problem hiding this comment.
@ccsv It's unclear to me what you're doing here. Do you have an exact reference for this, or can you explain in words?
It looks like you normalize the data in one period by the mean of each period. E.g., for monthly data year one is normalized by the mean for that whole year (axis 1 mean). Then you take the period averages (axis 0) mean. I'm curious about this. Division vs. subtraction corrections for the assumed type of cycle.
There was a problem hiding this comment.
It looks like this might be from wikipedia via NIST. I find many different recommendations for this in the literature, so we'll see what looks 'best.'
|
I'm closing this in favor of #1489. If you come back to work on this, please just push any changes here. I'm not even sure how to replicate some of these models in R. E.g., |
Started Exponential Model off of code from dfrusdn and heavily modified. Handles 15 different models. The code is also fully documented. It looked like this was in demand so I tried out my coding skills.
This handles ALL of the following models:
Simple Exponential Smoothing(SES)
Simple Seasonal models (both multiplicative and additive)
Brown's Linear Exponential Smoothing
Holt's Double Exponential Smoothing
Exponential trend method
Damped-Trend Linear Exponential Smoothing
Multiplicative damped trend (Taylor 2003)
Holt-Winters Exponential Smoothing: multiplicative trend, additive trend, multiplicative season, additive season and damped models for all four variations
The code is accurate just that the initial values are off so they have to be adjusted. All the equations match what is given by Exponential smoothing: The state of the Art II page 8.
I do not know what methods are used to backcast the function so I left two Nans in the beginning to align the data. There is also a todo list.
I am not a programmer and I just did python for about 3 months so I need a code check. I think this should be in a class but I have not dealt with them enough to know what I am doing.
Testing: Go to the line 308 to 320 and remove the double pound signs for debug
it matches the data in blue from http://analysights.wordpress.com/2010/05/20/forecast-friday-topic-double-exponential-smoothing/
For forecasting 3 periods ahead