通过在R中更新来预测时间序列

时间:2021-10-01 05:54:46

I'm working on time series with a monthly demand for 5 years in R. 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:

我正在研究R中每月需求5年的时间序列。目前,我正在使用天真的方法来预测12个月(h = 12)并且它确实工作得非常好我只想预测一个月(h = 1)(始终使用朴素方法)然后将此预测值包含在时间序列中并重复此过程12次。例如:

  1. get forecast for January 2013
  2. 获得2013年1月的预测
  3. include this predicted value to time series
  4. 将此预测值包含在时间序列中
  5. apply naive method for the new series
  6. 为新系列应用天真的方法

My time series is not stationary and has a trend and seasonality.

我的时间序列不是固定的,具有趋势和季节性。

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. How can I do that?

我想要做的是使用Naive进行预测,但逐步(逐月)预测每一步更新我的时间序列。我怎样才能做到这一点?

1 个解决方案

#1


1  

Surely you will get the same answer. The naive method uses the most recent observation as the forecast. So your first forecast will be equal to the last observation. Your second forecast will be equal to the first forecast, and so is also equal to the last observation. And so on.

当然你会得到同样的答案。天真的方法使用最近的观察作为预测。所以你的第一次预测将等于最后一次观察。您的第二次预测将等于第一次预测,因此也等于最后一次预测。等等。

In any case, what you describe is precisely how almost all time series forecasts work. It is called the recursive method of forecasting, where predicted values take the place of observations as you forecast further ahead. In the forecast package for R, all purely time series forecasts are created this way.

无论如何,您所描述的正是几乎所有时间序列预测的工作方式。它被称为预测的递归方法,其中预测值取代您在进一步预测时的观察值。在R的预测包中,所有纯粹的时间序列预测都是以这种方式创建的。

#1


1  

Surely you will get the same answer. The naive method uses the most recent observation as the forecast. So your first forecast will be equal to the last observation. Your second forecast will be equal to the first forecast, and so is also equal to the last observation. And so on.

当然你会得到同样的答案。天真的方法使用最近的观察作为预测。所以你的第一次预测将等于最后一次观察。您的第二次预测将等于第一次预测,因此也等于最后一次预测。等等。

In any case, what you describe is precisely how almost all time series forecasts work. It is called the recursive method of forecasting, where predicted values take the place of observations as you forecast further ahead. In the forecast package for R, all purely time series forecasts are created this way.

无论如何,您所描述的正是几乎所有时间序列预测的工作方式。它被称为预测的递归方法,其中预测值取代您在进一步预测时的观察值。在R的预测包中,所有纯粹的时间序列预测都是以这种方式创建的。