Cochrane-Orcutt in Python

ECON 3209 · Week 18, Lecture 3 · Kerala Agricultural University

Department of Development Economics, KAU

Autumn 2026

Learning Outcomes

By the end of this lecture, you should be able to:

  1. explain the logic of Cochrane-Orcutt and Prais-Winsten corrections
  2. estimate the autocorrelation parameter from OLS residuals
  3. apply a transformed regression in Python
  4. compare transformed estimates with HAC robust standard errors
  5. choose a practical response when autocorrelation is detected

Why Correct Autocorrelation?

  • After detecting serial correlation, we have two broad options:
    1. keep OLS coefficients but fix inference using robust methods,
    2. transform the model to reduce serial correlation directly.
  • Cochrane-Orcutt is a classic transformation approach for AR(1) errors.

Cochrane-Orcutt Steps

  1. Estimate the original regression by OLS.
  2. Obtain residuals and estimate \(\rho\) from \(\hat{e}_t = \rho \hat{e}_{t-1} + v_t\).
  3. Transform the variables:
    • \(y_t^* = y_t - \rho y_{t-1}\)
    • \(x_t^* = x_t - \rho x_{t-1}\)
  4. Re-estimate the transformed regression.

This is a feasible GLS idea.

Prais-Winsten versus Cochrane-Orcutt

  • Cochrane-Orcutt drops the first observation after transformation.
  • Prais-Winsten keeps the first observation with a modified weighting.
  • Both target AR(1) errors; Prais-Winsten is often preferred because it uses more information.

Step 1: Fit OLS and Estimate rho

Step 2: Transform and Refit

HAC Robust Standard Errors

  • Sometimes we do not want to transform the model.
  • We can keep the OLS specification but compute HAC (heteroskedasticity and autocorrelation consistent) standard errors.
  • This is especially useful when the focus is inference rather than forecasting the dynamic structure.

HAC in Python

Kerala Monthly Price Example

For Kerala rubber or coconut prices, serial correlation may come from storage, trade contracts, and gradual market adjustment.

If your goal is policy inference, HAC standard errors may be enough. If your goal is modelling the dynamics, transformation or a time-series model becomes more appealing.

Comparing Fits Visually

What to Report

  • State that autocorrelation was detected.
  • Report the diagnostic test used.
  • Explain whether you corrected via transformation, HAC standard errors, or a dynamic time-series model.
  • Link the method choice to the empirical objective.

Practical Takeaway

  • Cochrane-Orcutt is a useful teaching tool for feasible GLS correction.
  • Prais-Winsten keeps the first observation and is often preferred.
  • HAC standard errors offer a convenient alternative when the coefficient estimates themselves are acceptable.
  • The next topic extends this logic into full time-series modelling.

Exercise

Use the starter code to estimate rho from OLS residuals and run a Cochrane-Orcutt transformation. Compare the transformed coefficient on trend with the original OLS coefficient.

Summary

  • ✅ Cochrane-Orcutt estimates the AR(1) parameter and transforms the regression accordingly.
  • ✅ Prais-Winsten is a related correction that retains the first observation.
  • ✅ HAC robust standard errors are a practical alternative when only inference needs repair.
  • ✅ Method choice depends on whether you want corrected inference or a full dynamic specification.

Next Lecture

  • We begin time-series basics with stationarity, trend, seasonality, and white noise.
  • You will learn why stable stochastic properties matter before forecasting.
  • Autocorrelation prepares us for the broader time-series toolkit.