I am trying to make sure I understand how TimeSeriesForecast
works. I apologize in advance for the basic nature of this question. I am using Mathematica 10.
I create a TimeSeries
in a stock like GE, containing O/H/L/C prices and from there estimate a vector autoregression (ARMA) model using some in-sample data. I now want to produce 1-step ahead forecasts, period by period, for the out of sample data. The code I have listed below does this and produces the results as shown.
I want to make 100% sure that the forecast produced for period n are the forecast OHLC prices for period n, and not the forecast prices produced at period n for period n+1. So below, is the first set of forecast prices the forecast for period 8325, or the forecasts produced in period 8325 for period 8326?
Whats confusing me is the with ISend = 8325, I get:
GE["Path"][[ISend + 1]]
(* {8325, {20.4819, 20.5104, 20.1867, 20.32}} *)
i.e it seems that the TimeSeries variable GE somehow "lags" by 1 period.
Forecasting code
ISend
(* 8325 *)
n = 1;
forecasts =
Flatten[Table[
TimeSeriesForecast[eproc,
TimeSeriesWindow[GE, {ISend - 3 + i, ISend - 2 + i}], {n},
Method -> "Covariance"]["Path"], {i, 1, 386}], 1];
Take[forecasts, 5]
(* {{8325, {19.8498, 19.8257, 19.3094,
19.6899}}, {8326, {20.711, 20.7849, 20.3424,
21.2416}}, {8327, {20.142, 20.4853, 20.1133,
20.2042}}, {8328, {20.1565, 20.2824, 20.009,
20.0737}}, {8329, {20.0761, 20.1621, 19.96, 20.0177}}} *)