Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Multiple linear regression applies to data consisting of an n×1n \times 1 vector yy and an n×(m+1)n \times (m+1) matrix XX whose first column is all ones. In the (univariate) time series context, yy denotes the observed values of the time series. There are two ways of creating XX:

  1. The covariates are given by various functions of the time. For example, the first covariate could be the time index, the second covariate could be the square of the time index, the third covariate could be some other function of time etc.

  2. Auto-Regression: Here the covariates would be the lagged values of the observed time series. Here are examples of both these kinds of regressions.

Example of Regression with functions of time: USA Accidents Dataset

This dataset was inbuilt in R. I have saved it as “USAccDeaths.csv”.

<Figure size 640x480 with 1 Axes>

To this data, below we fit the model:

yt=β0+β11cos⁡(2πf1t/12)+β12sin⁡(2πf1t/12)+β21cos⁡(2πf2t/12)+β22sin⁡(2πf2t/12)+β31cos⁡(2πf3t/12)+β32sin⁡(2πf3t/12)+ϵt.\begin{align*} y_t &= \beta_0 + \beta_{11} \cos(2 \pi f_1 t/12) + \beta_{12} \sin(2 \pi f_1 t/12) \\ &+ \beta_{21} \cos(2 \pi f_2 t/12) + \beta_{22} \sin(2 \pi f_2 t/12) \\ &+ \beta_{31} \cos(2 \pi f_3 t/12) + \beta_{32} \sin(2 \pi f_3 t/12) + \epsilon_t. \end{align*}

with fixed frequencies f1=1f_1 = 1, f2=2f_2 = 2 and f3=3f_3 = 3.

                            OLS Regression Results                            
==============================================================================
Dep. Variable:                      x   R-squared:                       0.706
Model:                            OLS   Adj. R-squared:                  0.679
Method:                 Least Squares   F-statistic:                     25.98
Date:                Tue, 08 Sep 2026   Prob (F-statistic):           1.60e-15
Time:                        18:54:09   Log-Likelihood:                -551.88
No. Observations:                  72   AIC:                             1118.
Df Residuals:                      65   BIC:                             1134.
Df Model:                           6                                         
Covariance Type:            nonrobust                                         
==============================================================================
                 coef    std err          t      P>|t|      [0.025      0.975]
------------------------------------------------------------------------------
const       8788.7917     63.995    137.336      0.000    8660.985    8916.598
x1          -734.1918     90.502     -8.112      0.000    -914.937    -553.446
x2          -711.3231     90.502     -7.860      0.000    -892.069    -530.578
x3           408.0417     90.502      4.509      0.000     227.296     588.787
x4            97.1151     90.502      1.073      0.287     -83.630     277.861
x5           145.9722     90.502      1.613      0.112     -34.773     326.718
x6          -185.6111     90.502     -2.051      0.044    -366.357      -4.866
==============================================================================
Omnibus:                        5.033   Durbin-Watson:                   0.900
Prob(Omnibus):                  0.081   Jarque-Bera (JB):                4.860
Skew:                           0.635   Prob(JB):                       0.0880
Kurtosis:                       2.912   Cond. No.                         1.41
==============================================================================

Notes:
[1] Standard Errors assume that the covariance matrix of the errors is correctly specified.
<Figure size 1000x600 with 1 Axes>
                            OLS Regression Results                            
==============================================================================
Dep. Variable:                      x   R-squared:                       0.706
Model:                            OLS   Adj. R-squared:                  0.679
Method:                 Least Squares   F-statistic:                     25.98
Date:                Tue, 08 Sep 2026   Prob (F-statistic):           1.60e-15
Time:                        18:54:39   Log-Likelihood:                -551.88
No. Observations:                  72   AIC:                             1118.
Df Residuals:                      65   BIC:                             1134.
Df Model:                           6                                         
Covariance Type:            nonrobust                                         
==============================================================================
                 coef    std err          t      P>|t|      [0.025      0.975]
------------------------------------------------------------------------------
const       8788.7917     63.995    137.336      0.000    8660.985    8916.598
x1          -734.1918     90.502     -8.112      0.000    -914.937    -553.446
x2          -711.3231     90.502     -7.860      0.000    -892.069    -530.578
x3           408.0417     90.502      4.509      0.000     227.296     588.787
x4            97.1151     90.502      1.073      0.287     -83.630     277.861
x5           145.9722     90.502      1.613      0.112     -34.773     326.718
x6          -185.6111     90.502     -2.051      0.044    -366.357      -4.866
==============================================================================
Omnibus:                        5.033   Durbin-Watson:                   0.900
Prob(Omnibus):                  0.081   Jarque-Bera (JB):                4.860
Skew:                           0.635   Prob(JB):                       0.0880
Kurtosis:                       2.912   Cond. No.                         1.41
==============================================================================

