Hello, everyone.
In this lecture, we will estimate model parameters of AR(3) Simulation.
Objective is to estimate model parameters of simulated
AR(3) process using Yule-Walker equations in matrix form.
Exactly what we did in a previous lecture, but this time it's not AR (2),
it's AR (3).
Now let's look at AR (3), not 2, AR (3) process with mean 0.
Now we have three terms instead of two.
And in this simulation, we're going to take p1 as 1 over 3,
p2 as 1 over 2 and p3 is going to be 7 over 100.
And c1 is going to 4.
Remember the Yule-Walker equations in the matrix forum.
In this case, we'll be at three-by-three systems.
This is our r matrix, this is our b, the left hand side, and
this is the coefficients that we are trying to estimate.
We will solve, we will find inverse of it, multiply to the left.
And remember Yule-Walker estimator for
sigma square is basically autocovariance at lag zero.
1 minus the dot product of the coefficients and
the autocorrelation onto lag p.
In other words, the sum of the pi ri, from 1 to p.
Please go ahead and
open up a notebook called AR(3) simulation parameter estimation.
And its name here in the notebook is Yule-Walker Estimation AR(3) Simulation.
So what are we doing?
We are trying to estimate the model parameters of an some simulations.
So we have to simulate first, this is just like before.
We have set the c to 2017 so
we can reproduce exactly what we are producing this video.
Sigma's four, this is our phi, the coefficients.
And this time we should take 100,000 data points.
Let's run the cell.
Let's go to next code block.
We are simulating AR(3) process, again we are using arima.sim.
And this time, we have three coefficients.
So it automatically understands that this is the autoregressive process of order 3.
And n is 100,000.
So we are simulating time series with 100,000 data points in it.
Let's run.
So next one, we define our autocorrelation,
coefficients from 1 to 3, so r1, r2, r3.
Okay, this is our r1, this is r2, this is r3.
And we define our matrix r and then we update r accordingly so
we get the r from the Yule-Walker equation.
And then r becomes basically once in the main diagonal and it's very symmetric,
is positive so we have a definite matrix.
This is a base of r1s and this is r2.
We define r matrix vector b Basically by putting rs as a column.
So this is our b, r1, r2, r3.
And we solve rx = b and
we are getting phi-hat here.
And the phi-hat becomes basically 0.34, 0.33,
almost 0.5 and this is almost like 0.07,
which is very close to the actual model.
And let's estimate sigma or variance.
And the variance is around 15.97, which is very close to 16.
And next code block is basically partitioning the output screen.
And then putting time plot in a CFN [INAUDIBLE] into three rows.
If we do that, here we go.
So this is our ar3 process, 100,000 data points.
And this is autocorrelation function which decays eventually.
There's some exponential decay here.
And partial autocorrelation function has three significant correlations,
lag1, lag2, lag3, and cuts off after lag3, just like we expected.
Results, we started with 100,000 data points.
Phi1 is estimated at 0.338.
This is phi2, this is phi3, which is very close.
The actual model is right here.
This is where we started our simulation and a fitted model is
right here where innoations has variance which is very close to 16.
And this is our time plot ACF and PACF.
So what have you learned?
We have learned how to estimate model parameters of ARP processes.
This time it was AR(3) processes using Yule-Walker equations in a matrix form.
In the next lecture,
we will actually look at the real time series data [INAUDIBLE] simulation.
And we'll try to fit autoregressive processes into that dataset