Linear regression

Linear regression models the relationship between a target variable and explanatory variables through a linear combination of coefficients.

In the multiple case:

where contains the features, the coefficients, and the error term.

Intuition

Linear regression searches for the best hyperplane approximating a continuous target from input variables. The standard criterion is the residual sum of squares.

In the simple case:

The coefficient measures the average change in associated with a one-unit increase in , holding other variables fixed in the multiple case.

Ordinary least squares estimation

The OLS estimator minimizes:

In matrix form, if is invertible:

This formula immediately shows why collinearity is problematic: if the columns of are linearly dependent, the inverse does not exist.

ObjectFormulaRole
PredictionFitted values from the model
ResidualsObserved in-sample error
RSSResidual sum of squares
Variance estimatorEstimated residual variance

Model assumptions

AssumptionIdeaWhy it matters
LinearityThe model must be correctly specified in mean
ExogeneityKey condition for unbiasedness
IndependenceErrors are uncorrelated across observationsImportant for classical inference
HomoscedasticityOtherwise OLS standard errors are invalid
No perfect collinearity

invertible

Condition for existence of

Normality of errorsUseful for exact small-sample tests, not required to compute OLS

Theoretical properties

Under the standard assumptions, the OLS estimator is:

  • unbiased:
  • consistent as sample size increases under regularity conditions
  • BLUE (Best Linear Unbiased Estimator) by the Gauss-Markov theorem

Its conditional variance is:

Under Gaussian errors, OLS also coincides with the maximum likelihood estimator.

Statistical inference

ConceptFormulaInterpretation
Standard errorEstimated uncertainty on one coefficient
t-statisticTests whether a coefficient is zero or equals a target value
95% CIPlausible interval for the true coefficient
Global F-testCompare full and restricted modelsTests joint significance of several coefficients
p-value

Probability under of observing as extreme or more

Measures compatibility with the null, not effect size

p-values are not enough to judge a model. You should also look at coefficient magnitude and sign, out-of-sample stability, business or economic coherence, and sensitivity to variables being added or removed.

Goodness of fit

MetricFormula / ideaLimitation
Share of explained varianceMechanically increases when adding variables

Adjusted

Penalizes useless variablesStill an in-sample measure
RMSERoot mean squared errorSensitive to large errors
MAEMean absolute errorLess sensitive to outliers, but less smooth

Diagnostics

DiagnosticWarning signConsequence
Residuals vs fittedSystematic structure, curvatureNonlinearity or misspecification
HeteroskedasticityResidual spread grows with fitted valuesBiased standard errors; prefer HC-robust estimates
MulticollinearityHigh VIF, unstable coefficientsHarder interpretation, inflated variance
Influential pointsHigh leverage, large Cook's distanceThe model depends too much on a few observations
AutocorrelationTime-correlated residualsFrequent issue in time series settings

Limits

  • Causality does not follow from a significant linear correlation. - Outliers can strongly move coefficients. - The true relationship may be nonlinear or depend on omitted interactions. - With leakage or wrong temporal ordering, inference becomes misleading. - Linear regression extrapolates as a line or hyperplane, which can be economically absurd outside the observed region.

Common extensions

ExtensionIdea
Polynomial regressionAdd powers of variables to capture curvature
InteractionsAllow the effect of one variable to depend on another
Ridge / Lasso / Elastic NetRegularization to reduce variance and select variables
WLS / GLSHandle heteroskedasticity or correlated errors
Logistic regression

Binary classification counterpart with a logit link instead of a continuous target

Linear regression as an ML baseline

In tabular machine learning, linear regression remains an essential baseline:

  • fast to train
  • highly interpretable
  • strong comparison point before nonlinear models
  • useful to detect whether extra complexity (trees, boosting, neural nets) really adds value

It is especially relevant when data are scarce, noise is moderate, and coefficient interpretation matters.

References

• statsmodels —

OLS

• scikit-learn —

LinearRegression