In this lecture, we are going to discuss holds linear trend model.
Previously we looked at simple exponential smoothing and we noted that our forecasts were always a straight
horizontal line, holds linear trend model, extends the exponential smoothing model so that we can
capture and forecast trends.
Let's start by considering what linear trend might look like.
Well, linear means line.
We know that the equation for a line in general is Y equals M, X plus B, let's suppose that instead
we say Y, Sebti equals slope times T plus.
Why not?
This doesn't change anything.
All we've done is replaced X with T and be with Y not.
As you know, the coefficient in front of T is called the slope and the constant term by itself is called
the intercept.
Clearly it is the value of Y at time T equals zero, hence the symbol y not or Y zero.
Note that the slope is the amount that y changes when t increases by one.
Understanding this kind of equation is a crucial step in understanding Holtze linear trend model.
The best way to understand holds linear trend model, in my opinion, is to simply look at the model
equations and to try and decipher each component one at a time.
The first thing you'll notice is that it's very similar to the simple exponential smoothing equations
in component form.
That's why it was so important to rearrange them in that way.
You'll notice that, whereas the simple exponential smoothing model had two equations, we now have
three equations.
So we've added one more equation, specifically one more equation for modeling the trend.
So now we have three equations in total, one for the forecast, which we already had, one for the
level which we already had, and one new equation for the trend.
Let's start by studying the forecast equation, as you can see, this is nothing but the equation for
a line.
Of course, we now have different symbols, but I know you're not going to let that intimidate you as
before.
We have the level which represents some sort of average value.
But now we also have a term that increases linearly with H, which is the number of steps in the forecast.
Clearly, this means that B of T is the trend, or in other words, the slope that is elevated, the
level is the starting value of the forecast and then the forecast increases by the amount B of T for
each step into the future that we forecast, of course, but can also be negative.
So if you increase by a negative amount, then you're actually decreasing.
The key point is, thanks to this new linear trend term, our forecast is no longer a horizontal line,
but a line in any direction.
This justifies the name holds linear trend model.
Let's now study the level equation again, this is very similar to the level equation from before.
The only difference is on the far right, which represents this moving average value.
Remember that the prediction is now made up of two components, the level and the trend, which are
represented by LMB.
As you recall, in order to make a forecast, we find L plus H times B, but since this is just one
step ahead, H equals one.
And so the value of our prediction is just L plus B or more specifically L at T minus one, plus B,
A, T minus one.
So that concludes how to update the level.
It is still exponential smoothing on the input signal way T using L of T minus one A plus B of T minus
one as the previous smoothed value.
Finally, we have the trend equation, as you can see, the general form of this equation still follows
that of exponential smoothing.
We have better times, something plus one minus BITA times the old value.
In other words, the trend to B of T is also an exponentially smooth estimate.
But what is it an exponentially smooth estimate of?
Well, that's the thing that goes in front of the beta.
So what goes there?
In fact, it's just elev T minus elev T minus one.
So why does this make sense?
Remember that B of T is trying to estimate the slope or the trend of the signal.
The slope of the signal is the value at one time, minus the value at some other time divided by the
difference in time.
In our case, the time difference is just one, because we're updating B of T on every timestep.
So of T minus elev T minus one makes sense.
You might think y ltt and not Y of T remember that one way of thinking of a time series signal is that
it is noisy.
The level of T represents the smooth version of that signal without the noise.
And so it's making the difference in L.A. is a better estimate of the overall trend because it essentially
removes that noise from the equation.
Recall that previously Alpha was treated as sort of a hyper parameter that could be tuned depending
on what you were trying to do.
In fact, this is often the case.
For example, suppose you're working as an audio engineer and you would like to remove some noise from
a sound file.
Well, if you have experience with sound editing, then you probably know that you often have to choose
some parameters yourself.
You tune these to your tastes depending on what the final output signal sounds like.
You want it to sound subjectively good, which in general is not something that can be quantified.
On the other hand, with Holtze linear trend model, now we're getting closer to the machine learning
picture where what we care about is predictive accuracy, we want our forecast to be good.
And now that our model can exhibit a trend, it actually has a chance of making decent predictions.
Therefore, the parameters that we learned about in this lecture, Alpha and Beta will no longer be
chosen arbitrarily, but rather we can fit them as usual.
If you're familiar with machine learning, then you know, this involves setting up a lost function
like the mean squared error and then minimizing the squarer over the training set using methods such
as gradient descent.
If you are unfamiliar with this process, then you don't need to worry because stats models is going
to do all this work for us.
Finally, let's take a quick look at how the code will look at a high level as before we start by instantiating
the model, unlike cyclosarin and most modern machine learning APIs, this is where we pass in the data,
which is a univariate time series.
Unlike Saikat learn, since the data is UNIVARIATE, it's OK if this data array is one dimensional.
Next, we call the fit function, which in this case doesn't take in any parameters inside yet learn.
This is where the data would usually go.
This returns a result object we can use the result object to obtain the predicted values from the set
by calling the attribute fitted values.
And if we want to forecast, we can call results forecast passing in the number of time steps to forecast.