Ordinary Least Squares

There are many econometric options in Matlab such as the Econometrics Toolbox, the Statistics Toolbox or manually entering the equations in by hand. In this section we will simulate an AR(1) process and then estimate its parameters using ordinary least squares. We compute our estimates by using both the statistics toolbox and manual entry.

Simulate an AR(1) Process

  • We simulate an AR(1) process exactly as described in the previous section

    \(y_{t} = c + \phi y_{t-1} + \epsilon_{t}\). The true parameters are:

\[\begin{split}c & = 5 \\ \phi &= 0.7 \\ \sigma &= 2\end{split}\]

Discard Observations

  • We want to discard the first 200 observations so that initial values won’t influence our results. We also set X to equal the lagged values of Y

Statistics Toolbox Approach

  • The statistics toolbox estimates a linear model with the function fitlm(X,y)
  • fitlm() generates output:

Solving Manually

  • Alternatively, we can enter the equations manually:
  • Which generates output:
  • You can see that the two different methods produce the same results