regression analysis
Linear Regression
You should know: descriptive statistics
Overview
In statistics, linear regression is a model that estimates the relationship between a scalar response and one or more explanatory variables. A model with exactly one explanatory variable is a simple linear regression; a model with two or more explanatory variables is a multiple linear regression. This term is distinct from multivariate linear regression, which predicts multiple correlated dependent variables rather than a single dependent variable. Linear regression is one of the most widely used statistical techniques, forming the basis for prediction, trend estimation, and causal-effect modeling across nearly every quantitative field.
Intuition
Given a scatterplot of points that roughly trend upward or downward, linear regression finds the single straight line that best fits the cloud of points. 'Best' means minimizing the total squared vertical distance between each data point and the line (least squares) — this penalizes big misses much more than small ones, and has a clean closed-form solution. Once you have that line, you can predict a new response for an unseen input, and the line's slope tells you how much the response is expected to change per unit change in the predictor.
Interactive Graph
Formal Definition
For n observations (yᵢ, xᵢ1, ..., xᵢp), the linear regression model assumes the response is a linear combination of the predictors plus random error:
Each response is a linear function of the predictors plus noise ε_i
Stacking all observations into vectors/matrices
Closed-form solution minimizing the sum of squared residuals
Notation
| Notation | Meaning |
|---|---|
| The intercept — the predicted y when all predictors are 0 | |
| The slope — the expected change in y per unit increase in x₁, holding other predictors fixed | |
| The random error term for observation i, assumed to have mean 0 | |
| The fitted/predicted value from the regression line | |
| Coefficient of determination — the proportion of variance in y explained by the model |
Properties
Least squares objective
Simple regression slope
Condition: for one predictor (p=1)
Regression line passes through the means
Gauss–Markov theorem
Applications
Worked Examples
Compute means: x̄ = 3, ȳ = 4.
Compute the slope using the covariance/variance formula.
Compute the intercept so the line passes through (x̄, ȳ).
Answer: ŷ = 1.3 + 0.9x
Practice Problems
A regression gives ŷ = 5 + 2x. What is the predicted value when x = 10, and what does the coefficient 2 represent?
In ordinary least squares regression, the coefficients are chosen to minimize:
A lab fits concrete strength y (MPa) against curing days x and gets ŷ = 12 + 1.8x with R² = 0.94. Predict the 28-day strength and interpret R².
Common Mistakes
Interpreting a strong linear regression fit (high R²) as proof of causation.
Regression captures association, not causation. A high R² only means the linear model explains a lot of the variance in y — confounding variables or reverse causation can still be at play.
Extrapolating far outside the range of observed x-values and trusting the prediction.
The linear relationship is only justified within (or near) the range of the data used to fit it. Extrapolation far beyond that range can produce wildly inaccurate predictions if the true relationship isn't linear everywhere.
Quiz
Summary
- Linear regression models a response y as a linear function of predictors: y = β₀ + β₁x₁ + ... + βₚxₚ + ε.
- Ordinary least squares (OLS) chooses coefficients that minimize the sum of squared residuals.
- For simple regression, the slope is β̂₁ = Σ(xᵢ−x̄)(yᵢ−ȳ) / Σ(xᵢ−x̄)², and the fitted line always passes through (x̄, ȳ).
- R² measures the proportion of variance in y explained by the model.
- A good fit shows association, not necessarily causation, and predictions are only reliable within the range of observed data.
Mathematics