# How to implement a multiple regression for AR models (time series)?

Let's say I have the following model:

So I have an AR model of order 3, and I want to estimate A1, A2, and A3.

I understand how regression normally works for two variables x and y. Also, after doing some research, I think I've figured out to implement a regression for an AR(1) model. But I'm having problems extending this to AR(p). Can someone give an example of how this is done for my case? There dont seem to be any built in functions for MATLAB either. Or, am I not supposed to use regression for this type of problem? I'd appreciate any help.

If you want to implement an AR(3) model you can proceed like this: Let A be your $(Nx1)$ vector. Simply define your dependent variable $Y$ and your matrix of explanatory variables $X$ as follows:

Y = A(4:end,1);
X = [A(3:end-1,1), A(2:end-2,1), A(1:end-3,1)]


then simply run an OLS function (from the Kevin Sheppard Toolbox for ex.)

[beta, tstat] = ols(Y,X,1);


If I understand you equation correctly, you want to use one lag to predict the returns for the 10th period. In that case simply adjust the equation above to select the lags that fit your purpose. Note that you want to have the same dimensions in $Y$ and $X$.

• Makes sense, and thanks for pointing out the toolbox. – John Alperto Apr 22 '16 at 1:23