So in this lecture, we will be looking at the syntax for Arche and Gurche with the Python library called
Arche, although there are other libraries in Python that implement Gurche, this seems to be the most
popular.
So this lecture will focus on showing you how to use this library so that when we look at the actual
code, you won't be surprised.
OK, so to begin, unlike most libraries we need on Google CoLab, Arche does not come preinstalled.
However, as with most Python libraries, it's very easy to install.
Simply use PIP install arch as you normally would.
The next step is to consider how we will use our.
Basically, you'll find that it's much more like stat's models compared to typical machine learning
libraries like Cycad Learn.
So the main steps are as follows.
The first step is to create the model during the stage you'll pass in the training data along with model
type of parameters, just like stat's models.
The next step is to call the fifth function, which is not taking any data since you already pass it
in a during the previous step.
The third step is to use your fittin model to make a forecast.
Now this step will require some elaboration, so that will be one of the main topics of this lecture.
So on the next few slides, we're going to expand on each of these three steps and I'll show you the
exact syntax you'll need.
OK, so the first step is to create your model for this, we're going to use a high level function called
arch model.
Note that unlike other libraries, this is not the actual name of the class, but more like a factory
method that returns some object at this point.
We'll look at some, but not all of the possible arguments.
The first argument is the Noise Time series.
You're trying to model, for example, series of log returns.
The next argument is for passing an exogenous data, which we will not use in this course.
The next argument is the mean, which is not a number like it sounds like it might be, but rather a
string.
This string specifies the kind of model you want to use for the mean portion of your time series.
As you recall, we can think of every time series as a model plus a noise model gergis for the noise
part.
While you can really use any technique we've learned about for the mean part.
Now you might ask, what about Arima?
Unfortunately, this library for some reason does not support a rhema as the model, although other
libraries do, for example, are Yuga, which is for the our language.
Since we're not using R in this class, I don't have any plans to cover that at this time.
But you can let me know on the Q&A if that's something you would be interested in seeing.
So the closest thing to a Remo that's included in this library is R x, which is an AP model with the
option of having exoticness inputs.
Now for us, we will be using the default argument, which is constant.
This makes sense since we will be looking at stock returns, which we've seen have no auto regressive
structure.
But feel free to try other options if you like.
The next argument we're going to look at is Volle, which represents the kind of Gargash model you want
to use, the default is Gargash, but the simple arch is another option.
Other advanced options are also possible to choose, for example, eg arch.
The next arguments we're going to discuss are in queue for this library, and you are used as we've
defined them in this course.
So as you recall, although some resources reverse the queue, that won't be the case this time.
Also note that the default values for P and Q are both one.
Since the most common Gurche model is the Ghazwan one, it just so happens that this model tends to
fit financial returns very well.
The final argument I want to discuss is the deceit argument.
Now, this is going to get a bit advanced, but if you've taken courses with me before, you should
find this familiar.
Basically, as you recall, the way that these models are fit is by maximizing some likelihood, of
course, in order to have a likelihood function.
You must have some corresponding distribution.
We've seen that for regression.
This is typically the normal.
However, as you may have learned in the past, financial returns have fat tails.
What we mean by this is financial returns can take on more extreme values than would be predicted by
the normal distribution, which is the default.
If you want to convince yourself of this, try plotting a histogram of stock returns against a fitted
normal distribution.
And you should see that there are large deviations.
Basically, the short story is, although the normal distribution is often the default choice, it's
not actually a good fit for financial returns.
As an example, we often find that the T distribution is a much better fit.
So this this argument allows us to specify a different distribution.
OK, so finally, we are at the second step, which is to actually fit the model, this isn't so interesting
because we can call this function without any arguments.
As with stats models, this returns a result object, which you can then use to forecast and do other
things.
One thing you can do after you fitted your model is you can call the summary function.
So if you've ever done regression analysis, what we get back from this should feel pretty familiar.
Basically, you get to see the final log likelihood, the final I, the model parameters and so forth.
It also does some statistical tests so you can check whether or not the parameters are statistically
significant.
OK, so the interesting part of how we use Gargash is when we make our predictions, let's think about
this for a second.
If we want to make a so-called prediction using Gurche, what is it that we are actually predicting?
You might think it's Epsilon of T, since that's the TIME series we're trying to model, but this actually
doesn't make sense.
OK, so why doesn't it make sense to predict Ypsilanti?
Well, Ypsilanti is Noize.
This would be nearly as random as trying to predict a number sampled from the standard normal or a coin
flip.
In fact, it's pretty much just as hard as predicting a coin flip since, as you recall, ZT is a sample
from the standard normal, which is symmetric around zero.
OK, so it doesn't make sense to predict Ypsilanti.
So what does it make sense to predict?
Well, it makes sense to predict the statistics of Ypsilanti in particular, its mean and its variance.
Note that the median is not so interesting since, as you recall, it's typically zero or in our case,
constant.
What we really care about with Gurche being a model for volatility is the variance.
As you recall, this is Sigma squared T. So when it comes time to forecast, this is really what we
want to forecast, either sigma or sigma squared.
Now, since this lecture has been quite long so far, we're going to take a break and continue in the
next lecture, the next lecture will focus on how to forecast.