So with this library, obtaining the forecast is a bit complicated, there are three arguments we're
going to consider in the forecast function.
The first argument is simple, which is just the horizon.
That is how many steps would we like to forecast?
The second argument is called the index, which will be the main point of confusion.
The third argument is start, which seems like it will be the start date of your forecast.
However, as you'll see, this is not quite true.
OK, so let's talk about this, a reenacts argument, in fact, the main reason we have to mention this
is because of a new change in the art library.
So if you do not set this argument explicitly, you're going to get a warning which says the default
Tafari index is true after September twenty twenty one.
This will change defaults.
Since we don't want to get this warning, we're going to set it explicitly.
Of course, in order to set this argument, we have to actually know what it means.
So what does reenacts index do according to the documentation it states, whether to index the forecasts
to have the same dimension as the series being forecast?
Now, to me, this sounds very cryptic, so let's try to explain it in a simpler way.
Basically, when you think of a forecast, you think of it like in stats models.
You have your training time series and then you make a forecast which extends beyond the end of that
Time series.
Not so with this library.
With this library, it's possible to make a forecast starting from any point within the Time series
as well.
For example, if your Time series goes from January twenty twenty one up to January twenty twenty two,
it's possible to make a forecast starting at March 1st.
Twenty twenty one.
And note that this is not an example.
One step prediction as you might expect, it's a legitimate multi-step forecast.
So that's one thing you may not have expected.
Of course, the latest forecast you can make corresponds to the final date in the training time series.
OK, so here's another strange fact about how we can forecast with this library, not only can we start
the forecast from any date within the time series, we can actually forecast from every date within
the Time series at the same time.
So if your data goes from twenty twenty one up to twenty, twenty two, you can potentially create a
forecast for every day of the whole year.
That brings us back to this reenacts index argument, basically reenacts equals true means you want
the resulting data frame to have the same length as your training series.
So if your training series went from twenty twenty one up to twenty twenty two, your forecast data
frame will have one row for every day of the year.
On the other hand, if you set index to false.
This means that the resulting data frame will only contain the dates for which you wanted to make a
forecast.
Now this is a bit abstract, so it helps to simply look at examples.
So suppose we said re indexed to true and we set the forecast horizon to five and we set the start to
March six.
Also, suppose that our data set only goes from March one up to March 10.
In this case, the forecast data frame will have a row for every day from March one up to March 10,
the entirety of the Input Time series, but only March six up to March 10 will be filled with actual
numbers for the forecast.
The other rows will be set to Enan.
Now, let's consider what happens if you set reenacts to false in this case, you will only get the
rose from March six up to March 10 and all of them will be filled.
So as you can see in this case, the forecast goes from left to right.
So suppose that we wanted to make a forecast for March six.
The first column in this case contains the forecast for March seven.
The second column contains the forecast for March 8th and so on.
Also note the headings which are named as one H2 and so forth.
Now, we've pretty much already explained the first argument, which is start essentially this argument
controls the first date from which we want to generate a forecast.
So this date and every date after it, we'll have a forecast as per the previous slide.
The only thing left to mention is that if you do not pass in this argument, there will only be a single
forecast for the final date of your training series.
So if your data goes from March one to March 10, the forecasts will be assumed to start on March 10,
which means that the first the actual forecast data point is a forecast for March 11.
Now, again, as mentioned earlier, this so-called forecast is not just a single number when we call
the forecast function, this actually returns an object of type Arche model forecast.
From this, we can access certain attributes like the mean of variance and so forth.
So when you call variance, this will return a data frame of variance forecasts.
One point of confusion is that there are two attributes for variance.
One is called residual variance and the other is simply called variance.
These will only be different if you specify a mean model that can change like an error process.
So for us, it doesn't matter which one we use since they will be the same.
OK, so the final topic we have to discuss in this lecture is the difference between in sample and out
of sample predictions.
As you recall, we've seen that we can kind of do an end sample forecast, but this is not a true in
sample prediction.
In fact, the sample prediction is obtained by accessing that attribute, conditional volatility through
the arch model result object.
As you recall, this is the objects return by calling fit.
Also recall that in finance we normally think of volatility as the square root of variance.
Thus this is on a different scale than the actual forecast, which has variance.
So when we do the forecast, we want to take the square root such that the sample predictions and the
forecasts can be on the same scale.
OK, so let's now summarize what we've learned about the code since that was probably more complex than
you expected, as we saw, there are three main steps.
The first step is to construct our model using the high level function arc model.
This takes in several arguments, such as your training time series, the type of model, the model
orders and the error distribution.
The second step is to fit the model.
After fitting the model, we can also call the summary function to check the result.
The third step is to forecast.
We learned about three arguments for the forecast function, including Horizon re index and start the
most confusing of these were we index start, which allow us to quote unquote forecast starting not
only from the end of the Time series, but from any point within the Time series.
We also learn that what we are actually forecasting is not the Time series itself, but its variance.
Furthermore, we learn that the sample predictions are the square root of the variance.
Thus we should also take the square root of the forecast to put them both on the same scale.