7
$\begingroup$

I am using R and I need an easier way to produce forecasts of data at the original level based on forecasts using differenced data.

The situation, in more detail, is this: I am using several different models (including SVM and a few others) to forecast a time series. My models are based on differenced data since the original data is not stationary. Now I have a vector of predicted values for each model, but all the forecasts are for the differenced data. How can I get forecasts of the original data before it's differenced?

In other words, if I have forecasts of returns, how do I automatically get the forecasts of stock prices of the same period in R? I know the hard-coded way to do it, but I am looking for an easier way. In testing situations like rolling windows with different forecast horizons, things could be trickier I believe. To be more specific, if the window is rolling with horizon 7 (days), then $\hat{y}_{t+1}$ until $\hat{y}_{t+7}$ is easy to calculate by Glen's answer below. However, after we roll the window once we will be standing at time $t+7$, where we have both $y_{t+7}$ and $\hat{y}_{t+7}$. I want to calculate $\hat{y}_{t+8}$ as $y_{t+7}+\hat{z}_{t+8}$ and $\hat{y}_{t+9}$ as $y_{t+7}+\hat{z}_{t+8}+\hat{z}_{t+9}$, and so on. So, for $\hat{y}_{t+8}$ to $\hat{y}_{t+14}$ the value $y_{t+7}$ needs to be used and this could go on until the end of the dataset. Is there any R function I can use to make this calculation conveniently?

$\endgroup$
  • $\begingroup$ There's something unclear about your circumstances; you may be aware of important details that we aren't. Why is $y_{t+7}$ needed? $\endgroup$ – Glen_b Dec 4 '14 at 14:58
  • $\begingroup$ @Glen_b Because using rolling window with horizon $h=7$ we get new information step by step, at time $t+7$, we already know $y_{t+7}$, so I believe it makes more sense to calculate $\hat{y}_{t+8}$ as $y_{t+7}+\hat{z}_{t+8}$ rather than $y_{t+1}+\hat{z}_{t+1}+...+\hat{z}_{t+8}$. $\endgroup$ – svmflower Dec 4 '14 at 15:15
  • $\begingroup$ @Glen_b Thank you for clearing things up, I think I know how to proceed now. $\endgroup$ – svmflower Dec 4 '14 at 15:41
  • $\begingroup$ I moved the comment to my answer. $\endgroup$ – Glen_b Dec 4 '14 at 15:48
6
$\begingroup$

The usual approach to the point forecasts is to cumulatively add the difference-forecasts to the last cumulative observation. If $z$ are the differenced data and $y$ the original, then:

$\hat{y}_{t+1}=y_t+\hat{z}_{t+1}$

$\hat{y}_{t+2}=\hat{y}_{t+1}+\hat{z}_{t+2}=y_t+\hat{z}_{t+1}+\hat{z}_{t+2}$

and so on. The cumulative sums of the $\hat{z}$ values are easy, and adding $y_t$ is also easy. Details of what to do in R would depend on the specific model (e.g. if you fitted an ARMA to the differences, just specify the corresponding ARIMA to the original and predict that).

On your second question, you have more data, so you have to calculate new parameter estimates anyway. Since you have new parameter estimates you'd just recalculate forecasts the same way as before, but with those 7 additional observations. In some circumstances the parameter updates can be computed in terms of the old estimates and the data (e.g. state-space models), but for many models you just recompute everything like you did with the previous forecasts.

$\endgroup$
  • $\begingroup$ Lets say for fitted values, how will we know the real fitted values as it has been differenced twice already. what will be yt in that case? and how to proceed in that? I have an example here stats.stackexchange.com/questions/188595/… $\endgroup$ – Enthusiast Dec 29 '15 at 20:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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