[R] Time series forecasting

Stephan Kolassa Stephan.Kolassa at gmx.de
Sun Apr 5 18:59:23 CEST 2009


Hi Perry,

my impression after a very cursory glance: this looks like noise. 
Perhaps you should think a little more about your series - what kind of 
seasonality there could be (is this weekly data? or monthly?), whether 
the peaks and troughs could be due to some kind of external driver, 
whether you really have count data, that kind of thing.

Until then, there is little else to do than to use a very simple method, 
e.g. forecast the last observation (random walk) or the mean of the 
observations (white noise), or the median. All of these "benchmarks" can 
be surprisingly hard to beat.

If you have seasonality but no external influence, you could look at 
smoothing methods, they are nice to interpret and usually perform very 
well. I'd recommend Hyndman et al., "Forecasting with Exponential 
Smoothing: The State Space Approach" and the accompanying forecast R 
package, mainly with the ets() function.

You could also look at arima(). I fitted an ARIMA model to your data, 
and as expected, it returned a simple mean (not that I would recommend 
blindly fitting ARIMA to just any data):

Call:
arima(x = foo[, 2])

Coefficients:
       intercept
          7.2333
s.e.     0.8009

sigma^2 estimated as 19.25:  log likelihood = -86.93,  aic = 177.85

And for count data, you could use some variants of ARIMA, e.g., INAR.

HTH,
Stephan


pgary at gol.com schrieb:
> Dear all:
> 
> I'm a newbie and an amateur seeking help with forecasting the next in a non-stationary time series, with constraints of 1 (low) and 27 (high) applicable to all. 
> 
> What I need help with is the solution concept. The series has 439 observations as of last week. I'd like to analyze obs 1 - 30 (which are historical and therefore invariate), to solve for 31.
> 
> The history:
> Obs 1        2
> 2                1
> 3                1
> 4                16
> 5                9
> 6                6
> 7                7
> 8                11
> 9                11
>  10                1
> 11                12
> 12                14
> 13                13
> 14                2
> 15                4
> 16                5
> 17                14
> 18                6
> 19                4
> 20                7
> 21                5
> 22                8
> 23                7
> 24                15
> 25                11
> 26                3
> 27                4
> 28                6
> 29                8
> 30                4                             
> 31                ?? (a known)
> 
> For backtesting of forecasting accuracy, I can use either a sliding window ( 1 - 30 to solve for 31, 2 - 31 to solve for 32, 3 - 32 to solve for 33, etc.) OR a cumulative window (1 - 30 to solve for 31, 1 - 31 to solve for 32, 1 - 32 to solve for 33, etc.), whichever works better. I can also supply different windows if deemed  appropriate, e.g., 50 or 75 or 100 obs, whatever, in either configuration.
> 
> The 30 obs window is selected for this list query only so as not to take up too much message space.
> 
> Query: How would you solve for ob 31 in the above series, with the constraints stated? (If you need a longer history, say, 50 obs or more, I can supply it off-list.) I've tried all the relevant Excel functions with no success, and suspect that the solution lies in some combination of them. Here I defer to the collective wisdom of you all. 
> 
> Once the correct concept is established, I can proceed to set it up in R for this and other similar series.
> 
> Many TIA and regards,
> Perry E. Gary
> Tokyo
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>




More information about the R-help mailing list