All right, so the main reason I wanted to discuss the Akef and the pickoff was because in a Time series
analysis courses, instructors often talk about how to use the Akef and the pickoff as if you're following
a set of arbitrary rules.
But they never go on to show you that these rules actually do what they say they do by comparing the
Akef and the pickoff to known data by looking at the acronym for known data.
We can confirm that those rules actually work.
Following them thus becomes natural.
It's also important to recognize that these are standard topics and time series analysis, so it wouldn't
be right to leave them out.
Even so, there are important caveats.
The caveats are that even if you do follow these rules, they might not lead to the best model.
Of course, we haven't yet defined what best model actually means, but we will.
The real question is why do all that work when we can get a computer to do it for us, especially when
a computer will do a better job than we can?
That is what this lecture is all about.
So it turns out that the computers of today are fast enough that you don't need to go through all that
work, especially since you might end up with a suboptimal answer.
Instead, popular time series packages usually contain a function called auto arima that automatically
finds the best model for you.
That is to say, it tries a bunch of different settings and returns the best settings according to some
criteria on what these criteria might be will be discussed in the next lecture.
In the other language, for example, you can simply call a function called Auto Arima and pass in your
Time series, which is very nice.
In stat's models, there exists no such function.
However, there is a package called PMed Yarema, which uses stat's models under the hood that does
implement the auto arima function.
So basically we have the power of auto arima at our fingertips.
We just need to install a different library, which luckily still uses Stass models under the hood.
Now, the PMed Arima API is a little different from stat's models, so that would be worth mentioning
briefly assuming that we have our data as a series, the first step will be to call the auto Arima function.
This allows us to pass in an argument called seasonal as well as the seasonal period.
M We will get to what this means later on, but it's basically a seasonal extension of the vanilla Arima
we've been discussing so far.
This will return to us a model object from which we can make predictions.
Note that this is not a static model object, so the API is a bit different.
When we want to forecast, we call the model predict function.
This takes into arguments which are relevant to us, which are in periods and return content and periods.
Is the forecast horizon or the number of time steps to forecast and return content should be set to
true if you want the confidence bounce along with your prediction.
So that's for the out of sample data.
For the sample data you want to call the function model predict in sample.
This takes into arguments start and end along with some others, which we won't worry about.
Technically, you can return confidence intervals for the sample predictions as well, although that
is less common than for forecasts.
Unlike stats, models start and end should be specified as integers which correspond to the indices
of the train set in stats.
Models start and end can be integers, but they can also be daytime objects or strings corresponding
to the index of the the series you passed in for training.
In order to better understand what Auto Arima is doing, we'll have to discuss seasonal Arima.
This will be brief since it's not as important to know compared to the vanilla Arima.
Just understand the basic high level points and you will be fine.
Again, I want to mention that seasonality is not usually observed in stock prices, but stock prices
do not comprise all of what can be considered financial data.
And so these concepts do show up in financial literature as they should.
One example of this is that the weather or in other words, actual seasons like summer, winter and
so forth, affect when and where people purchase real estate.
So that's one example of where seasonality affects finance.
OK, so seasonal Arima, abbreviated as SCREAMO, gives us three new hyper parameters called Capital
P, Capital D and Capital Q, which are analogous with the lowercase versions of the Eurema.
So now we have six hyper parameters in total.
We usually write this as a Arima PD to cross capital P Capital, the capital Q Subscript M where M is
the seasonal period.
The reason why we add the cross is because it turns out when you write the model using operators, you
end up multiplying the non seasonal parts by the seasonal parts to get your full model.
This is outside the scope of this course, since the notation is very messy and doesn't really add any
benefit on top of what we are already doing.
However, if you want some simple intuition, we can discuss what the seasonal part might look like
in isolation.
So let's suppose we want to consider only the seasonal part of the seasonal Arima, if we have capital,
the one that means we difference YFC once using the seasonal period.
Our notation for this is Delta sub M y of T, which is equal to Y of T, minus Y of T minus M.
So this is just like regular differences, except that regular different saying subtracts from one timestep
behind and that measures the slope of the trend.
With the seasonal part of seasonal Arima, we subtract from one period ago, so if we have monthly data
and T is equal to March, then we subtract from the previous March.
Note that when we discussed stationery earlier, we discussed certain characteristics of Time series
that indicate that it is not stationary examples of this where trend and changing variance.
If either the level or the variance changes over time, then the series is not stationary.
Seasonality is the other key component of this stationary time series should also not exhibit seasonality.
So if you find a time series that does exhibit seasonality, then you would say is not stationary.
Interestingly, what we found in our previous, quote, examples was that it is possible for a non seasonal
Arima to model the airline passengers data set quite well, even though it has no seasonal component.
In fact, it's possible for a purely auto regressive H2 model to perfectly represent a sine wave.
So it's not that Arima cannot model seasonality, but including seasonality explicitly by using SCREAMO
can lead to a better model.
So without loss of generality, let's suppose that we have not difference so that we can keep using
the variable y t or you can pretend y t now represents the new difference, the time series doesn't
matter.
The seasonal auto regressive part is, again, what you might expect.
Y t is regressed on past data points in the Time series at multiples of M away from T, so for example,
by of T depends on Y of T minus M Y of T minus two M and so on.
For the moving average part, we again have the same pattern.
Y of T depends on past errors at multiples of M.
So that would be Epsilon at T minus M Epsilon at T, minus two M and so on.
Finally, once we have this season apart, we multiply it with the non seasonal part, and that gives
us the false Arima model.
In code, there is actually one extra component which gives us the sorry max model, the X part is actually
pretty nice and I think it will make you feel like this model can actually be applied to so-called real
world data.
The ex parte refers to exogenous variables.
So imagine that you have a time series of length Big T at each point in the Time series, you have some
feature vector of exogenous data, such as maybe the sentiment of tweets by Elon Musk or the sentiment
from various financial news sites.
You can include this in your model by passing in an array of feature vectors of size T bidi into the
auto arima function.
One caveat to this is that when you want to make predictions, you have to know what these features
are.
So you want to consider whether or not this is actually practical for you.
In any case, we won't be making use of this, but we will see on our output.
Sorry, Max.
So this is just in case you wanted to know what that means.
Otherwise, consider this topic outside the scope of this cause.