Multiple Linear Regression: Ordinary Least Squares Derivation & Diagnostics

by Rao Statistics · Last updated on 1 Nov 2026 · 4.1 Multiple Linear Regression

From matrix formulation and Gauss-Markov assumptions to model assessment in R and Python

Learning Objective

By the end of this lesson: Formulate a multiple linear regression model in matrix notation, estimate regression coefficients using OLS, calculate R2,R^2\text{,} adjusted R2,R^2\text{,} and F-statistics, and detect multicollinearity via Variance Inflation Factors (VIF).

Statistical Theory & Assumptions

In multiple linear regression, we model the conditional expectation of a response variable YY as a linear function of pp explanatory variables: Y=Xβ+ε,Y = X\beta + \varepsilon\text{,} where E[ε]=0E[\varepsilon] = 0 and Var⁡(ε)=σ2I.\operatorname{Var}(\varepsilon) = \sigma^2 I\text{.} The Ordinary Least Squares (OLS) estimator minimizes the sum of squared residuals e⊤e.e^\top e\text{.}

Assumptions

  • Linearity in Parameters: The relationship between predictors and the mean response is linear in the parameters β.\beta\text{.}
  • Strict Exogeneity: The expected value of errors given X is zero: E[ε∣X]=0.E[\varepsilon \mid X] = 0\text{.}
  • No Multicollinearity: The matrix XX has full column rank (rank⁡(X)=p+1),\text{(}\operatorname{rank}(X) = p + 1\text{),} meaning no exact linear dependency exists among regressors.
  • Homoscedasticity & Independence: Errors have constant variance and are uncorrelated: Cov⁡(εi,εj)=0\operatorname{Cov}(\varepsilon_i, \varepsilon_j) = 0 for i≠j.i \neq j\text{.}
β^=(XTX)−1XTY\hat{\boldsymbol{\beta}} = (\mathbf{X}^T \mathbf{X})^{-1} \mathbf{X}^T \mathbf{Y}

The vector of estimated coefficients β^\hat{\beta} is obtained by solving the system of normal equations X⊤Xβ^=X⊤Y,X^\top X \hat{\beta} = X^\top Y\text{,} with covariance matrix Cov⁡(β^)=σ2(X⊤X)−1.\operatorname{Cov}(\hat{\beta}) = \sigma^2 (X^\top X)^{-1}\text{.}

Worked Dataset & Variables

Concrete Compressive Strength Laboratory Data: Engineering experimental observations measuring 28-day compressive strength (MPa) based on Water-Cement Ratio (wc),\text{(}w_c\text{),} Fly Ash content (kg/m³), and Curing Temperature (°C). (sample size n = 30).

Data dictionary
VariableTypeDescription
sample_idIntegerBatch test specimen code
w_c_ratioNumericWater to cementitious materials ratio
fly_ashNumericFly ash proportion (kg/m³)
curing_tempNumericCuring temperature in Celsius
strength_mpaNumericCompressive strength in MPa (Response Y)
Sample observations
sample_idw_c_ratiofly_ashcuring_tempstrength_mpa
10.42502142.6
20.45452038.9
30.38602247.1
40.5301933.4
50.4552345.2

Software Procedure (R, Python & Excel)

# Fit multiple linear regression model
fit <- lm(strength_mpa ~ w_c_ratio + fly_ash + curing_temp, data = concrete_data)
summary(fit)

# Calculate Variance Inflation Factors (VIF)
car::vif(fit)

# Diagnostic plots
par(mfrow = c(2, 2))
plot(fit)

Numerical Results

The estimated OLS model demonstrates high explanatory fidelity. Water-cement ratio shows a strong negative association with strength, while fly ash and temperature contribute positively.

Key results
StatisticValueNote
Intercept (β₀)+68.42p < 0.001
β₁ (w_c_ratio)-72.35t = -7.81, p < 0.0001
β₂ (fly_ash)+0.142t = +4.12, p = 0.0003
β₃ (curing_temp)+0.618t = +2.48, p = 0.019
Coefficient of Determination (R²)0.84284.2% variance explained
Adjusted R²0.824Penalized for predictor count
Overall F-Statistic46.21 (df=3, 26)p < 0.0001
Max VIF observed1.45Well below threshold of 5.0 (No collinearity)

Interpretation & Decision Rule

Formal conclusion: The overall model is statistically significant at the α=0.001\alpha = 0.001 level (F(3,26)=46.21,\text{(}F(3, 26) = 46.21\text{,} p<0.0001).p < 0.0001\text{).} The three explanatory variables account for 84.2% of the total variability in 28-day concrete strength.

Decision rule: Each regression coefficient exhibits a p-value strictly below 0.05, confirming that all three regressors contribute unique linear explanatory power to compressive strength.

Practical significance: Controlling the water-cement ratio is the paramount determinant: each 0.05 increase in the w/c ratio reduces expected compressive strength by approximately 3.6 MPa, holding fly ash and temperature fixed.

Gauss-Markov Optimality: Under the Gauss-Markov assumptions (uncorrelated errors with constant variance), the OLS estimator β^\hat{\beta} is the Best Linear Unbiased Estimator (BLUE), achieving minimum variance among all linear unbiased estimators.

Practice Files

Download: concrete_compressive_strength_experiment.csv (CSV Dataset, 2.8 KB)

You might also like

← 4.1 Multiple Linear Regression