Regression fits a function of predictors to a response, while correlation measures the strength of a linear relationship. Least squares is the workhorse that connects them and links back to the projection ideas in Singular Value Decomposition.

Correlation

Covariance measures joint variation and correlation normalizes it (see Expectation and Moments):

  • Sample version: .
  • means points lie exactly on a line; means no linear trend.
  • is invariant to shifts and positive scalings of or .

Correlation is not causation

A high can arise from a confounder, reverse causation, or coincidence. Regression fits a line but does not establish that causes . Anscombe’s quartet shows four datasets with identical but wildly different shapes, so always plot the data.

Simple Linear Regression

Model the response as a line plus noise:

Derivation: Least-Squares Estimates

Least squares minimizes the residual sum of squares . Setting the partial derivatives to zero gives the normal equations:

Solving yields

The first normal equation forces the fitted line through the centroid and makes the residuals sum to zero.

Multiple Linear Regression

With predictors, stack the data into a design matrix (a column of ones plus predictors):

Derivation: minimizing gives , so .

  • This is the normal-equations solution, an Orthogonality and Projections of onto the column space of : the fitted is the closest point in that subspace and the residual is orthogonal to it.
  • When is ill-conditioned, use the Singular Value Decomposition (giving the pseudoinverse) or ridge regularization .

Interpretation and Diagnostics

  • : expected change in per unit change in predictor , holding others fixed.
  • Coefficient of determination: , the fraction of variance explained; in simple regression .
  • Test each coefficient with a -test on (see Hypothesis Testing).
  • Check residual plots for the four assumptions: linearity, independence, constant variance (homoscedasticity), and normality.

Overfitting and extrapolation

never decreases when predictors are added, so use adjusted or cross-validation to compare models. Predictions far outside the observed range of are unreliable, and multicollinearity (correlated predictors) inflates coefficient variances and destabilizes signs.