2
$\begingroup$

I'm working on time series with a monthly demand for 5 years. Currently, I'm using naive method to forecast 12 months (h=12)and it does work very well I want to forecast only for one month (h=1) (always with naive method) and then include this predicted value to time series and repeat this process 12 times. For example:

  1. get forecast for January 2013
  2. include this predicted value to time series
  3. Apply naive method for the new series

I want to do it in R. I tried to use a loop but my problem is how to add the predicted value to my time series ?

$\endgroup$
7
  • $\begingroup$ Sounds like it should be straightforward enough. Basically, you want to set up a process that could be called rolling forecasts or dynamic forecasts (although I leave these undefined for the time being and trust you understand the gist of it). As @Khashaa asks, what's the question? Are you looking for theoretical equations or computer code? Please provide more details so we can try help. $\endgroup$ Commented Jan 3, 2015 at 12:19
  • $\begingroup$ Clarifying specifically what you mean by naive method would be helpful and appreciated, too. I assume this means using the last observed value as the one-period-ahead forecast? $\endgroup$ Commented Jan 3, 2015 at 12:24
  • $\begingroup$ Yes. Naive method use the last observation. I want to do it in R. I tried to use a loop but my problem is how to add the predicted value to my time series ? $\endgroup$
    – MAYA
    Commented Jan 3, 2015 at 14:14
  • $\begingroup$ Look at arima function in stats package. $\endgroup$
    – Aksakal
    Commented Jan 3, 2015 at 18:38
  • $\begingroup$ What's the difference between Arima and Naive? What I'm looking to do is to forecast using Naive but step by step (month by month) with updating my time series each step. $\endgroup$
    – MAYA
    Commented Jan 3, 2015 at 19:56

1 Answer 1

7
$\begingroup$

@Maya, I would recommend an online forecasting text book if you are specifically interested in time series forecasting methods. It has a section on naive forecasting

There are two types of naive methods, for seasonal and non-seasonal data. programming naive models is one of the simplest models that you can do either in R or any other program. For non-seasonal data, last value is your forecast for all the future horizon. for seasonal data, the forecast for future period is same as whatever value is in the historical data during the same period (Example forecast for Aug 2015 is same value as actual value for Aug 2014.)

In R specifically you can perform naive forecast (both non seasonal and seasonal) using forecast package. The code snippet is shown below. I have also shown how the forecast looks like for non-seasonal and seasonal data plots.

library("forecast")
library("fma")

## Example Data  Non Seasonal from fma package

nsdata <- eggs
plot(nsdata)

## Forecast naive method for seasonal data for 18 years
nsdata.f <- naive(nsdata,h=18)
plot(nsdata.f)


## Example data for Seasonal data from fma package
sdata <- airpass
plot(sdata)

## Forecast naive method for seasonal data provides you 12 months of forecast
sdata.f <- snaive(sdata,h=12)
plot(sdata.f)

Non-Seasonal Data enter image description here

$\endgroup$
2
  • 3
    $\begingroup$ +1 My initial thoughts were that the OP wanted to know how to do something like this: robjhyndman.com/hyndsight/rolling-forecasts $\endgroup$ Commented Jan 4, 2015 at 1:37
  • $\begingroup$ Thank you for explanation. I have already read this book and it's very interesting. By the way, I got the solution of my problem Thank you $\endgroup$
    – MAYA
    Commented Jan 27, 2015 at 10:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.