Regression when the noise has heavy tails, and an interest rate read off a bond price, modelled as AR(3) once likelihood ratio tests rule out the simpler fits.
The first MASM18 lab is maximum likelihood done by hand: write the likelihood down, maximise it numerically, and read the standard errors off the curvature at the top. It is applied twice, first to a regression whose noise is not what least squares assumes, then to an interest rate series whose model order has to be chosen from the data.
The model is a straight line, $y_i = \beta_0 + \beta_1 x_i + \sigma\varepsilon_i$, fitted to two data sets of 200 points. In the first the noise is Gaussian, and maximum likelihood and ordinary least squares find the same line, with slope 0.858. They differ only in the variance estimate, which divides the residual sum of squares by $n$ in one and by $n - 2$ in the other, so the least squares intervals come out marginally wider.
In the second the noise comes from a Student $t$ distribution, and the two part company. Least squares penalises every residual by its square, so a few extreme points drag the line and inflate the noise estimate to $\hat\sigma = 3.58$. Maximising the $t$ likelihood instead, with the degrees of freedom $\nu$ as a fourth parameter, gives $\hat\sigma = 1.88$ and an interval for the slope of width 0.66 against 1.07.
The estimate $\hat\nu = 2.57$ is a finding in its own right. A $t$ distribution with so few degrees of freedom has a finite variance but no finite fourth moment, and tails like that are what financial returns tend to have.
Whether a straight line is enough is a likelihood ratio test. Adding a quadratic term raises the log-likelihood by 0.0095, a test statistic of 0.019 against a critical value of 3.84, so the line stays.
The second half starts from fifteen years of weekly prices of a zero-coupon bond maturing at $T = 15$. The price is not stationary: it climbs towards 1 as maturity approaches, and its fluctuations shrink to nothing on the way. The yield it implies,
$$r(t) = -\frac{\log p(t, T)}{T - t},$$
is a different matter. It moves around 0.05 with a constant spread, so the yield is what gets modelled, after subtracting its mean. The last observation, at $t = T$, would divide by zero and is dropped, which leaves 780.
The sample autocorrelation at lag 1 is 0.571, so AR(1) is the obvious first attempt, and it gives $\hat a_1 = 0.578$. Its residuals look normal, but they are not white: their autocorrelations at lags 1 to 3 are 0.22, −0.25 and −0.20, all far outside the ±0.070 band. Structure the model leaves out is still in the data.
Fitting AR(1) to AR(4) and testing each against the next settles it. All four are fitted on the same observations, $t = 5$ to $780$, because likelihoods computed on different samples cannot be compared.
| Test | LR statistic | p-value | Decision |
|---|---|---|---|
| AR(1) against AR(2) | 124.53 | below 0.0001 | reject AR(1) |
| AR(2) against AR(3) | 7.34 | 0.0067 | reject AR(2) |
| AR(3) against AR(4) | 0.58 | 0.448 | keep AR(3) |
The chosen model, with $\tilde r_t = r_t - \bar r$, is
$$\tilde r_t = 0.835\,\tilde r_{t-1} - 0.465\,\tilde r_{t-2} + 0.098\,\tilde r_{t-3} + \sigma\varepsilon_t,$$
and every coefficient's 95 percent interval is clear of zero. Its residuals pass where those of AR(1) failed: the autocorrelations at lags 1 to 5 are all below 0.02 in size, and the three lags out of 30 that touch the band are about what chance alone produces.
Log-likelihoods written out for Gaussian and $t$ regression and for autoregressions, maximised with BFGS over the logarithms of the scale parameters, so the optimiser can never step into a negative variance. Standard errors come from the inverted numerical Hessian, and the AR(3) estimates agree with those from statsmodels. The course supplies its lab code in MATLAB; this lab was done in Python, with SciPy in place of the supplied optimiser.
Back to all engineering work, or the lecture notes.