Module 2: Linear Models
Study manual for Exam SRM
1. Ordinary Least Squares (OLS) Formulation & Properties
The Multiple Linear Regression model relates a quantitative response to predictor variables :
In matrix notation for a sample of observations:
where:
- is an vector of observed responses.
- is the design matrix, with a leading column of 1s representing the intercept:
- is the vector of unknown regression parameters.
- is the error vector.
1.1 The Normal Equations & OLS Estimator
The OLS criterion chooses to minimize the Residual Sum of Squares (RSS):
Setting the gradient vector with respect to equal to :
These are the Normal Equations. Assuming has full column rank (no perfect multicollinearity), the unique solution is:
1.2 Fitted Values and the Hat Matrix
The vector of fitted (predicted) values is:
where is the Hat Matrix (or projection matrix).
Mathematical Properties of the Hat Matrix :
- Symmetric: .
- Idempotent: .
- Trace: (the number of estimated parameters).
- Leverage Bounds: . The average leverage across all observations is .
- Residuals: . The matrix is also symmetric and idempotent with trace .
- Residual Covariance: .
1.3 The Gauss-Markov Theorem
2. Reading and Reconstructing the Regression Output
Exam questions often present an incomplete R regression summary table and requires candidates to deduce missing entries.
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 15.4200 3.2500 4.745 2.84e-05 ***
driver_age -0.4500 0.0900 -5.000 1.25e-05 ***
car_value 0.0820 0.0205 4.000 0.000281 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 4.50 on 47 degrees of freedom
Multiple R-squared: 0.6425, Adjusted R-squared: 0.6273
F-statistic: 42.23 on 2 and 47 DF, p-value: 1.15e-102.1 The ANOVA Partition of Total Sum of Squares
| Component | Sum of Squares | Degrees of Freedom | Mean Square | Expected Mean Square |
|---|---|---|---|---|
| Regression (Model) | ||||
| Residual (Error) | ||||
| Total (Corrected) |
2.2 Reconstructing Key Quantities from Output Statistics
- Residual Standard Error ( or ):
Degrees of freedom for error: . Sample size: .
- Standard Error of a Slope Coefficient:
where is the from regressing on all other predictors.
- Individual -Statistic:
- Coefficient of Determination ():
measures the proportion of total variation in explained by the linear regression model.
- Adjusted ():
- always.
- can decrease when a useless predictor is added. In fact, increases if and only if the added predictor's (or partial ).
- can become negative if the model fits worse than the horizontal mean line.
- Overall -Statistic: Tests the global null hypothesis against :
2.3 The Partial -Test for Nested Models
To test whether a subset of predictors can be simultaneously dropped from a full model with predictors ():
- Full Model: Has predictors, error sum of squares , and .
- Reduced Model: Drops the predictors, leaving predictors, error sum of squares , and .
In terms of :
3. Confidence Intervals vs. Prediction Intervals
At a specified new predictor profile , the point prediction is:
Candidates must strictly distinguish between estimating the mean response versus predicting an individual observation.
| Confidence interval for | Prediction interval for | |
|---|---|---|
| Target | Population mean | A single unobserved future response |
| Sources of uncertainty | Parameter estimation error only, | Parameter estimation error plus the random noise , with |
| Variance | ||
| Width | Always narrower than the prediction interval | Always wider than the confidence interval |
| As | Shrinks to zero | Does not shrink to zero (the noise remains) |
3.1 Simple Linear Regression Formulas
For Simple Linear Regression with single predictor :
- Standard Error of the Mean Response:
- Standard Error of an Individual Prediction:
4. Special Predictors: Categorical Variables & Interactions
4.1 Categorical Predictors (Dummy Variables)
When a qualitative predictor has distinct categories (e.g., Territory = {Urban, Suburban, Rural}, ):
- We must construct exactly binary dummy variables to avoid the dummy variable trap (exact collinearity with the intercept vector of 1s).
- One category is designated as the reference (baseline) level.
Example with reference level = Rural:
Model:
- Expected Response for Rural: . The intercept represents the mean response for the baseline group when continuous covariates are 0.
- Expected Response for Urban: . The coefficient represents the differential impact of Urban relative to Rural.
- Expected Response for Suburban: .
4.2 Interaction Terms
An interaction term allows the effect of one predictor on to depend on the level of another predictor.
Rearranging:
- The effective slope with respect to is , which varies with .
- The Hierarchical Principle: If an interaction term is included in the model, the main effects and must always be retained in the model, even if their individual -values are not statistically significant!
5. Regression Diagnostics, Leverage & Influence
OLS residuals are defined as .
5.1 The Four Classic R Diagnostic Plots
When calling plot(model) in R, four diagnostic graphs are rendered to test OLS assumptions:
- Zero Reference Line
- Observed Residuals
- LOWESS Smoother
Checks Linearity & Homoskedasticity. A well-specified model exhibits an evenly distributed, random scatter of residuals around zero with a roughly horizontal red LOWESS trendline.
- 45-Degree Reference Line
- Sample Residual Quantiles
Checks Normality of Errors. Residual quantiles closely tracking the diagonal 45-degree dashed line confirm the assumption of normally distributed error terms.
| Diagnostic Graph | Target Assessment | Desired Benchmark Pattern | Actuarial Warning Flag | Corrective Actuarial Action |
|---|---|---|---|---|
| 1. Residuals vs. Fitted | Linearity & Homoskedasticity | Random horizontal band centered at 0 | Parabolic U-shape (non-linearity) or funnel widening (heteroskedasticity) | Add polynomial terms (), log-transform , or fit GLM (Gamma/Poisson) |
| 2. Normal Q-Q Plot | Error Normality () | Points lie on 45° reference line | S-shape / heavy tails (kurtosis) or upward bow (skewness) | Log-transform right-skewed claims or adopt heavy-tailed distribution |
| 3. Scale-Location | Constant Spread (Homoskedasticity) | Horizontal smoother with random scatter | Positive slope / widening spread | Apply Weighted Least Squares (WLS) or log transform |
| 4. Residuals vs. Leverage | Influential Cases (Cook's ) | All points inside boundaries | Points beyond or contour | Investigate data errors, re-evaluate leverage |
5.2 Leverage, Outliers, and Cook's Distance
Actuaries must strictly distinguish between an outlier, a high-leverage point, and an influential point:
| Category | Definition & Metric Threshold | Primary Geometric Driver | Impact on OLS Regression | Corrective Action |
|---|---|---|---|---|
| Outlier | Large studentized residual: or | Extreme in the -direction (unusual claim severity) | Inflates , widens confidence intervals, dampens | Audit claim file for recording errors; evaluate robust regression |
| High Leverage Point | High diagonal leverage: | Extreme in the -direction (far from feature centroid ) | High potential influence, but may not shift slope if on regression line | Check predictor accuracy; collect more data in sparse regions |
| Influential Observation | Cook's distance (caution) or (severe) | Extreme in BOTH -space and -space | Substantially alters estimated slopes when included vs excluded | Report model sensitivity with and without observation; evaluate truncation |
- Standardized Residuals:
- Studentized (Internally/Externally Studentized) Residuals ():
where is the estimated standard error computed with observation omitted. Values indicate severe outliers.
- Leverage (): Measures how far observation 's predictors are from the sample mean of all predictors.
- Heuristic Threshold: An observation has unusually high leverage if (or in large samples).
- Cook's Distance (): Synthesizes both residual size (outlier in ) and leverage (extremity in ) to quantify the total shift in all fitted values when observation is removed:
- Heuristic Threshold: indicates an intensely influential point that dominates the regression fit. Values warrant close actuarial scrutiny.
5.3 Multicollinearity and the Variance Inflation Factor (VIF)
Collinearity occurs when two or more predictor variables are closely correlated with each other.
Consequences of Collinearity:
- OLS parameter estimates remain unbiased.
- However, the standard errors become enormously inflated.
- Individual -statistics drop, causing truly significant variables to appear statistically insignificant (), even while the overall model -test is highly significant ()!
The Variance Inflation Factor (VIF):
For each predictor :
where is the obtained from regressing predictor onto all remaining predictors.
- Interpretation: is inflated by a factor of compared to what it would be if were completely orthogonal to all other predictors.
- Rule of Thumb:
- : Complete absence of collinearity.
- : Moderate to severe collinearity.
- : Severe collinearity requiring remedial action (dropping redundant predictors, combining via PCA, or applying Ridge regression).
6. Model Selection Criteria & Subset Selection
Adding predictors to an OLS model always reduces training RSS and increases . To prevent overfitting, penalized criteria adjust for model complexity (the total number of parameters including the intercept).
6.1 Mallows' , AIC, and BIC
Let denote the number of parameters in the candidate model (including intercept), let be its residual sum of squares, and let be an unbiased estimate of obtained from the full model with all available predictors.
- Mallows' :
An unbiased model has . We seek models with small values close to or below .
- Akaike Information Criterion (AIC): Under normality and known , AIC is proportional to Mallows' :
- Bayesian Information Criterion (BIC):
6.2 Subset Selection Algorithms
| Selection Method | Search Scope | Computational Cost | Applicability when |
|---|---|---|---|
| Best Subset Selection | Fits all possible submodels. Identifies the model with minimal RSS for each size . | : Intractable for . | Cannot be used when (requires ). |
| Forward Stepwise | Starts with null model (intercept only). Sequentially adds the single predictor that yields greatest RSS reduction, until all predictors are added. | : Fits models. | Can be applied even when (can add up to predictors). |
| Backward Stepwise | Starts with full model containing all predictors. Sequentially removes the least useful predictor (smallest / largest -value). | : Fits models. | Cannot be used when (full model cannot be fitted). |
7. Regularization & Shrinkage Methods
When is large relative to , OLS has high variance. When , OLS is completely ill-defined (infinite solutions with 0 training error). Regularization constrains or shrinks the coefficient estimates toward zero.
| Ridge regression () | Lasso regression () | |
|---|---|---|
| Penalty | ||
| Constraint region | Circular | Diamond, with corners |
| Effect on coefficients | Shrinks them toward | Drives some exactly to |
| Predictors kept | All predictors | Performs variable selection |
| Works best when | Many predictors have small, spread-out effects | A sparse subset of predictors truly affects the response |
| Solution | Closed form | No closed form; solved numerically |
7.1 Ridge Regression ( Penalty)
Ridge regression minimizes a penalized sum of squares:
where is a tuning parameter (hyperparameter).
- When : Penalty has no effect Standard OLS estimates.
- As : Penalty dominates All slope estimates (intercept becomes ).
- The intercept is never penalized!
- Closed-Form Solution:
Even when is singular ( or perfect multicollinearity), is always strictly positive definite and invertible for any !
7.2 Lasso Regression ( Penalty and Variable Selection)
Lasso (Least Absolute Shrinkage and Selection Operator) minimizes:
- Because the penalty has sharp corners on the coordinate axes (diamond constraint region), the elliptical contours of the RSS objective frequently touch the constraint boundary at a vertex where one or more coordinates are identically zero.
- Lasso produces sparse models: It sets coefficients of unimportant variables exactly to 0, performing automated feature selection.
7.3 Tuning Parameter Selection via Cross-Validation
The optimal tuning parameter is chosen using -fold cross-validation (typically 10-fold):
lambda.min: The value of that minimizes the cross-validation error.lambda.1se(One-Standard-Error Rule): The largest value of whose cross-validation error is within 1 standard error of the minimum error. Selects a simpler, more heavily regularized model with fewer variables without significantly degrading predictive performance.
8. R code and output interpretation lab
8.1 Multiple Regression Summary Table
fit <- lm(claim_cost ~ age + vehicle_type + annual_miles, data = auto_data)
summary(fit)Call:
lm(formula = claim_cost ~ age + vehicle_type + annual_miles, data = auto_data)
Residuals:
Min 1Q Median 3Q Max
-1240.2 -310.5 -12.4 289.1 2410.8
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 420.5000 112.4000 3.741 0.000241 ***
age -8.2500 2.1500 -3.837 0.000167 ***
vehicle_typeSedan 120.4000 45.2000 2.664 0.008341 **
vehicle_typeSUV 285.6000 52.1000 5.482 1.34e-07 ***
annual_miles 0.0450 0.0090 5.000 1.25e-06 ***
---
Residual standard error: 485.2 on 245 degrees of freedom
Multiple R-squared: 0.3842, Adjusted R-squared: 0.3741
F-statistic: 38.21 on 4 and 245 DF, p-value: < 2.2e-16Line-by-Line Interpretation:
- Reference Level: The baseline vehicle type omitted from the table is the reference category (e.g., Truck).
- An otherwise identical Sedan incurs on average more in claim costs than a Truck ().
- An SUV incurs on average more than a Truck ().
- Degrees of Freedom & Sample Size:
- Error degrees of freedom .
- Parameters estimated: 1 intercept + 4 slopes .
- Total sample size .
- Overall Model Utility:
- with . Strongly rejects .
8.2 Regularized Regression with glmnet
library(glmnet)
# Matrix preparation (glmnet requires model matrix X and vector y)
X <- model.matrix(claim_cost ~ age + vehicle_type + annual_miles, data = auto_data)[, -1]
y <- auto_data$claim_cost
# 1. Fit Ridge Regression (alpha = 0)
ridge_fit <- glmnet(X, y, alpha = 0)
# 2. Fit Lasso Regression (alpha = 1)
lasso_fit <- glmnet(X, y, alpha = 1)
# 3. 10-fold Cross-Validation for Lasso
set.seed(2027)
cv_lasso <- cv.glmnet(X, y, alpha = 1)
best_lam <- cv_lasso$lambda.min # Lambda minimizing MSE
se1_lam <- cv_lasso$lambda.1se # Most parsimonious model within 1 SE
# Extract coefficients at lambda.1se
coef(cv_lasso, s = "lambda.1se")
# Notice: Unimportant predictors are driven to EXACTLY zero (.)9. Common traps
10. Master Practice Question Vault
Question 1: Partial -Test for Nested Policyholder Predictors
An actuarial analyst models comprehensive automobile insurance claim severity.
- The Full Model includes 6 predictors () fitted on observations, yielding a Residual Sum of Squares .
- The Reduced Model drops 2 predictors (), yielding .
Calculate the partial -statistic testing whether the 2 dropped predictors can be excluded, and state the numerator and denominator degrees of freedom.
- A;
- B;
- C;
- D;
- E;
Detailed 4-Step Solution:
- Actuarial Formula:
- Degrees of Freedom:
- Numerator .
- Denominator .
- Calculate Sum of Squares:
- Numerator difference: .
- Mean square for dropped terms: .
- Full model error variance: .
- Evaluate -Statistic:
On 2 and 80 degrees of freedom. Correct Option: (B)
Question 2: A BIC calculation
A linear regression model with predictors ( parameters including the intercept) is fitted to observations. The model achieves a Residual Sum of Squares . An estimate of the error variance from the full model is .
Calculate the Bayesian Information Criterion (BIC) using the definition given in this module.
- A1.48
- B1.25
- C1.63
- D0.967
- E12.45
Detailed 4-Step Solution:
- Governing formula:
- Substitute Known Parameters:
- .
- .
- .
- .
- Calculate Penalty Term:
- Evaluate BIC:
Splitting the two terms shows where the penalty comes from: By that definition: . Correct Option: (D)
Question 3: Cook's Distance Computation
In an OLS regression with predictors ( parameters) and observations, the residual mean square is . Observation 12 has an OLS residual of and a leverage value of .
Calculate Cook's distance for this observation.
- A0.250
- B0.125
- C0.313
- D0.391
- E0.500
Detailed 4-Step Solution:
- Governing Formula:
- Substitute Known Values:
- .
- .
- .
- .
- Compute Components:
- Residual ratio: .
- Leverage multiplier: .
- Evaluate :
Correct Option: (C)