Lesson 9 of 11 · All lessons in this module
  1. The regression model and least squares
  2. Interpreting coefficients, fitted values and residuals
  3. The four assumptions and residual plotsVideo lesson
  4. Sums of squares, \(R^2\), the ANOVA table and the SEEVideo lesson
  5. Testing the slope: t-test, correlation test and F-testVideo lesson
  6. Intercept tests, indicator variables and p-values
  7. Forecasts and prediction intervals
  8. Functional forms: log-lin, lin-log and log-logVideo lesson
  9. Panel data, matrix form and regression software
  10. Estimating CAPM beta with a simple regression
  11. Integrated cases: reading a full regression printout

This lesson is part of the 2027 curriculum. You are following the 2026 curriculum, where it is not taught in this form. Switch if you are sitting the exam under the 2027 curriculum.

Lesson 9 of 11 · 12 min

Panel data, matrix form and regression software

Real regressions run on cross-sectional, time-series or panel data, are written compactly as y=Xβ+εy = X\beta + \varepsilon, are solved by β^=(XTX)−1XTy\hat\beta = (X^TX)^{-1}X^Ty, and are estimated in practice with a handful of spreadsheet, R or Python functions.

In short

  • Panel data follow the same entities over several periods: a cross-section and a time series at once.
  • Choose a functional form with goodness-of-fit measures and residual plots, but let economic and finance theory lead; data alone can produce a model that fits well and means nothing.
  • In matrix notation the regression is y=Xβ+εy = X\beta + \varepsilon: y is n × 1, the design matrix X is n × 2 (a column of ones plus the X values), β is 2 × 1.
  • The OLS estimator is β^=(XTX)−1XTy\hat\beta = (X^TX)^{-1}X^Ty and the fitted values are y^=Xβ^\hat y = X\hat\beta; it gives exactly the same intercept and slope as the covariance formula.
  • Excel/Google Sheets: SLOPE, INTERCEPT, LINEST, FORECAST, TREND, RSQ, CORREL. R: lm(), summary(), coef(), predict(), plot(). Python (scikit-learn): LinearRegression(), fit(), intercept_, coef_, predict(), score().

Unlock this lesson free for 7 days

Create a free account to get 7 days free: every lesson, video and flashcard, and the question bank. No card needed.