3.1 Ordinary least squares (λ = 0)
The elastic net at penalty strength λ = 0 is just ordinary least
squares: with no penalty, the mixing parameter α drops out and glmnet
returns the unregularized fit. It is the natural first model —
We use a noise-free fixture so the answer is unambiguous. Take two predictors
and build the response as an exact linear function of them,
y = 1 + 2 x₁ − x₂, with no error term. Ordinary least squares then
recovers the intercept 1.0 and coefficients (2.0 -1.0) —
(require glmnet)
(provide run-example)
The design matrix is a list of rows; the response is the matching vector. (Rows here, columns there: the binding marshals to the column-major layout the Fortran expects.)
ols is elnet-fit with #:lambda 0.0. The result is an elnet-result carrying the intercept, the dense coefficient vector, the achieved R², and the λ actually used.