In simple regression, the first column of \(X\) is a column of ones and the second column is the regressor values.
This compact matrix formula extends naturally to multiple regression.
Computing OLS by hand in Python
Visualising the fitted regression line
Geometric interpretation of OLS
OLS chooses the line with the smallest total squared vertical distance from the data points.
In simple regression, the fitted line summarises average linear association.
The slope tells us how \(Y\) changes when \(X\) increases by one unit.
The intercept is the predicted value when \(X = 0\).
Interpretation must always respect the economic context and units.
Estimating the same model with statsmodels
Residuals and fit quality
Interpreting coefficients in context
If \(\hat{\beta}_1 = 0.26\), then one more unit of fertilizer is associated with about 0.26 more units of yield.
If fertilizer is measured in kg/ha and yield in quintals/ha, interpret exactly in those units.
The intercept may be outside the realistic data range, so it is not always economically meaningful.
The slope is usually the main object of interest in simple regression.
Regression is a tool for disciplined interpretation, not just equation fitting.
Exercise
Use the arrays x = [10, 20, 30, 40] and y = [15, 18, 23, 27] to compute \(\hat{\beta}_1\) and \(\hat{\beta}_0\) manually. Then print the fitted values.
Summary
✅ The PRF describes the population relationship; the SRF is estimated from sample data.
✅ OLS minimises the sum of squared residuals.
✅ Differentiating SSR gives the normal equations.
✅ The resulting estimators are \(\hat{\beta}_0\) and \(\hat{\beta}_1\).
✅ We can compute OLS manually and verify it with statsmodels.
✅ Coefficients must be interpreted with units and economic context.
Next Lecture
We move to OLS theory and properties.
The next lecture introduces the Gauss-Markov assumptions and the meaning of BLUE.