Let . Generate mutually independent standard normal random variables
and define
Center and standardize each column of to have mean zero and average squared value one, following the lectureβs scaling convention.
Continue to use for the standardized matrix and keep it fixed throughout the question, where is the number of predictors. The unpenalized intercept gives total fitted coefficients. Let
Generate a training response and an independent test response at the same predictor values:
where
Center the training response as . For each , fit the slopes using the lectureβs ridge formula:
The unpenalized intercept is ; add this training mean back when predicting either response. The case is ordinary least squares. Use seed 43231 before generating the design and responses. R and Python use different random-number generators, so their exact numerical results need not agree.
Generate once. Report the correlation between its first two columns and its largest and smallest singular values. Use these quantities to explain why the estimator contrast should be much more variable than .
Independently repeat the generation of and , followed by all three fits, 200 times while keeping fixed. Draw the training and test noise inside each repetition, then reuse that realized pair for all three values of . For each value of , report the empirical mean and standard deviation of
Also report the average training MSE and the average test MSE calculated from the independent test response, where
- Interpret the coefficient estimates and test MSE using bias and variance. Explain why ridge can substantially stabilize the individual coefficients without producing an equally large change in the fitted values.