Notes:
[1] Standard Errors assume that the covariance matrix of the errors is correctly specified.
<Figure size 1100x600 with 1 Axes>

Example of Lagged or Auto Regression

We apply lagged regression to the following dataset. The model is:

yt=β0+β1yt−1+⋯+βmyt−m+ϵt\begin{align*} y_t = \beta_0 + \beta_1 y_{t-1} + \dots + \beta_m y_{t-m} + \epsilon_t \end{align*}

for some mm. The response vector and covariate matrix in this regression are:

y=(ym+1ym+2⋅⋅⋅yn) and X=(1ymym−1⋅⋅⋅y11ym+1ym⋅⋅⋅y2⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅1yn−1yn−2⋅⋅⋅yn−m)\begin{align*} y = \begin{pmatrix}y_{m+1} \\ y_{m+2} \\ \cdot \\ \cdot \\ \cdot \\ y_n \end{pmatrix} \text{ and } X = \begin{pmatrix} 1 & y_m & y_{m-1} & \cdot & \cdot & \cdot & y_1 \\ 1 & y_{m+1} & y_{m} & \cdot & \cdot & \cdot & y_2 \\ \cdot & \cdot & \cdot & \cdot & \cdot & \cdot & \cdot \\ \cdot & \cdot & \cdot & \cdot & \cdot & \cdot & \cdot \\ \cdot & \cdot & \cdot & \cdot & \cdot & \cdot & \cdot \\ 1 & y_{n-1} & y_{n-2} & \cdot & \cdot & \cdot & y_{n-m}\end{pmatrix} \end{align*}

So the number of observations in this regression is n−mn-m.

  observation_date  MRTSSM4453USN
0       1992-01-01           1414
1       1992-02-01           1444
2       1992-03-01           1496
3       1992-04-01           1569
4       1992-05-01           1707
<Figure size 1200x600 with 1 Axes>

The code below forms yy: (n−m)×1(n-m) \times 1 and XX: (n−m)×(m+1)(n-m) \times (m+1) as above.

(391, 13)
403

Below we run regression (using OLS).

                            OLS Regression Results                            
==============================================================================
Dep. Variable:                      y   R-squared:                       0.988
Model:                            OLS   Adj. R-squared:                  0.988
Method:                 Least Squares   F-statistic:                     2597.
Date:                Tue, 08 Sep 2026   Prob (F-statistic):               0.00
Time:                        19:02:35   Log-Likelihood:                -2529.9
No. Observations:                 391   AIC:                             5086.
Df Residuals:                     378   BIC:                             5137.
Df Model:                          12                                         
Covariance Type:            nonrobust                                         
==============================================================================
                 coef    std err          t      P>|t|      [0.025      0.975]
------------------------------------------------------------------------------
const          6.7819     21.711      0.312      0.755     -35.907      49.471
x1             0.0439      0.018      2.448      0.015       0.009       0.079
x2             0.0428      0.018      2.379      0.018       0.007       0.078
x3             0.0521      0.018      2.913      0.004       0.017       0.087
x4             0.0336      0.018      1.870      0.062      -0.002       0.069
x5             0.0523      0.018      2.898      0.004       0.017       0.088
x6             0.0002      0.018      0.009      0.993      -0.036       0.036
x7            -0.0128      0.018     -0.697      0.486      -0.049       0.023
x8            -0.0304      0.019     -1.633      0.103      -0.067       0.006
x9            -0.0440      0.019     -2.368      0.018      -0.081      -0.007
x10           -0.0621      0.019     -3.352      0.001      -0.099      -0.026
x11           -0.0163      0.019     -0.875      0.382      -0.053       0.020
x12            0.9739      0.019     52.184      0.000       0.937       1.011
==============================================================================
Omnibus:                      172.369   Durbin-Watson:                   0.812
Prob(Omnibus):                  0.000   Jarque-Bera (JB):             1196.724
Skew:                           1.726   Prob(JB):                    1.36e-260
Kurtosis:                      10.845   Cond. No.                     3.36e+04
==============================================================================

Notes:
[1] Standard Errors assume that the covariance matrix of the errors is correctly specified.
[2] The condition number is large, 3.36e+04. This might indicate that there are
strong multicollinearity or other numerical problems.

The code below does prediction for yn+1,…,yn+ky_{n+1}, \dots, y_{n+k}. This needs to be done sequentially: first predict yn+1y_{n+1}, then use that prediction for yn+2y_{n+2} and so on. We shall study AutoRegressions in more detail later in the course.

<Figure size 1200x600 with 1 Axes>

The value of mm is crucial for the performance of this method. If m<12m < 12, then the predictions will look clearly off. But values of mm larger than 12 seem to give sensible predictions.