Module 1: Statistical Learning & Exploratory Data Analysis
Study manual for Exam SRM
1. Foundational Distinctions in Statistical Learning
Statistical learning refers to a vast set of tools for understanding data. In a formal statistical learning problem, we observe a quantitative or qualitative response and a vector of different predictors (features, inputs, covariates) . We assume that there is some true underlying functional relationship between and :
where:
- is an unknown fixed function representing the systematic information that provides about .
- is a random error term with mean zero, , that is independent of .
1.1 Four core taxonomies
• Supervised (X and Y)
• Unsupervised (X only)
• Regression (Continuous)
• Classification (Categorical)
• Prediction (Accuracy)
• Inference (Interpretability)
• Parametric (Linear/GLM)
• Non-parametric (KNN/Trees)
| Criterion | Distinction A | Distinction B | Actuarial Example |
|---|---|---|---|
| Supervision | Supervised Learning: Every training observation includes both features and a supervising outcome label . | Unsupervised Learning: Only features are recorded; no target exists. The goal is discovering latent clusters, patterns, or principal dimensions (Module 6). | Supervised: Predicting claim severity from vehicle age. Unsupervised: Grouping policyholders into lifestyle clusters without claim labels. |
| Response Type | Regression: The response takes continuous, numerical values (e.g., loss amounts, claim costs, financial returns). | Classification: The response takes values in a discrete set of classes (e.g., claim occurrence 0/1, policy renewal vs. lapse). | Regression: Estimating ultimate claim cost in dollars. Classification: Predicting whether a driver will file at least one bodily injury claim. |
| Modeling Goal | Prediction: The primary objective is producing an accurate prediction for new cases. The structure of can be a "black box" as long as prediction error is minimized. | Inference: The primary objective is understanding how is affected by individual components of (which predictors are associated with , what is the direction and magnitude of each effect, is the relationship linear?). | Prediction: Real-time pricing algorithms where exact competitive quote pricing is prioritized. Inference: Regulatory filings requiring transparent justification of rate differentials across geographic territories. |
| Model Structure | Parametric Methods: Assume a functional form for (e.g., linear ). Reduces the estimation problem to estimating a finite set of parameters. | Non-parametric Methods: Make no explicit assumptions about the functional form of . Seek an estimate that gets close to the data without being too rough. | Parametric: Multiple Linear Regression, Logistic GLM. Non-parametric: -Nearest Neighbors, Splines, Decision Trees. |
1.2 Reducible vs. Irreducible Error
When we estimate with , our prediction for a new observation is . The expected squared error of this prediction decomposes into two fundamentally distinct components:
2. The Bias-Variance Trade-off
The bias-variance trade-off is the central theoretical concept governing all supervised statistical learning methods on Exam SRM. It dictates how model flexibility affects predictive performance.
2.1 Full Mathematical Derivation of the Decomposition
Let be a fixed, newly observed predictor value, let be the corresponding unobserved true response (where and , independent of the training data ), and let be the prediction generated by a model trained on dataset .
Because depends on the randomly drawn training sample , is a random variable with expectation and variance .
We seek to evaluate the Expected Test Mean Squared Error (MSE) at point :
Step-by-Step Proof:
- Add and subtract and inside the error term:
- Square this three-term sum:
- Take the mathematical expectation across both the training data and the new error :
- (since ).
- is non-random with respect to , so its expectation is simply .
- .
- (since ).
- (because is independent of the training data that generated ).
- .
- Summing the non-zero terms yields the celebrated Bias-Variance Decomposition:
- Total Test MSE
- Squared Bias
- Variance
- Training MSE
As flexibility increases, Squared Bias monotonically decreases, while Model Variance monotonically increases. The Test MSE curve is U-shaped, reaching its global minimum where the rate of decrease in squared bias equals the rate of increase in variance.
2.2 Deep Conceptual Breakdown of the Three Components
- Squared Bias :
- Definition: The error introduced by approximating a complicated real-world process with a much simpler model.
- Behavior: Very rigid models (e.g., Simple Linear Regression) have high bias because they cannot capture non-linear relationships. Extremely flexible models (e.g., high-degree splines, deep trees) have low bias because they can conform to almost any functional shape.
- Monotonicity: Squared bias monotonically decreases as model flexibility increases.
- Model Variance :
- Definition: The amount by which would change if we estimated it using a completely different training dataset drawn from the same population.
- Behavior: Ideally, the estimate should not vary substantially between training sets. Rigid models have low variance because changing a few data points does not shift the slope of a fitted line drastically. In contrast, highly flexible models have high variance because they chase individual data points, causing dramatic fluctuations across different training samples.
- Monotonicity: Model variance monotonically increases as model flexibility increases.
- Irreducible Error :
- Definition: The inherent noise in the system that cannot be explained by any function of the observed predictors .
- Behavior: Completely independent of model choice, algorithm flexibility, and sample size. It represents the horizontal asymptote / floor below which test MSE can never descend.
3. Resampling Methods: Validating Model Accuracy
Training MSE always flatters the fitted model because the optimization objective minimizes errors on those exact observations. As model flexibility grows, Training MSE monotonically decreases towards zero.
Consequently, Training MSE is completely useless for model selection. To evaluate predictive performance, we must estimate the Test MSE using data that was never used during model fitting.
Comparison of Resampling Approaches
│
┌─────────────────────────┼─────────────────────────┐
▼ ▼ ▼
Validation Set Split $k$-Fold CV LOOCV
┌───────────────────────┐ ┌─────────────────────────┐ ┌─────────────────────────┐
│ • Single split (e.g., │ │ • Divide into $k$ equal │ │ • $k = n$ folds. │
│ 70% train / 30% test│ │ folds (e.g., $k=5, 10$)│ │ • Fit on $n-1$, test on 1│
│ • High variance in MSE│ │ • Intermediate bias and │ │ • Virtually zero bias. │
│ • Overestimates error │ │ low variance. │ │ • High variance in MSE │
│ (smaller sample) │ │ • Gold standard for SRM.│ │ estimate (correlated).│
└───────────────────────┘ └─────────────────────────┘ └─────────────────────────┘3.1 The Validation Set Approach
- The data is randomly partitioned into a training set (e.g., 70%) and a validation/holdout set (e.g., 30%).
- Drawbacks:
- High Variability: The estimated test error rate can be highly variable depending on exactly which observations happen to land in the training set versus the validation set.
- Statistical Inefficiency (Overestimated Error Rate): Statistical learning methods perform worse when trained on fewer observations. Because the model is trained on only a subset of the data, the validation set error tends to overestimate the test error rate of the model fitted to the full dataset.
3.2 -Fold Cross-Validation
- The dataset of size is randomly partitioned into equal-sized folds .
- For each :
- Treat fold as the holdout validation set.
- Fit the statistical learning model on the remaining folds combined ().
- Compute the mean squared error on the held-out fold:
- The overall -fold cross-validation estimate is the arithmetic average:
3.3 Leave-One-Out Cross-Validation (LOOCV)
- LOOCV is the extreme special case where .
- Each individual observation is held out in turn, the model is trained on the remaining observations, and the squared prediction error is evaluated on observation .
- The LOOCV estimate is:
The Bias-Variance Trade-off Between LOOCV and -Fold ( or ):
Candidates on Exam SRM must understand the subtle bias-variance trade-off of the CV error estimators themselves:
- Bias of the Error Estimator:
- LOOCV trains on observations, which is virtually identical to the full sample . Hence, LOOCV provides an almost completely unbiased estimate of test error.
- -fold CV ( or ) trains on observations (e.g., or ). It has slightly higher bias (it slightly overestimates test error).
- Variance of the Error Estimator:
- Counterintuitively, LOOCV has higher variance than -fold CV!
- Why? In LOOCV, the fitted models are trained on datasets that are each almost identical (sharing common observations). Therefore, the validation errors are highly positively correlated. The mean of many highly correlated quantities has a higher variance than the mean of quantities that are less correlated.
- In -fold CV, the training sets overlap much less, reducing positive correlation and lowering the variance of the overall CV estimate .
- Conclusion: or strikes the optimal balance between bias and variance for estimating test error.
3.4 The Least-Squares Computational Shortcut for LOOCV
Fitting a model separate times is computationally expensive. However, for Ordinary Least Squares (OLS) linear and polynomial regression, there is a remarkable algebraic identity:
where:
- is the fitted value from the model fitted to the full dataset.
- is the standard -th OLS training residual.
- is the leverage of the -th observation, which is the -th diagonal element of the hat matrix :
3.5 The Golden Rule of Cross-Validation: Preventing Data Leakage
4. Exploratory Data Analysis (EDA) & Descriptive Statistics
Before fitting any predictive model, actuaries perform Exploratory Data Analysis (EDA) to understand the distribution, central tendencies, spread, skewness, and anomalies within the dataset.
4.1 Summary Statistics & Moment Analysis
Let be a sample of observations.
- Sample Mean () vs. Sample Median ():
- Mean: . Sensitive to extreme outliers.
- Median: 50th percentile. Robust against outliers and heavy tails.
- Skewness Diagnostic:
- : Symmetric distribution (e.g., Normal).
- : Right-skewed (positive skewness), typical in actuarial claim severity, mortality loss, and healthcare expenditures.
- : Left-skewed (negative skewness), seen in retirement age or customer retention duration.
- Interquartile Range (IQR):
where is the 25th percentile (first quartile) and is the 75th percentile (third quartile). The IQR covers the central 50% of the distribution and is robust against extreme values.
- Sample Variance () and Standard Deviation ():
- Sample Skewness () and Sample Kurtosis ():
- Skewness (Asymmetry):
indicates a long right tail; indicates a long left tail.
- Kurtosis (Tail Heaviness):
For a standard normal distribution, . Excess kurtosis is . A leptokurtic distribution (excess kurtosis ) features fat tails and a sharp peak, common in financial risk modeling.
4.2 The Boxplot & The Outlier Fence Rule
Tukey's schematic boxplot visually portrays the distribution using the Five-Number Summary:
Lower Outlier Inner Fence Q1 Median Q3 Upper Fence Upper Outlier
* ├──────────────────────────[ | | ]──────────────────────────┤ *
│ │ │ │ │ │
Q1 - 1.5*IQR Q1 │ Q2 Q3 Q3 + 1.5*IQR
│◄─────────────►│
IQR- Inner Box: Spans from to ; the vertical line inside marks the median.
- Interquartile Range: Height/width of the box .
- Lower Fence (Threshold): .
- Upper Fence (Threshold): .
- Whiskers: Extend from the quartiles to the most extreme observation that is within the fences. Whiskers never extend past beyond the box!
- Outliers: Any individual observation falling strictly below or strictly above is plotted individually as a separate point or asterisk.
4.3 Normal Quantile-Quantile (Q-Q) Plots
A normal Q-Q plot compares the sample quantiles of standardized observations against the theoretical quantiles of a standard normal distribution .
| Q-Q Plot Pattern | Diagnostic Interpretation | Actuarial Consequence & Remedy |
|---|---|---|
| Straight 45-degree diagonal line | Observations follow a normal distribution. | Standard OLS assumptions are satisfied. |
| Upward curving convex arc (both ends above line) | Right-skewed (positively skewed) distribution. Small values are clustered; large values are excessively dispersed. | OLS residuals violate normality. Apply a log transform or use a Gamma/Poisson GLM with log link. |
| Downward curving concave arc (both ends below line) | Left-skewed (negatively skewed) distribution. | Consider power transformations (e.g., Box-Cox with ). |
| S-shape: Left end below line, Right end above line | Heavy-tailed (fat-tailed / leptokurtic) distribution. Extreme values occur far more frequently than predicted by a normal distribution. | High risk of underestimating extreme claim severity or tail risk (VaR/TVaR). Consider Student's , Pareto, or Generalized Pareto distributions. |
| Inverted S-shape: Left end above, Right end below | Light-tailed (platykurtic) distribution. Bounded or truncated support with fewer extreme values. | Truncated models or uniform-like characteristics. |
5. -Nearest Neighbors (KNN)
-Nearest Neighbors is a quintessential non-parametric, memory-based learning algorithm that can be applied to both regression and classification problems.
5.1 The Algorithm
Given a positive integer and a test observation :
- Identify the points in the training dataset that are closest to using a distance metric, typically Euclidean distance:
Let denote this set of nearest points.
- KNN Regression: Estimate the response as the arithmetic average of the neighbors:
- KNN Classification: Estimate the conditional probability for class as the proportion of neighbors belonging to class :
The observation is classified to the class with the highest estimated probability (majority vote).
5.2 The Role of the Hyperparameter
| Setting | Flexibility | Bias | Variance | Effective Degrees of Freedom | Training Error |
|---|---|---|---|---|---|
| Maximum (overfitting) | Extremely low (zero at training points) | Extremely high (sensitive to local noise) | (perfect fit on training data) | ||
| Intermediate (e.g., ) | Balanced | Moderate | Moderate | Optimal test performance | |
| Minimum (underfitting) | Extremely high (predicts global sample mean/mode) | Virtually zero | Very high (ignores all local predictor information) |
As increases, the effective degrees of freedom drop, making the decision boundary smoother and less flexible, thereby increasing bias and decreasing variance.
5.3 Mandatory Predictor Standardization
Because KNN relies directly on Euclidean distance, it is highly sensitive to the measurement scale of the predictors.
If Predictor 1 is Annual Income measured in dollars ( to , standard deviation ) and Predictor 2 is Driver Age measured in years ( to , standard deviation ), a difference of in income completely dwarfs a 20-year difference in age in Euclidean distance calculations!
5.4 The Curse of Dimensionality
As the number of predictor dimensions increases:
- The volume of the feature space grows exponentially ().
- The available data points become increasingly sparse.
- To capture a fixed fraction (e.g., 10%) of the total sample volume, the nearest neighbors must be located exceedingly far away from in the predictor space.
- Consequently, the nearest neighbors are no longer genuinely "local," severely inflating bias and causing KNN to perform poorly in high dimensions compared to parametric linear models.
6. R code and output interpretation lab
Exam questions often present R output to extract coefficients, test statistics, and model diagnostic parameters.
6.1 Exploratory Data Analysis & Residual Diagnostics
# Load actuarial policyholder dataset
data <- read.csv("auto_claims.csv")
# 1. Five-number summary and distribution checks
summary(data$claim_amount)
# Output:
# Min. 1st Qu. Median Mean 3rd Qu. Max.
# 120 1450 3200 5480 6800 85000
# Notice Mean (5480) > Median (3200) -> Severe Right-Skewness!
# 2. Interquartile Range and Outlier Detection
iqr_val <- IQR(data$claim_amount) # 6800 - 1450 = 5350
upper_fence <- 6800 + 1.5 * iqr_val # 6800 + 1.5 * 5350 = 14825
lower_fence <- 1450 - 1.5 * iqr_val # 1450 - 8025 = -6575 (bounded at 0)
# Any claim above $14,825 is flagged as an outlier in boxplot!
# 3. Generating Diagnostic Plots
boxplot(claim_amount ~ vehicle_type, data = data,
main = "Claim Severity by Vehicle Category",
xlab = "Vehicle Type", ylab = "Incurred Loss ($)")
qqnorm(residuals(model_ols), main = "Normal Q-Q Plot of OLS Residuals")
qqline(residuals(model_ols), col = "red", lwd = 2)6.2 Cross-Validation with boot::cv.glm
In R, cross-validation for generalized linear models is executed using the cv.glm() function from the boot library.
library(boot)
# Fit linear regression model using glm() (equivalent to lm() when family = gaussian)
glm_fit <- glm(claim_amount ~ driver_age + vehicle_age + credit_score,
data = auto_claims)
# Run 10-fold Cross-Validation
set.seed(2027)
cv_10fold <- cv.glm(data = auto_claims, glmfit = glm_fit, K = 10)
# Inspect cross-validation results
cv_10fold$delta
# Output:
# [1] 412580.4 411990.26.3 -Nearest Neighbors with class::knn
library(class)
# Prepare standardized training and testing feature matrices
train_X <- scale(train_data[, c("driver_age", "credit_score", "annual_mileage")])
test_X <- scale(test_data[, c("driver_age", "credit_score", "annual_mileage")],
center = attr(train_X, "scaled:center"),
scale = attr(train_X, "scaled:scale")) # Crucial: Prevent data leakage!
train_Y <- train_data$claim_indicator # Binary factor: 0 or 1
# Fit KNN with K = 5
knn_pred <- knn(train = train_X, test = test_X, cl = train_Y, k = 5, prob = TRUE)
# Confusion Matrix Evaluation
conf_matrix <- table(Predicted = knn_pred, Actual = test_data$claim_indicator)
print(conf_matrix)
# Output:
# Actual
# Predicted 0 1
# 0 1820 140
# 1 80 60From this confusion matrix:
- .
- .
- .
- .
7. Common traps
8. Master Practice Question Vault
Problem 1: Mathematical Bias-Variance Decomposition
An actuarial team evaluates two competing predictive models for commercial liability claim severity at a specific covariate vector . The true expected severity at is . The irreducible noise standard deviation is .
- Model A (Rigid OLS): Average prediction ; prediction variance .
- Model B (Flexible KNN): Average prediction ; prediction variance .
Which model has the lower expected test Mean Squared Error at , and what is the difference in expected test MSE between the two models?
- AModel A has lower MSE; difference is 1,125
- BModel A has lower MSE; difference is 275
- CModel B has lower MSE; difference is 875
- DModel A has lower MSE; difference is 1,150
- EBoth models have identical test MSE
Detailed 4-Step Solution:
- Actuarial Principle & Formula: Expected Test MSE decomposes as:
- Evaluate Model A:
- .
- .
- .
- .
- .
- Evaluate Model B:
- .
- .
- .
- .
- .
- Compare and Conclude: . The irreducible error is the same for both, so the gap is all in the reducible part: reducible error for A. reducible error for B. . Model A has the lower expected test MSE, by 275: its larger bias is outweighed by its much smaller variance. Answer (B).
Why the other choices are wrong:
- (A) Adds the biases unsquared, .
- (C) Compares only the squared biases, , and ignores the variances.
- (D) Compares only the variances, , and ignores the biases.
- (E) Looks only at the irreducible error , which is the same for both models.
Problem 2: LOOCV Computational Leverage Shortcut
An OLS linear regression model is fitted to claim observations. The observed responses , fitted values , and diagonal hat matrix elements are given below:
| Observation | Actual | Fitted | Leverage |
|---|---|---|---|
| 1 | 12 | 10 | 0.20 |
| 2 | 18 | 20 | 0.50 |
| 3 | 25 | 22 | 0.25 |
| 4 | 30 | 32 | 0.60 |
| 5 | 40 | 38 | 0.20 |
Calculate the Leave-One-Out Cross-Validation estimate of the test Mean Squared Error ().
- A17.38
- B8.00
- C13.90
- D5.00
- E69.50
Detailed 4-Step Solution:
- Governing Formula:
- Compute Deleted Residuals :
- Obs 1: . .
- Obs 2: . .
- Obs 3: . .
- Obs 4: . .
- Obs 5: . .
- Sum Squared Deleted Residuals:
- Evaluate Average:
(Notice: Simple training MSE would be , illustrating how training MSE severely underestimates test error).
Answer (C).
Why the other choices are wrong:
- (A) Divides the sum by instead of .
- (B) Divides each squared residual by once instead of squaring the ratio.
- (D) Gives the training MSE, which leaves out the leverage adjustment.
- (E) Gives the sum of the squared deleted residuals and forgets to average.
Problem 3: Tukey Boxplot Fence and Outlier Evaluation
An insurer analyzes workers' compensation loss severity across a sample of 200 settled claims. The computed sample quartiles are:
- Median
The five largest settled claims in the sample are: , , , , and .
Using Tukey's rule, determine:
- The upper fence threshold beyond which a claim is categorized as an outlier.
- How many of the five largest claims are flagged as outliers.
- AUpper fence is ; 5 claims are outliers
- BUpper fence is ; 3 claims are outliers
- CUpper fence is ; 5 claims are outliers
- DUpper fence is ; 1 claim is an outlier
- EUpper fence is ; 5 claims are outliers
Detailed 4-Step Solution:
- Compute Interquartile Range (IQR):
- Compute Upper Fence:
- Evaluate Observations Above Upper Fence: Any claim strictly greater than is flagged as an outlier:
- (Regular observation)
- (Regular observation)
- Outlier 1
- Outlier 2
- Outlier 3
- Conclusion: Upper fence is ; exactly 3 claims are flagged as outliers. Answer (B).
Why the other choices are wrong:
- (A) Uses instead of .
- (C) Builds the fence from the median instead of , .
- (D) Uses , the fence for extreme outliers.
- (E) Gives itself and forgets to add .
Problem 4: -Nearest Neighbors Regression with Scaling
A homeowner policy insurer uses KNN regression to predict contents damage (, in thousands of dollars) using two predictors: Home Age (, in years) and Distance to Coast (, in miles). The training dataset consists of 4 observations:
| Policy | Age | Distance | Damage ($000) |
|---|---|---|---|
| 1 | 10 | 2 | 40 |
| 2 | 20 | 8 | 20 |
| 3 | 30 | 4 | 60 |
| 4 | 40 | 10 | 30 |
The sample standard deviations are years for and miles for . A new claim arrives with Age and Distance .
Predict for the new policy using standardized -Nearest Neighbors with .
- A60
- B37.5
- C40
- D50
- E46.3
Detailed 4-Step Solution:
- Standardize Distances: For each observation , the standardized Euclidean distance to is:
- Compute Distance to Each Policy:
- Policy 1: . .
- Policy 2: . .
- Policy 3: . .
- Policy 4: . .
- Identify Nearest Neighbors:
- Smallest distance: Policy 3 (, ).
- Second smallest: Policy 2 (, ).
- Compute KNN Prediction:
Answer (C).
Why the other choices are wrong:
- (A) Uses only the single nearest neighbour, .
- (B) Averages all four policies, which ignores the distances.
- (D) Measures distance by Distance to Coast alone and breaks the tie between policies 1 and 2 toward policy 1.
- (E) Weights the two neighbours by inverse distance, but KNN regression with takes a plain average.