Solved – forecasting time series based on previous value forecasted

forecastingtime series

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 ?

Best Answer

@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

Related Question