OK, so in this lecture, we will continue looking at our garbage notebook.
The first step is to create our train test split of our log returns.
We'll use an testicles five hundred for no particular reason.
In the next block of code, we'll investigate why it's important to scale our returns when using search.
So we'll begin by calling the arch model function.
As mentioned to the first argument is the training time series.
We'll specify that we want our model to be a large one one.
The next step is to call a model that fit.
OK, so you can see how this prints out a bunch of stuff, such as the lost function at each iteration
notice that we end up getting a warning telling us that the scale of why is too small.
It says parameter estimation works better when this value is between one and 1000.
The recommended rescaling is 100 times why.
OK, so the lesson is that for Gaj, we need to scale our time series.
OK, so the next step is to scale our time series will assign the mean of the training series to be
M and the standard deviation of our training series to be X.
The next step is to standardize both the train series and the Test series using M and S.
As you recall, we subtract and divide by X.
The next step is to create an arch one.
So notice that for this, we have to specify that vol is arch, although P equals one is the default.
This is because the default model for this function is actually gaj.
The next step is to call March one that fit.
Notice that I've passed in an argument called Update Freak, which shows you how to modify how often
this function prints out the locks.
OK, so notice how the training process has completed successfully, and we no longer get any warnings.
The next step is to call the summary function on the results.
So we can see a few important things from this.
Firstly, notice that the mean model is constant mean, as you recall, this is the default setting.
Secondly, notice that the distribution is normal.
This is also one of the default settings.
Third, notice that the method is maximum likelihood.
Now, if you don't know what that is, will be going over that in a later lecture.
But if you do, then this should give you some idea of how this model is trained.
The next thing to notice is the log likelihood.
If you recall, the log likelihood for our previous model was much worse when we did not scale the time
series.
OK, so the next thing to notice is the mean model.
The mean model says that the meme is about 0.01 something, but also note that the P value for this
is quite large.
Furthermore, notice that the confidence interval also contains both positive and negative values.
The next thing to look at is the volatility model.
Notice that the arch library uses the same notation we do.
So the bias term is called omega and the arch coefficient is called out for one.
Also notice that both of these have highly significant P values.
OK, so the next step is to plot our modest predictions of the in simple condition of volatility, since
you've seen this code before.
There's nothing more to explain.
So as you can see, the fit seems to be just OK.
It seems to underestimate when the values are large and overestimate when the values are small.
The next step is to explore how to forecast most of this stuff we discussed in the code preparation.
So this should just be a review.
The first thing we're going to do is call the forecast function with only the horizon.
So why don't we do this?
You see that we get a warning telling us about this argument called the Re index, which we discussed
in the code preparation.
The next step is to try setting this index argument to true.
The next step is to simply print out the return value to see what kind of object it is.
So we can see that it's an object of type arch model forecast.
Now, as you recall, this object has attributes including mean variance and so forth.
So the next step is to try printing out the mean.
So as you can see, what we get back is a data frame.
It contains all the dates of our original training time series.
So it starts at two thousand ten or 105, even though these dates don't have a forecast.
They are simply set to not a number, by the way.
A really great exercise while you're watching this lecture is to take what you learned in the previous
lecture and try to guess what we will see.
Also, notice that the column names are simply a smaller one, each start oh two and so forth.
So if we scroll down to the bottom, we see that only the final row has actual numbers, as you recall.
This is because we didn't specify a value for the start argument.
So it simply assumes that we only want to forecast from the end of the training series.
Now, let's think about why all these values are the same.
Well, as you recall, we're just looking at the mean and the default mean model is just constant.
The next step is to check the variants.
So again, we get a full size data frame, even though most of these values are just done a number.
When we scroll down to the end, we can see that the variance forecast is stored in the final row.
The next step is to check the residual variance, as mentioned when we use a constant mean or zero,
meaning this will be the same as the variance.
So if we scroll down to the bottom, we can see that these values are the same.
The next step is to call the forecast function again, but this time to set RE index defaults.
So let's look at the main attribute once again.
So we can see that now because we only have a forecast for the final date.
This is the only role that shows up in our data frame.
The next step is to look at the variants.
So again, it's the same forecast as before, except that we do not have any rows with not a number
of values.