The historical display follows the frozen A8-R1 results; the older A8-A accepted version is preserved. This chapter does not retrain models or fabricate historical predictions. Main thread: when features are numerous and signals are weak, OLS coefficient variance can overwhelm out-of-sample performance. Ridge, Lasso, and Elastic Net trade controlled bias for lower variance, but regularization strength must be selected within the training data, and results must be evaluated against zero-prediction and training-mean baselines and after costs.
Prerequisites: Chapter 8 regression (OLS, standardization, introduction to regularization in software) and Chapter 38 pipelines. After this chapter, you will be able to: write the objective functions and scaling conventions for three scikit-learn estimators; hand-calculate four estimators under an orthogonal design; derive the bias, variance, and optimal strength α∗=σ2/w2 for a single Ridge coefficient; explain L1/L2 geometry and their behavior under collinearity; and compare out-of-sample prediction metrics and after-cost portfolio results for six models on the Chapter 38 pipeline.
1. Learning Objectives
Write the objective functions for OLS, Ridge, Lasso, and Elastic Net; explain the scikit-learn 1.9.1 convention that Ridge does not divide by 2n, while Lasso and Elastic Net do, and that the intercept is not penalized.
Hand-calculate all four estimators under the orthogonal design X⊤X=nI; verify the results with code.
Derive the closed-form Ridge solution, singular-value shrinkage factors, and the bias, variance, mean squared error, and optimal strength α∗=σ2/w2 for a single coefficient.
Derive the Lasso soft-thresholding rule and the orthogonal Elastic Net solution; use geometry to explain why L1 produces zero coefficients while L2 does not actively produce a sparse solution.
Explain why standardization must be fitted within the training data and how it determines whether the penalty treats each feature equally.
Explain OLS sign reversals, Ridge sharing, and Lasso's choice of one feature under collinearity, and why coefficients cannot be interpreted directly as causal effects.
Use the date-based walk-forward and training-only tuning from Chapter 38 to compare out-of-sample and after-cost performance for zero prediction, the training mean, OLS, Ridge, Lasso, and Elastic Net on a constructed panel with more noise features than effective signals.
Completion criteria: Sections 15–17 can be completed independently; trace the frozen inputs and outputs in Sections 8–10 and explain the fresh-run versus frozen-replay boundary in Section 9; this batch does not run or retrain.
2. Why Quant Needs This
Cross-sectional stock-selection models often have dozens to hundreds of candidate features, of which only a few are genuinely useful, and those signals are weak. Under fixed-design and conditional zero-mean error assumptions, full-rank OLS coefficients are unbiased, but they can have very high variance. When there are many features and little effective information in the sample (Chapter 37: overlapping labels and low signal-to-noise ratio), that variance becomes out-of-sample error. Gu, Kelly, and Xiu (2020) report the following results for monthly U.S. individual-stock data: the out-of-sample R2 for OLS using all features is −3.46%, OLS using only three variables is 0.16%, and Elastic Net is 0.11% (see the verified reading locations in Sections 11 and 20). Regularization does not make a model “smarter”; it makes the model less prone to errors caused by noise.
Chapter 8 already demonstrated regularization selection within the training data for a single series. This chapter adds three things: exact scaling of the objective functions (the α values of different software packages are not interchangeable); a quantitative bias–variance derivation; and evaluation against baselines and costs in a panel pipeline.
3. Intuition
Consider an example with two features and four observations:
X=11−1−11−11−1,y=31−1−3.
Both columns have mean 0 and population standard deviation 1, and they are orthogonal, so X⊤X=4I. The OLS coefficients are (2,1).
Ridge pulls both coefficients toward 0 by the same proportion: at α=4, they become (1,0.5).
Lasso subtracts the same amount from each coefficient and stops at 0: at α=1.5, the coefficients become (0.5,0), so the second feature is removed.
Elastic Net first subtracts an amount and then shrinks proportionally: at α=1 and L1 ratio 0.5, the coefficients become (1,1/3).
“Shrink proportionally” and “subtract a fixed amount” are the differences between L2 and L1 penalties, derived in Section 6. A simplified boundary: real features are not orthogonal, so coefficients affect one another and the closed-form solution is this simple only under orthogonality. Still, every number in this example can be reproduced exactly with scikit-learn (Section 9).
4. Mathematical Foundations
Symbol
Meaning
Dimension / units
n
Number of training sample rows
—
X∈Rn×p
Feature matrix centered and standardized on the training set
Each column is in units of one training-set standard deviation
y∈Rn
Centered label
Decimal return
w∈Rp
Coefficient
Return (decimal) per unit of standardized feature
α≥0
Regularization strength (scikit-learn notation)
Depends on the estimator; see below
ρ∈(0,1)
Elastic Net L1 ratio (scikit-learn l1_ratio)
—
X=UDV⊤
Singular value decomposition; dj is a singular value
—
z=X⊤y/n
Sample covariance between each feature and the label under an orthogonal design
Return units
Intercept: center X and y on the training set first; the intercept is the training mean and is not penalized. scikit-learn does the same when fit_intercept=True. Prerequisites: the OLS normal equations and projection in Chapter 8, and subgradients in Chapter 9 convex optimization (used in the Lasso derivation).
5. Formal Definitions
OLS (ordinary least squares).w^OLS=argminw∥y−Xw∥22. Every finite design matrix has a least-squares solution. When the matrix is rank deficient, the coefficients are generally not unique, but the training projection is unique. Invertibility of X⊤X is the condition for unique coefficients and the ordinary inverse formula (full column rank; with a centered, intercept-inclusive design, there must also be enough residual degrees of freedom). Unbiased coefficients require separate statistical assumptions, such as fixed design and conditional zero-mean errors.
Ridge. In scikit-learn 1.9.1:
w^R=argwmin∥y−Xw∥22+α∥w∥22.
The residual sum of squares in the objective is not divided byn. The L2 penalty stabilizes coefficients when X⊤X is ill-conditioned or p is large.
Lasso (least absolute shrinkage and selection operator). In scikit-learn 1.9.1:
w^L=argwmin2n1∥y−Xw∥22+α∥w∥1.
The residual sum of squares is divided by 2n. The L1 penalty can shrink a coefficient to exactly 0, so it performs feature selection.
It combines selection (L1) and stabilization (L2), making it useful when features are correlated and a sparse solution is desired.
Consequences of the scaling conventions. Rewrite Ridge in the same form as Lasso: ∥y−Xw∥2+α∥w∥2=2n[2n1∥y−Xw∥2+2nα∥w∥2]. If another package writes the objective as 2n1∥y−Xw∥2+2λ∥w∥2, then λ/2=α/(2n), or λ=α/n. The same numerical value, α=1, represents very different strengths in Ridge and Lasso. If the training sample size n changes, the relative strength of the same Ridge α changes too. When comparing software (such as glmnet) or sample lengths, convert the scaling; do not copy values directly.
Regularization path. Take a sequence of α values from large to small to obtain a curve of coefficients as α changes. Coordinate descent solves along a decreasing α grid, using the solution at the previous α as the starting value for the next (warm start; Friedman, Hastie, and Tibshirani 2010, verified in the reconnaissance report).
Scaling (standardization). Use the training-set mean μj and standard deviation sj to transform a feature to (xj−μj)/sj. A regularization penalty ∥w∥ depends on coefficient units, so “treating each feature equally” has meaning only after standardization. Estimate μ and s only on training rows (Chapter 38 Pipeline).
How Scale Enters the Penalty: Converting Coefficients Back to Original Units
Let x be the original feature, b its slope in original units, and let the training standard deviations form an invertible diagonal matrix S. The standardized feature is u=S−1(x−μ) and its coefficient is w. Since w⊤u=b⊤(x−μ), we have b=S−1w and w=Sb; the intercept absorbs centering and is not penalized. Therefore, the standardized penalties for identical predictions are
∥w∥22=j∑sj2bj2,∥w∥1=j∑sj∣bj∣.
The penalty is on “the predicted contribution from a one-training-standard-deviation change,” not an equal sum of raw slopes measured in different units. Without standardization, if the recording unit for x2 is multiplied by 100, preserving the same predictions requires dividing b2 by 100. Its L2 penalty becomes 1/104 of the original, and its L1 penalty becomes 1/100. After standardization, s2 is also multiplied by 100, so s2b2 is unchanged and the unit change cancels. A constant column with sj=0 cannot be handled by this invertible-transform proof; it must be handled according to the actual preprocessing rule.
Also check the label units. Here y is a decimal return, the standardized x is dimensionless, and w remains in return units. Under this convention, Ridge α is dimensionless, while Lasso α has return units. Elastic Net uses one numerical α to control both the L1 and L2 terms, so it must be interpreted with the label unit fixed; there is no single physical unit for it that suits both terms. If y is multiplied by c>0 and predictions and coefficients must also be multiplied by c, Ridge keeps the same α; Lasso needs α′=cα; Elastic Net must preserve both α′ρ′=cαρ and α′(1−ρ′)=α(1−ρ), which gives
α′=α[(1−ρ)+cρ],ρ′=(1−ρ)+cρcρ.
Derive this by dividing the transformed objective by c2: the residual term returns to its original scale, the L1 term gains a factor of 1/c, and the L2 term is unchanged. If ρ is fixed, mechanically multiplying Elastic Net α by 100 does not preserve both terms. Record decimal-return and percentage-return units together with the grid. This is a unit conversion for the objective function, not retuning in this batch.
Bias–variance. The mean squared error of an estimator w^ is E∥w^−w∥2=∥Ew^−w∥2+trVar(w^). Regularization increases the first term and reduces the second.
Nested tuning. Select α (and ρ) only on date-based walk-forward folds within the outer training rows; evaluate the outer test once (Chapter 38).
Baselines. Evaluate zero prediction and the training-mean prediction on the same folds, with the same portfolio rule and costs (Chapter 37).
Sparsity and collinearity. Sparsity means that many coefficients are exactly 0. Collinearity means that features are highly correlated and the smallest eigenvalue of X⊤X is close to 0.
6. Derivations
6.1 Closed-Form Solutions for OLS and Ridge
Take the gradient of the Ridge objective and set it to 0:
When α>0, X⊤X+αI is positive definite, so a unique solution always exists, even when p>n. At α=0, the optimization problem is OLS; only the ordinary inverse formula requires invertibility. When the matrix is rank deficient, the pseudoinverse can select a minimum-norm solution.
Orthogonal design (X⊤X=nI): w^OLS=X⊤y/n=z, and w^R=X⊤y/(n+α)=n+αnz. Every coefficient is multiplied by the same shrinkage factor, n/(n+α). In the example from Section 3, n=4, z=(2,1), and α=4; the factor is 1/2, giving (1,0.5).
Singular-value form for a general design: Substituting X=UDV⊤ gives
Xw^R=j∑ujdj2+αdj2uj⊤y.
For the derivation, if we use the rank-r compact SVD X=UrDrVr⊤, then Vr does not span the entire right-hand space. Therefore, when α>0, we must write
(X⊤X+αI)−1=Vr(Dr2+αIr)−1Vr⊤+αI−VrVr⊤.
The last term acts on the null space; multiplying on the left by X makes it 0. The hat matrix is therefore still UrDr(Dr2+αIr)−1DrUr⊤. We could also use a full right-singular basis and pad with zero singular values, but the first compact-SVD term alone is not the whole inverse matrix. Ridge multiplies fitted values in each principal-component direction uj by dj2/(dj2+α): directions with less variance (dj small) are shrunk the most. Under collinearity, the smallest dj is very small; this is exactly the direction in which OLS is unstable (ESL Section 3.4.1, verified in the reconnaissance report).
6.2 Bias, Variance, and Optimal Strength for a Single Ridge Coefficient
Assumptions: One standardized feature, x⊤x=n, ∑x=0; y=wx+ε, with independent errors εi of mean 0 and variance σ2.
w^=n+αx⊤y=n+αnw+x⊤ε.
Expectation: Ew^=n+αnw, with bias −n+ααw. For the variance, Var(x⊤ε)=σ2x⊤x=nσ2, so Varw^=(n+α)2nσ2. The mean squared error is
MSE(α)=(n+α)2α2w2+nσ2.
Differentiate with respect to α. The numerator is 2αw2(n+α)2−2(n+α)(α2w2+nσ2). Set it to 0 and divide by 2(n+α): αw2(n+α)−α2w2−nσ2=0, hence nαw2=nσ2,
α∗=w2σ2,MSE(α∗)=n+α∗σ2<nσ2=MSE(0).
For the last step, substitute α∗w2=σ2; the numerator becomes α∗σ2+nσ2=σ2(n+α∗).
This optimal formula and strict improvement require w=0 and σ2>0. If w=0 and σ2>0, MSE is nσ2/(n+α)2 and tends to 0 as the strength increases; there is no finite optimum given by σ2/w2. If the noise is 0 and the signal is nonzero, the optimum is α=0. Expectations and variances are conditional on the fixed design.
Financial interpretation: The weaker the signal (w small) and the larger the noise (σ large), the stronger the optimal shrinkage. α∗ does not depend on n because scikit-learn Ridge does not divide by n. When this formula does not apply:w and σ are unknown, so α∗ cannot be calculated directly; select α by validation within the training data. With multiple correlated features, there is no similarly simple formula.
6.3 Lasso Soft Thresholding
Assumptions: Orthogonal design X⊤X=nI, with the scikit-learn convention that the squared loss is divided by 2n.
Expand the objective: 2n1∥y−Xw∥2=2n1y⊤y−z⊤w+21∥w∥2 (using X⊤X=nI and z=X⊤y/n). The objective separates by coordinate; each coefficient solves
wjmin21wj2−zjwj+α∣wj∣.
The subgradient condition is 0∈wj−zj+α∂∣wj∣. If wj>0, then wj=zj−α, which requires zj>α. If wj<0, then wj=zj+α, which requires zj<−α. If wj=0, we need ∣zj∣≤α. Together,
w^jL=S(zj,α)=sign(zj)(∣zj∣−α)+.
In the example from Section 3, z=(2,1) and α=1.5: S(2,1.5)=0.5 and S(1,1.5)=0.
The same subgradient argument as in Section 6.3, with the quadratic coefficient changed to 1+α(1−ρ), gives
w^jEN=1+α(1−ρ)S(zj,αρ).
First soft-threshold, then shrink proportionally. Example: α=1, ρ=0.5 gives S(z,0.5)/1.5=(1.5/1.5,0.5/1.5)=(1,1/3).
6.5 Geometry: Why L1 Produces Zero Coefficients
Lasso is equivalent to minimizing the residual sum of squares subject to ∥w∥1≤t (a value of t corresponds to a value of α through Lagrangian duality). The residual-sum-of-squares contours are ellipses centered at the OLS solution. The L1 constraint set is a diamond, with corners on the coordinate axes. Expand the residual contours outward from the OLS center until they first touch the constraint set; often they touch a corner, where some coordinates are exactly 0. The L2 constraint set is a circle with no corners, so its point of tangency is generally not on a coordinate axis. Ridge therefore does not actively produce sparse support. This does not mean that a coordinate can never be 0: under an orthogonal design, Ridge also gives a zero coefficient when zj=0. If the OLS solution is already inside the constraint set, the constraint is inactive. In a general design, shrinkage is along singular directions; it does not guarantee that every original coordinate decreases in absolute value or that coefficient rankings stay fixed (the classic illustration in ESL Figure 3.11, verified in the reconnaissance report). Under orthogonality, this geometry is the soft-thresholding rule from Section 6.3: coordinates with ∣zj∣≤α land on a corner.
6.6 Collinearity: What OLS, Ridge, and Lasso Do
Assumptions: Two standardized features with sample correlation r, such that X⊤X/n=(1rr1).
OLS variance is Var(w^)=σ2(X⊤X)−1=n(1−r2)σ2(1−r−r1). Each coefficient's variance is 1/(1−r2) times that under orthogonality (the variance inflation factor, VIF). At r=0.99, VIF =50.25 and the standard deviation is about 7.1 times larger. The stable “sum” direction and the equal-splitting description below are for r≈+1; when r≈−1, the stable sum/difference directions switch. The estimated coefficients have correlation −r: if one is overestimated, the other is underestimated, and they are often of opposite signs, even though the sum w^1+w^2 is estimated quite precisely.
For Ridge, the eigenvalues of X⊤X are n(1+r) and n(1−r), with eigenvectors (1,1)/2 and (1,−1)/2. Ridge shrinks the “sum” direction by n(1+r)+αn(1+r) and the “difference” direction by n(1−r)+αn(1−r). The latter is much smaller, so Ridge nearly eliminates the difference and the two coefficients become similar (an equal split). When the two features are identical (r=1), Ridge splits the coefficient exactly equally (proof left as 39-C01).
For Lasso, fixing the sum of same-sign coefficients keeps the L1 penalty ∣w1∣+∣w2∣ constant. The entire objective is indifferent to the allocation only when the two columns are identical (r=1), so the fit also depends only on their sum (39-C01). With high but imperfect correlation, the residual term still distinguishes allocations. Full column rank makes the squared loss strictly convex and the Lasso solution unique, although selection can vary across samples and may retain only one variable. For example, let X⊤X/n have diagonal entries 1 and off-diagonal entries 0.99, and let y=X1+X2. Coefficients (1,1) and (2,0) both have L1 norm 2, but the latter has a normalized squared loss higher by 0.01. Theorem 1 of Zou and Hastie (2005) gives Elastic Net's “grouping effect”: the more highly correlated the features and the larger the L2 component, the closer their coefficients are (verified in the reconnaissance report; this chapter uses only the result, which is independently illustrated by the Section 8.3 simulation).
6.7 What Does Ridge Predict When α Is Large?
When α is sufficiently large relative to all eigenvalues of X⊤X, and the cross-sectional projection direction is nondegenerate, as α→∞ we have (X⊤X+αI)−1≈I/α, w^R≈X⊤y/α, and y^=yˉ+x⊤X⊤y/α. The prediction level approaches the training mean, while the direction of the cross-sectional differences approaches X⊤y (the sample covariance of each feature with the label), with the whole vector scaled by 1/α. Thus, a purely rank-based portfolio can have approximately the same holdings if the ranks are stable; the actual demeaned/L1-normalized continuous weights also approach the same limit when their leading term is the same and nonzero. Whether finite α=105 and 107 are close depends on the actual eigenvalues; it is not guaranteed. MSE still penalizes magnitude and calibration errors even when ranks are unchanged. At low signal-to-noise ratios, stronger shrinkage may reduce estimation noise; actual inner validation must determine whether the grid boundary is optimal. The limit does not imply that level error dominates, and shrinking predictions does not remove the labels' cross-sectional error. For example, take three assets with y=(−0.01,0,0.01), p=(−0.02,0,0.02), and predictions ap for a>0. Both means are zero, level error is zero, and Spearman IC stays at 1, but cross-sectional SSE is 2(0.01−0.02a)2: zero at a=0.5 and 0.0002 at a=1. Thus MSE and IC can prefer different strengths. The frequent largest-grid choice in Section 8.4 is an actual validation result; that choice alone does not identify the source of error.
7. Financial Interpretation
Coefficients are not causal effects. A standardized coefficient wj means that, holding other features constant in the training sample's joint distribution, a one-training-standard-deviation increase in feature j raises the linear prediction for the label by wj. It does not mean that “increasing this feature raises returns”: a feature may proxy for an omitted variable; with collinearity, a case where other features stay “constant” may scarcely occur in the data; and regularization pulls coefficients toward 0 according to the penalty, so coefficient size also depends on α. In the Section 8.3 simulation, both true coefficients are 1, yet OLS assigns opposite signs to them in 41.8% of samples.
Why a zero coefficient does not mean “useless.” Lasso may set a coefficient to 0 because a feature is truly irrelevant, because it is highly correlated with another selected feature, or because its signal is weaker than the current α. In Section 8.4, Lasso selects no features in 5 of 12 folds, leaving those portfolios in cash.
Regularization and portfolios. Dollar neutrality removes the common level; actual continuous weights also depend on the relative magnitudes of demeaned predictions. A common positive scaling cancels under L1 normalization. General Ridge does not multiply all original coefficients by a common factor, so it can change ranks and weights; Lasso removes features and can change ranks; large OLS coefficients on noisy features can add noise to the ranking. Thus, when the prediction-layer ROS2 differences are small, portfolio-level results can still differ, and the reverse can also happen.
Costs widen the gap. A portfolio rebalanced every 5 days has annual turnover of about 14–24 times (Section 8.4). A one-way cost of 10 basis points consumes about 1.4%–2.4% of returns per year. Models with lower turnover fare better after costs.
8. Numerical Example
8.1 Hand-Calculate Four Estimators (Constructed Teaching Example)
Use X and y from Section 3. We have n=4, X⊤y=(8,4), and z=(2,1).
Estimator
Formula
Result
OLS
z
(2,1)
Ridge, α=4
n+αnz=84z
(1,0.5)
Lasso, α=1.5
S(z,1.5)
(0.5,0)
Elastic Net, α=1,ρ=0.5
S(z,0.5)/(1+0.5)
(1,0.3333)
The maximum difference between the scikit-learn 1.9.1 fits and the closed-form solutions is 2.2×10−16. For this X, StandardScaler is the identity transformation.
8.2 Bias and Variance
Let n=50, w=0.2, and σ=1. Then α∗=σ2/w2=25. For OLS, MSE=σ2/n=0.02. At α∗, the bias is −7525×0.2=−0.0667, squared bias is 0.004444, and variance is 50/752=0.008889, for a total of 0.013333—one-third below OLS. The mean squared errors from 4,000 simulations match the formula curve (Figure 39-2).
8.3 Collinearity Simulation
Settings: n=40, two features with correlation 0.99, true coefficients (1,1), noise standard deviation 1, and 500 repetitions (seed 3902).
Method
Mean coefficients
Coefficient standard deviations
Fraction with one coefficient equal to 0
Fraction with a negative sign
OLS
(0.967, 0.982)
(1.211, 1.216)
0
41.8%
Ridge, α=10
(0.866, 0.865)
(0.127, 0.126)
0
0
Lasso, α=0.1
(0.932, 0.920)
(0.745, 0.751)
44.8%
0
VIF =1/(1−0.992)=50.25. OLS averages are close to the true values (unbiased), but the sign in any one sample is unreliable. Ridge is biased (about 0.87) but stable. In nearly half of the samples, Lasso retains only one feature.
8.4 A Panel with More Noise Features Than Effective Signals
Constructed panel (seed 3904): 40 assets, 1,260 days; 3 true features (daily expected-return loadings of 0.04%, 0.02%, and 0.01% per unit), 40 noise features, and 3 price features, for 46 features in total. ℓ=1, h=5; expanding-window date-based walk-forward, a 504-day initial training window, 63-day test blocks, 12 folds (first fit time: 2016-12-08); two inner validation blocks of 63 days each. Grids: Ridge α∈{102,…,107}; Lasso α∈{3×10−3,10−3,3×10−4,10−4,3×10−5}; Elastic Net α∈{3×10−3,10−3,3×10−4,10−4}×ρ∈{0.2,0.5,0.8}. Portfolio: cross-sectional demeaning, gross exposure 1, rebalance every 5 signal days, execute at the next close, proportional one-way costs of 0 or 10 basis points; NAV recorded daily; initial capital 1 million.
Model
ROS2 vs. zero
vs. training mean
Mean IC (model's own valid days)
Own valid days / candidate label days
Total return / Sharpe before costs
Total return / Sharpe after costs
Annual turnover
Maximum drawdown after costs
Zero prediction
0
+0.070%
—
0/750
0 / —
0 / —
0
0
Training mean
−0.070%
0
—
0/750
0 / —
0 / —
0
0
OLS
−0.699%
−0.629%
0.0316
750/750
+34.51% / 1.62
+25.08% / 1.23
24.2
−4.43%
Ridge
−0.001%
+0.069%
0.0349
750/750
+37.31% / 1.71
+27.67% / 1.33
24.2
−5.41%
Lasso
−0.037%
+0.033%
0.0380
441/750
+20.83% / 1.37
+15.91% / 1.08
13.9
−4.18%
Elastic Net
+0.025%
+0.095%
0.0499
624/750
+41.49% / 2.08
+33.64% / 1.75
19.0
−5.27%
Dates and inference display (A8-R1): The table reports the frozen summary means of each model's IC on its own valid dates; these are not rankings on a common date set. There are 750 candidate label dates; Ridge has 750 valid dates, Lasso 441, and Elastic Net 624. Zero prediction and the training mean are constants, so their IC is undefined and must not be entered as an observed 0. Chapter 39's frozen row-level predictions are missing, so the common dates and paired mean/difference for Ridge–Lasso and Ridge–Elastic Net, as well as the reason for each daily omission, could not be recomputed. The summaries confirm only that each has fewer than 750 valid dates; rows from the separate P06 experiment cannot be used to fill them in. Old fold records support that some Lasso folds were all zero, but do not independently establish the reason for every missing date.
First ask which dates are averaged. For model m, define Dm={d:ICm,d is defined}. Its own-date mean is ∣Dm∣−1∑d∈DmICm,d. For a paired comparison with Ridge, let DmR=Dm∩DR, and restrict both models to DmR:
ΔmR=∣DmR∣1d∈DmR∑(ICm,d−ICR,d).
This quantity is undefined when the common set is empty. Take the intersection first and then the difference to compare both models on the same market dates. In an independent constructed example, Ridge has ICs of 0.1, 0.9, and 0.2 on dates 1, 2, and 3; model m has ICs of 0.2 and 0.3 only on dates 1 and 3. Their own-date means are 0.4 and 0.25, which makes m appear worse. On the common set {1,3}, Ridge's mean is 0.15 and m's is 0.25, so the paired difference is instead +0.10. This example only shows that date selection can change the question; it does not supply any of this chapter's historical paired values for 750/441/624 days. The frozen P06 rows can illustrate how to form P06's own intersection; they cannot serve as Chapter 39 row records.
The old shared implementation first dropped missing IC values and then calculated NW(4) by the remaining observation index. The fourth-observation lag can span more than four trading days and therefore cannot be called “four-trading-day HAC.” The new candidate removes the old table's t-statistic and significance judgment; the old summary/PDF still preserves the historical t-statistic. There is no new calendar-aware HAC estimate here, and inability to recompute is not stated as a proven error. Any future re-estimation needs a separate protocol and the frozen row-level data.
(Test period: 750 signal days and 756 daily returns; Sharpe is annualized with a risk-free rate of 0.)
Reading the table:
OLS has the worst ROS2 (−0.70%), below the training mean, but its IC is still positive and the portfolio still makes money. Prediction-layer and portfolio-layer rankings differ.
Ridge's ROS2 is almost 0: it selects α=107 in 4 folds, 106 in 2 folds, and 105 in 6 folds (the mechanism in Section 6.7). The prediction level approaches the training mean while ranking information remains. Its own-date mean IC and portfolio result are higher than OLS; row-by-row alignment on common dates has not been recomputed.
In 5 of 12 folds (folds 1–4 and 12), Lasso selects α=3×10−3, which shrinks all coefficients to 0; predictions are constant and the portfolio stays in cash. The other folds retain 4–25 features. Its IC is calculated on only 441 dates with cross-sectional differences, so its own-date mean cannot be treated as a paired comparison with Ridge's 750 days. Elastic Net has only 624 valid days as well. The lower total return mainly reflects the all-zero folds.
Elastic Net has a 1.75 after-cost Sharpe on this frozen ledger. Its 0.050 IC is a descriptive mean on its own 624 valid days and does not support an IC advantage on common dates that have not been recomputed. This result is for this constructed panel, where the true features are independent and signal strengths were set by the author. It does not show that Elastic Net is better on real data.
Costs: 10 basis points one way reduces the average annualized return by about 2.4 percentage points (OLS 10.08% → 7.65%), consistent with annual turnover of 24.2 times × 0.1%.
9. Python Implementation
Script: code/ch39_regularized_models.py; shared module: quant_course.ml_pipeline (Chapter 38), where backtest_predictions connects predictions to the Chapter 29 ledger, run_backtest (lagged execution, proportional fees, and N returns corresponding to N+1 wealth points). The historical engineering entrypoint can retrain, but retraining cannot be used to fabricate the missing 3904 historical row-level predictions; the working script may also overwrite the original figures. The accepted I3 default Notebook only replays the frozen summary and display figures; it does not run the historical training. This batch did not run the CLI/Notebook/API; the English Notebook language layer is deferred to BIL23.
Seeds 3901–3904; outputs: ch39_results.json and three figures. Daily frequency; signal_time is the close on Dk, trade_time is the close on Dk+1, and the label interval is 5 days; missing-value treatment follows Chapter 38. Borrow fees, financing spreads, market impact, and capacity are not modeled. Tests: tests/test_ch39_regularized.py (hand-calculated estimators, α∗, soft thresholding) and tests/test_ml_pipeline.py.
Hand-calculation example:
import numpy as np
from sklearn.linear_model import ElasticNet, Lasso, LinearRegression, Ridge
X = np.array([[1.0, 1.0], [1.0, -1.0], [-1.0, 1.0], [-1.0, -1.0]])
y = np.array([3.0, 1.0, -1.0, -3.0])
for name, model in [("ols", LinearRegression()), ("ridge a=4", Ridge(alpha=4.0)),
("lasso a=1.5", Lasso(alpha=1.5)), ("enet a=1 r=0.5", ElasticNet(alpha=1.0, l1_ratio=0.5))]:
print(name, np.round(model.fit(X, y).coef_, 4))
import numpy as np
n, w, sigma = 50, 0.2, 1.0
mse = lambda a: (a * w / (n + a)) ** 2 + sigma ** 2 * n / (n + a) ** 2
grid = np.logspace(-1, 3, 4001)
print(round(grid[np.argmin(mse(grid))], 2), round(mse(sigma ** 2 / w ** 2), 6), sigma ** 2 / n)
Expected: 25.0 0.013333 0.02.
10. Visualization
Figure 39-1: The horizontal axis is α (log scale, decreasing to the right, using each estimator's scikit-learn convention); the vertical axis is the coefficient for each standardized feature. Colored lines represent three true features (true coefficients 0.6, 0.4, and −0.3); gray lines represent 12 noise features; n=120, seed 3903. Observations: Ridge coefficients move smoothly away from 0 as α decreases, with all features entering together; Lasso coefficients enter from 0 one at a time. The first two true features enter at about α≈0.50, the third at 0.25, and some noise features below 0.19. As α→0, the estimates for the first two true features are both about 0.50 (their true values are 0.6 and 0.4): with n=120, the standard error of one OLS coefficient is about 1/120≈0.09, which is sampling error. Constructed data.
Figure 39-2: The horizontal axis is Ridge α (log scale); the vertical axis is the mean squared error of the coefficient estimate. The solid line is the formula (αw/(n+α))2+σ2n/(n+α)2, dots are 4,000 simulations, the dotted horizontal line is OLS, and the vertical dashed line is α∗=25. Observation: the curve reaches its minimum (0.0133) at α∗; when α is too large, bias dominates, the mean squared error rises, and eventually exceeds OLS. Constructed data, seed 3901.
Figure 39-3: All three panels use the six models on the horizontal axis. Left: ROS2 relative to zero prediction (%). Center: the mean daily Spearman IC over each model's own valid dates, with n labeled above each bar; IC is undefined for zero prediction and the training mean, so those entries are left blank and labeled n=0. The dates differ; no paired-advantage inference is made. Right: annualized Sharpe for dollar-neutral portfolios; light bars are before costs and dark bars are after one-way costs of 10 basis points. Zero prediction and the training mean remain in cash, so their Sharpe is undefined and left blank. Observation: the rankings in the left panel differ from those in the center and right panels; costs lower all model Sharpes by 0.3–0.4. Constructed panel, seed 3904.
11. Real-Market Example
This chapter reports no measured real-market numbers: Project 6 real data are blocked (see projects/project06/data_manifest.json). The literature results read by the author (Gu, Kelly, and Xiu 2020, Table 1, p. 2250; U.S. individual stocks, monthly, before costs) are: OLS with all features, out-of-sample R2=−3.46%; OLS using only size, value, and momentum, 0.16%; and Elastic Net with Huber loss, 0.11%, with zero prediction as the baseline (Equation 19, p. 2249). This is directionally consistent with Section 8.4: with many features, unconstrained OLS performs poorly out of sample, while regularization or dimension reduction brings R2 back to a small positive value. The magnitudes are not comparable to this book's constructed results because the samples, frequencies, features, and baselines differ.
Once data are available, report all columns of the Section 8.4 table for the same frozen stock universe and sample period, and add each fold's α, Lasso support-set size, and coefficient-sign stability.
12. Common Mistakes
12.1 Regularizing Without Standardizing
import numpy as np
from sklearn.linear_model import Lasso
rng = np.random.default_rng(0)
x1 = rng.normal(size=200); x2 = rng.normal(size=200)
y = 0.5 * x1 + 0.5 * x2 + rng.normal(size=200)
X_pct = np.column_stack([x1, x2 * 100]) # x2 recorded in percent instead of decimal
coef = Lasso(alpha=0.3).fit(X_pct, y).coef_ # WRONG: penalty treats a 1-unit change equallyprint(np.round(coef, 4))
X_std = (X_pct - X_pct.mean(0)) / X_pct.std(0) # fit mean/sd on training rows onlyprint(np.round(Lasso(alpha=0.3).fit(X_std, y).coef_, 4))
The book's output is [0.2408 0.0054] and [0.2243 0.2528]. The error is that the coefficient for x2, recorded in percent, is 100 times smaller for the same information, but the penalty is unchanged. In the first output, the x2 coefficient 0.0054 converts to 0.54 in decimal units, so it is barely shrunk, while x1 is reduced from about 0.5 to 0.24. After standardization, both are shrunk equally (second output). Fix: standardize on training rows before regularization (Pipeline); when reporting coefficients, state that they are “per training standard deviation.”
12.2 Comparing Ridge and Lasso α Directly
Incorrect: “Both models use α=1, so the penalties are the same.” Why: scikit-learn Ridge does not divide by 2n, while Lasso does (Section 5). Fix: tune each independently; convert to a common convention for comparison.
12.3 Selecting α on the Full Sample
Incorrect: use RidgeCV or LassoCV to select α with random K-fold cross-validation on the full sample, then report out-of-sample results on part of that sample. Why: selection used the test period, and random folds introduce overlap leakage (Chapter 38). Fix: outer date-based walk-forward, with inner date-based walk-forward for parameter selection (ml_pipeline.fit_select_predict).
12.4 Treating Coefficients as Causal Effects or Feature-Importance Rankings
Incorrect: “Lasso selected feature A and not B, so A drives returns and B is irrelevant.” Why: under collinearity, Lasso chooses one feature (in Section 8.3, only one of the two is retained in 44.8% of samples), and the choice changes with the sample and α (support sets range from 0 to 25 across folds in Section 8.4). Fix: report selection frequency and sign stability across folds; causal questions require a separate identification design.
12.5 Looking Only at R2 or Only at Sharpe
Incorrect: select the model with the highest ROS2, or report only before-cost Sharpe. Why: in Section 8.4, Ridge has R2 near 0 yet outperforms OLS at the portfolio layer; costs reduce Sharpe by 0.3–0.4. Fix: report metrics at both layers and under both cost levels, against the zero-prediction and training-mean baselines.
12.6 Fitting StandardScaler on All Dates in a Panel
Error: fit StandardScaler().fit(X_all) first, then run walk-forward. If the training design is full rank, OLS predictions are unaffected; with exact collinearity (rank deficiency), OLS predictions for new points can also change with standardization (the Chapter 38 Section 6.3 counterexample: 2.20 versus 1.75). Ridge and Lasso can usually be affected: the penalty is based on standard deviations from the full sample, including test-period information. Fix: fit inside a Pipeline.
13. Quant Research Application
Hypothesis: Among 46 features available at the close, a few weakly predict the next 5-day cross-sectional return; a regularized linear model can produce positive after-cost dollar-neutral returns and outperform zero prediction and the training mean.
Design (frozen): Use the panel, folds, grids, portfolio rules, and costs from Section 8.4; record the selected hyperparameters and Lasso support set for each fold.
Tests: Prediction layer (out-of-sample R2 against both baselines, each model's own valid-date and common paired-date IC; inference on t-statistics is no longer displayed for this historical case); portfolio layer (returns, Sharpe, turnover, and drawdown before and after costs); stability (fold-by-fold IC and feature selection); two cost levels.
Falsification conditions: After-cost Sharpe is not positive; a paired test on dates frozen in advance shows no advantage (the missing historical row-level data in this chapter prevented evaluation); the conclusion holds in only a few folds; or the best model changes with the grid boundary (for example, Ridge always selects the largest α, prompting a check of the inner validation curve and boundary, not a switch to IC tuning after looking at outer results; the objective and comparison protocol must be frozen in advance, see 39-C02).
Tuning judgment: Compare a grid boundary or a different evaluation criterion within the training data under a protocol frozen in advance; do not infer “the IC objective must be used” from outer-test performance.
How to state the conclusion: Elastic Net has a higher after-cost Sharpe on this chapter's frozen ledger. IC means calculated on different valid dates alone do not establish a paired prediction advantage. On real data, compare again under the same protocol and retain negative results.
14. Chapter Summary
Under assumptions such as fixed design and conditional zero-mean errors, OLS is unbiased but can have high variance. Under orthogonality, Ridge shrinks by n/(n+α); in a general design, it shrinks by dj2/(dj2+α). Lasso uses soft thresholding S(z,α) to produce zero coefficients; Elastic Net thresholds first and then shrinks. In scikit-learn, Ridge does not divide the residual sum of squares by 2n, while Lasso and Elastic Net do, so α cannot be compared across estimators. For a single coefficient with w=0 and σ2>0, Ridge's optimal strength is α∗=σ2/w2; at zero signal, the optimum is the limit of infinite shrinkage, and weaker signals call for stronger shrinkage. Under collinearity, OLS signs are unstable, Ridge splits, and Lasso may choose one feature; coefficients are not causal effects. In a panel pipeline, standardization and tuning both take place within the training data. Prediction-layer and portfolio-layer rankings can differ, MSE tuning can favor heavy shrinkage, and turnover determines how costs widen the gap. Always include zero prediction and the training mean in the same table.
15. Exercises
39-E01 (OLS)
Use the X from Section 3 and y=(2,0,2,−4). Compute X⊤y, z, and the OLS coefficients. What is the intercept?
39-E02 (Ridge and Scaling Convention)
Continue from 39-E01. (a) Find the scikit-learn Ridge coefficients at α=2 and α=12. (b) Another package writes Ridge as 2n1∥y−Xw∥2+2λ∥w∥2. What λ is equivalent to scikit-learn α=12?
39-E03 (Bias–Variance)
Let n=250, w=0.05, and σ=1. Find α∗, the bias, variance, and mean squared error at α∗, and compare with OLS.
39-E04 (Lasso Soft Thresholding)
Use the z from 39-E01. Find the Lasso coefficients at α=0.5, 1, and 2. At which α do all coefficients become 0?
39-E05 (Elastic Net)
Continue from 39-E01. Find the Elastic Net coefficients at α=1 with ρ=0.8 and ρ=0.2.
39-E06 (Standardization)
Feature x2 is recorded as a percentage (its recorded values are 100 times the decimal values). Without standardization, how do the OLS and Ridge coefficients and Lasso's selection of x2 change? Which one is unaffected? Explain.
39-E07 (Collinearity)
Two standardized features have correlation r=0.95, with n=100 and σ=1. Find the standard deviation of one OLS coefficient, the VIF, and Ridge shrinkage in the “sum” and “difference” directions at α=10.
39-E08 (Interpreting Coefficients)
Ridge estimates a coefficient of 0.002 for the standardized feature “book-to-market ratio” (5-day return per training standard deviation). The feature's training-set standard deviation is 0.4. (a) Convert this to the coefficient per unit of book-to-market ratio. (b) Give two reasons why this does not justify saying that “increasing book-to-market by 0.4 will raise 5-day return by 0.2%.”
39-T01 (New: Two Units and Two Penalty Terms)
(a) If the unstandardized feature x2 is multiplied by 100, how do its L1 and L2 penalties change when preserving the same predictions? Why does training-set standardization cancel this effect? (b) If decimal return y is multiplied by 100, how must α change for Ridge and Lasso to preserve the scaled predictions? (c) For Elastic Net with original α=0.01 and ρ=0.5, write the α′ and ρ′ that preserve both penalty terms.
39-T02 (New: Own-Date Mean and Paired Difference)
Using the three-day independent constructed example in Section 8.4, write DR, Dm, and DmR, then calculate the two own-date means and the paired difference on the common set. Can counts of valid days alone complete this calculation?
16. Programming Exercises
39-P01 (Regularization Path)
On constructed data with n=120 and 15 standardized features (3 true and 12 noise features), plot the Ridge and Lasso paths. Acceptance checks: (1) all Lasso coefficients are 0 at the largest α; (2) at the smallest α, the maximum absolute difference between the Lasso coefficients and OLS is less than 0.01; (3) report the first nonzero α for every feature; (4) fix the seed and label the axis with the convention used.
39-P02 (Panel Comparison)
Use ml_pipeline to reproduce the Section 8.4 table. Acceptance checks: (1) each fold's training rows satisfy label_available_at ≤ fit_time (read DateFold); (2) zero prediction and the training mean have total portfolio return 0; (3) for the same predictions, after-cost NAV is no higher than before-cost NAV; when fees are positive and the wealth factor is positive, the path endpoint must be strictly lower; the zero/mean cash baselines must be equal; (4) output the hyperparameters for every fold; (5) without changing any settings, rerun with seed 3905 and report whether the conclusion changes (retain the result and do not select a seed).
17. Challenge Problems
39-C01 (Ridge and Lasso under Perfect Collinearity)
Two features are identical (x1=x2=x, with x⊤x=n). Let α>0. (1) Prove that the Ridge solution is unique and that w^1=w^2=2n+αx⊤y. (2) Prove that the Lasso solution set is a line segment and write it out. (3) Is the Elastic Net solution unique when α(1−ρ)>0? What if α=0? Additional prerequisite: Chapter 9 convexity. Scoring: one-third each for parts (1), (2), and (3).
39-C02 (Tune on MSE or IC?)
In Section 8.4, Ridge selects α using inner validation MSE and often selects the largest value. Design a tuning scheme that uses mean daily Spearman IC on the inner validation set as its criterion. (a) Explain how it differs from the MSE criterion under the mechanism in Section 6.7. (b) Identify risks from the new criterion (for example, more selection opportunities or sensitivity to a few dates). (c) Explain how to compare the two criteria without looking at the outer test. This is an open-ended question; the scoring guide is in Section 18.
39-C03 (Date and Legacy t-Statistic Display Diagnostic)
Ridge, Lasso, and Elastic Net have 750, 441, and 624 valid dates, respectively, but only summary data. Can their IC means be compared directly? Can P06 predictions fill in paired evidence for this chapter? If the valid trading-sequence indices are 0, 2, 3, 5, and 8, which two days does the fourth observation lag after dropping missing values connect?
18. Solutions and Solution Hints
39-E01
For X⊤y, the first column gives 2+0−2+4=4 and the second gives 2−0+2+4=8. Thus z=(1,2) and OLS is (1,2). yˉ=0, so the intercept is 0.
39-E02
(a) 4+α4z: at α=2, (0.6667,1.3333); at α=12, (0.25,0.5). (b) Multiplying 2n1∥y−Xw∥2+2λ∥w∥2 by 2n gives ∥y−Xw∥2+nλ∥w∥2, so nλ=α, and λ=12/4=3.
39-E03
α∗=1/0.0025=400. Bias =−650400×0.05=−0.03077; squared bias is 0.000947; variance is 250/6502=0.000592; MSE is 0.001538 =1/650. OLS is 1/250=0.004. Shrinkage lowers MSE to 38% of OLS, at the cost of an estimate whose expectation is only 38% of the true value (250/650).
39-E04
z=(1,2). At α=0.5: (0.5,1.5); at α=1: (0,1); at α=2: (0,0). All coefficients are 0 when α≥max∣zj∣=2.
39-E05
At ρ=0.8: S(z,0.8)/(1+0.2)=(0.2,1.2)/1.2=(0.1667,1). At ρ=0.2: S(z,0.2)/(1+0.8)=(0.8,1.8)/1.8=(0.4444,1).
39-E06
OLS: if the training design has full column rank, the x2 coefficient is divided by 100, while predictions stay the same (Chapter 38, Section 6.3). If the design is exactly collinear (rank deficient), the software's default minimum-norm solution changes with the units, and predictions for new points can differ. Ridge: the penalty on x2 becomes relatively weaker (the same prediction contribution needs only 1/100 of the coefficient), so x2 is shrunk less and predictions change. Lasso: similarly, x2 becomes easier to select and x1 relatively easier to remove. Only OLS with full column rank is unaffected. After standardizing on the training rows, all three are invariant to the recording units.
39-E07
VIF =1/(1−0.9025)=10.26; OLS coefficient standard deviation 10.26/100=0.320 (0.1 under orthogonality). In the “sum” direction, Ridge shrinks by n(1+r)+αn(1+r)=205195=0.951; in the “difference” direction, by 155=0.333.
39-E08
(a) 0.002/0.4=0.005 per unit. (b) Any two: the coefficient is a conditional linear prediction in the training distribution, not an intervention effect; book-to-market may proxy for omitted risk or other features (collinearity); Ridge has shrunk the coefficient toward 0, so its magnitude depends on α; or “increasing by 0.4” may coincide with changes in other features in the data.
39-P01
Reference implementation: code/ch39_regularized_models.py::path_data. In the book's run, the first-entry α values for the first three true features under Lasso are 0.4954, 0.4954, and 0.2454; the first three coefficients at the smallest α are 0.508, 0.501, and −0.263. Complete reference method: use a fixed seed-3903 generator, first draw 120 × 15 independent normal features and standardize them on this training set, set the first three loadings to (0.6,0.4,−0.3) and the rest to 0, add noise with standard deviation 1, and center y. Fit Lasso on a decreasing 60-point grid from 100 to 10−3 and Ridge on a 60-point grid from 10−1 to 104; fit each grid on the same X,y and plot each coefficient column. Coordinate descent for Lasso can update wj←S(xj⊤(y−Xw+xjwj)/n,α)/(xj⊤xj/n), iterating until both coefficient changes and KKT residuals meet tolerance; alternatively, call lasso_path. Assertions and output:
Distinguish the three true features from the twelve noise features in the legend, label each horizontal axis with its estimator's convention, and save the maximum/minimum grid endpoints and nonzero tolerance. This gives the method; the historical path was not rerun.
39-P02
Reference implementation: panel_case and backtest_predictions. The full procedure below is provided for a future explicitly authorized experiment; this batch does not run a 3904 retraining or seed 3905.
Fix every constructed parameter from Section 8.4; run simulate_return_panel → make_forward_labels(horizon=5,execution_lag=1) → combine price_features and characteristics → stack_features; verify the 46 columns.
Call date_walk_forward on the same label table (504/63 dates), saving each fold's fit_time, train_rows, and test_rows. Assert that each training label is mature, each training signal date precedes the fit date, and no training label interval overlaps any test label interval (overlap among five-day label intervals within the training set or within the test set is allowed).
Use the fixed six-model grids from Section 8.4; call walk_forward_predict(...,inner_val_dates=63,inner_folds=2,inner_min_train_dates=252) for each model; save row-level predictions and each fold's chosen_params, then calculate the two baseline R2 values, each model's valid IC date set, and common date sets.
For each model, use the same predictions in backtest_predictions(close,pred,rebalance_every=5,fee_rate=0.0) and with fee 0.001; compare NAV on identical dates, costs, and turnover. Zero and training-mean predictions should have total return 0; the after-cost endpoint should be lower on paths with nonzero fees and actual trades, and equal when there is no trading. Each path must have N+1 wealth points for N daily returns.
Preserve all settings exactly, then change only the seed to 3905, save in a separate unique directory, and retain both positive and negative results and parameter choices; do not return later to select a favorable seed. This new run has a new identity and cannot fill in the missing 3904 historical rows. Report its results whatever they are. If authorization to run has not been granted, as in this batch, record “not run” and do not invent results.
Use the tests beginning with test_host_backtest in tests/test_ml_pipeline.py. Displayed numbers are in Section 8.4; the own-date IC counts of 750/441/624 are from the frozen summary. Common dates and paired means could not be recomputed; the old compressed-index NW t-statistic is not a four-trading-day HAC result. Do not retrain to fabricate historical rows. Fold hyperparameters are saved in ch39_results.json. Step (5) must be reported whether its result is favorable or not.
39-C01 Reference Proof
(1) The objective is ∥y−(w1+w2)x∥2+α(w12+w22). Let s=w1+w2. For fixed s, w12+w22 is minimized at w1=w2=s/2, so the optimal solution is an equal split. Minimizing ∥y−sx∥2+αs2/2 over s then gives s=2n+α2x⊤y and w^j=2n+αx⊤y. The objective is strictly convex, so the solution is unique. (2) The Lasso objective depends only on s and ∣w1∣+∣w2∣; for same-sign coefficients, ∣w1∣+∣w2∣=∣s∣. The optimal s∗=S(x⊤y/n,α), and the solution set is {(w1,w2):w1+w2=s∗,w1w2≥0}, a line segment. When s∗=0, it collapses to a point. Here α>0 ensures that opposite-sign allocations increase the L1 cost; when α=0, all allocations summing to x⊤y/n are optimal, including opposite-sign allocations, so the set is a full line. (3) When α(1−ρ)>0, the L2 term makes the objective strictly convex, so the solution is unique and splits equally. ρ<1 alone does not guarantee uniqueness when α=0.
39-C02 (Tune on MSE or IC?) Scoring Guide
Full credit: 10 points. (a) State that MSE penalizes magnitude and calibration errors, while IC uses cross-sectional ranks; even when common positive scaling preserves ranks, the criteria may prefer different strengths: 3 points. (b) Identify at least two risks of the new criterion, such as high daily IC noise, selection bias from more choices, or non-unique choices when IC is insensitive to strength (tie-breaking): 3 points. (c) Compare the two criteria without looking at the outer test, using the same “select then evaluate” process on inner folds (for example, with a second-level holdout on the last portion of the outer training data), or freeze the criterion in advance: 4 points. Using the outer test to compare the criteria loses 4 points.
39-C03 Complete Answer
Do not treat own-date IC means calculated over different date sets as a paired advantage on common dates. Define the valid sets Dm and Dm∩DR, then calculate both models' means and their difference on the common set. With summary data alone, these paired quantities could not be recomputed. P06 is a different experiment and cannot substitute. After missing dates are dropped, the fourth-observation lag connects trading-sequence index 8 to index 0, an 8-trading-day gap; this is not four-trading-day HAC. The old t-statistic remains in the old accepted summary, but is not presented as new inference; do not retrain to fabricate historical rows.
39-T01 Complete Answer
(a) The original slope b2 is divided by 100, so L1 becomes 1/100 and L2 becomes 1/10,000 of their original values. The training standard deviation s2 is multiplied by 100, so the standardized coefficient w2=s2b2 is unchanged and the penalty is unchanged. (b) Ridge's objective and penalty are both multiplied by 10,000, so α is unchanged. Lasso's loss is multiplied by 10,000 but ∣w∣ only by 100, so α′=100α. (c) Elastic Net: α′=0.01(0.5+100×0.5)=0.505, ρ′=50/50.5=100/101. Check that α′ρ′=0.5=100αρ and α′(1−ρ′)=0.005=α(1−ρ). The original-unit L1 and L2 coefficients after scaling meet the required equivalences; no new model fit is needed.
39-T02 Complete Answer
DR={1,2,3}, Dm={1,3}, and DmR={1,3}. Ridge's own-date mean is (0.1+0.9+0.2)/3=0.4; m's own-date mean is (0.2+0.3)/2=0.25. On the common set, Ridge's mean is 0.15 and m's is 0.25; the paired difference is ΔmR=[(0.2−0.1)+(0.3−0.2)]/2=0.10. The counts give neither the date membership nor the values on those dates, so they cannot yield a paired difference. The historical row-level gap in this chapter remains unrecomputed; P06 cannot replace those data.
19. Further Reading
Must know: Chapter 8 (OLS, standardization, regularization selection for a single series) and Chapter 38 (the pipeline).
Must know: scikit-learn 1.9.1 documentation for Ridge, Lasso, and ElasticNet (references CH08_DOC_08–CH08_DOC_10); read the objective functions and descriptions of alpha and l1_ratio.
Should know: Hastie, Tibshirani, and Friedman, The Elements of Statistical Learning, 2nd ed., Section 3.4 (reference ESL_2ND_ED): singular-value shrinkage for Ridge, Lasso, and L1/L2 geometry.
Should know: the grouping effect in Theorem 1 of Zou and Hastie (2005) (reference CH08_DOC_17); coordinate descent and regularization paths in Friedman, Hastie, and Tibshirani (2010) (reference CH39_FHT2010).
Should know: Section 2.2 and Table 1 of Gu, Kelly, and Xiu (2020) (reference CH37_GKX2020): out-of-sample comparisons of linear, regularized, and nonlinear models for large-scale stock prediction.
Optional: the original papers by Hoerl and Kennard (1970) and Tibshirani (1996) (references CH08_DOC_15 and CH08_DOC_16, registered in Chapter 8 as publisher records).
20. References
CH08_DOC_08, CH08_DOC_09, CH08_DOC_10: scikit-learn Ridge, Lasso, and ElasticNet. The author checked the three objective functions in the docstrings for local scikit-learn 1.9.1 (see source_notes).
ESL_2ND_ED: Hastie, T., Tibshirani, R., and Friedman, J. (2009). The Elements of Statistical Learning, 2nd ed., Section 3.4; the reconnaissance report records reading Equations (3.41), (3.44), and (3.47), Table 3.4, and Figure 3.11; the author did not reopen the book (the download page requires browser interaction). The derivations in Sections 6.1–6.5 are internally consistent and were checked with the Section 8.1 code.
CH08_DOC_17: Zou, H., and Hastie, T. (2005). “Regularization and variable selection via the elastic net.” JRSS-B 67(2), 301–320. The grouping effect in Theorem 1 was verified in the reconnaissance report.
CH39_FHT2010: Friedman, J., Hastie, T., and Tibshirani, R. (2010). “Regularization Paths for Generalized Linear Models via Coordinate Descent.” Journal of Statistical Software 33(1), 1–22. The reconnaissance report records reading Sections 1–2.
CH37_GKX2020: Gu, Kelly, and Xiu (2020), Equation (19), p. 2249, and Table 1, p. 2250, read by the author.