Ridge
Verification
Models
- OLS
- Logistic regression
- Probit regression
- Poisson regression
- Linear mixed model
- Linear mixed model, published data
- Binomial mixed model
- R compatibility
- IV
- Ridge
- Robust covariance
On this page
Numerics
Test suites
Scope
Coefficients, local-face effective df, conditional covariance, fitted values, weighted CV MSE and SE, and lambda selection.
References
- Reference
- glmnet, MASS, lmridge, and independent matrix calculations
- Versions
- R 4.6.1 (2026-06-24), glmnet 5.1, MASS 7.3.65, lmridge 1.2.2
Data
- Inputs
- Twelve fits and six CV cases including weighted day folds over hourly heating rows.
Method
Public glmnet output and independently computed conditional uncertainty, checked in the extension and polyfill.
- Check
- Comparison with a reference implementation
Tolerances
|x − r| ≤ 1e-7 + 2e-6 × |r|
Applies to: Numerical results
x: package value; r: reference value. Absolute error: |x − r|. Max errors are over the values a row compares.
Results
36 comparisons in 18 cases: 36 pass, 0 fail, 0 skipped.
By case
| Case | Comparisons | Largest abs. error | Status |
|---|---|---|---|
| standardized | 2 | 6.3e-11 | pass |
| raw | 2 | 4.5e-13 | pass |
| weighted | 2 | 2.7e-10 | pass |
| no_intercept | 2 | 7.6e-10 | pass |
| no_intercept_raw | 2 | 2.4e-10 | pass |
| unpenalized | 2 | 5.6e-12 | pass |
| bounded | 2 | 1.1e-13 | pass |
| bounded_zero_lambda | 2 | 1.1e-13 | pass |
| factors_interactions | 2 | 7.5e-10 | pass |
| weighted_bounded | 2 | 1.1e-10 | pass |
| missing | 2 | 3.2e-10 | pass |
| heating | 2 | 6.9e-8 | pass |
| cv/small_folds_ungrouped | 2 | 4.6e-8 | pass |
| cv/unequal_folds_and_weights | 2 | 1.7e-12 | pass |
| cv/bounded_weighted | 2 | 2.7e-12 | pass |
| cv/no_intercept | 2 | 3.9e-11 | pass |
| cv/missing_original_rows | 2 | 3.6e-12 | pass |
| cv/day_folds_with_age_weights | 2 | 5.1e-9 | pass |
Every comparison
| Case | Implementation | Quantity | Criterion | Values | Max abs. error | Status |
|---|---|---|---|---|---|---|
| standardized | native | Ridge estimates and CV error | |x − r| ≤ 1e-7 + 2e-6 × |r| | 332 | 6.3e-11 | pass |
| raw | native | Ridge estimates and CV error | |x − r| ≤ 1e-7 + 2e-6 × |r| | 331 | 4.5e-13 | pass |
| weighted | native | Ridge estimates and CV error | |x − r| ≤ 1e-7 + 2e-6 × |r| | 331 | 2.7e-10 | pass |
| no_intercept | native | Ridge estimates and CV error | |x − r| ≤ 1e-7 + 2e-6 × |r| | 319 | 7.6e-10 | pass |
| no_intercept_raw | native | Ridge estimates and CV error | |x − r| ≤ 1e-7 + 2e-6 × |r| | 319 | 2.4e-10 | pass |
| unpenalized | native | Ridge estimates and CV error | |x − r| ≤ 1e-7 + 2e-6 × |r| | 331 | 5.6e-12 | pass |
| bounded | native | Ridge estimates and CV error | |x − r| ≤ 1e-7 + 2e-6 × |r| | 313 | 1.1e-13 | pass |
| bounded_zero_lambda | native | Ridge estimates and CV error | |x − r| ≤ 1e-7 + 2e-6 × |r| | 321 | 1.1e-13 | pass |
| factors_interactions | native | Ridge estimates and CV error | |x − r| ≤ 1e-7 + 2e-6 × |r| | 345 | 7.5e-10 | pass |
| weighted_bounded | native | Ridge estimates and CV error | |x − r| ≤ 1e-7 + 2e-6 × |r| | 321 | 1.1e-10 | pass |
| missing | native | Ridge estimates and CV error | |x − r| ≤ 1e-7 + 2e-6 × |r| | 325 | 3.2e-10 | pass |
| heating | native | Ridge estimates and CV error | |x − r| ≤ 1e-7 + 2e-6 × |r| | 2,125 | 6.9e-8 | pass |
| cv/small_folds_ungrouped | native | Ridge estimates and CV error | |x − r| ≤ 1e-7 + 2e-6 × |r| | 34 | 4.6e-8 | pass |
| cv/unequal_folds_and_weights | native | Ridge estimates and CV error | |x − r| ≤ 1e-7 + 2e-6 × |r| | 34 | 1.7e-12 | pass |
| cv/bounded_weighted | native | Ridge estimates and CV error | |x − r| ≤ 1e-7 + 2e-6 × |r| | 34 | 2.7e-12 | pass |
| cv/no_intercept | native | Ridge estimates and CV error | |x − r| ≤ 1e-7 + 2e-6 × |r| | 34 | 3.9e-11 | pass |
| cv/missing_original_rows | native | Ridge estimates and CV error | |x − r| ≤ 1e-7 + 2e-6 × |r| | 34 | 3.6e-12 | pass |
| cv/day_folds_with_age_weights | native | Ridge estimates and CV error | |x − r| ≤ 1e-7 + 2e-6 × |r| | 29 | 5.1e-9 | pass |
| standardized | polyfill | Ridge estimates and CV error | |x − r| ≤ 1e-7 + 2e-6 × |r| | 332 | 6.3e-11 | pass |
| raw | polyfill | Ridge estimates and CV error | |x − r| ≤ 1e-7 + 2e-6 × |r| | 331 | 4.5e-13 | pass |
| weighted | polyfill | Ridge estimates and CV error | |x − r| ≤ 1e-7 + 2e-6 × |r| | 331 | 2.7e-10 | pass |
| no_intercept | polyfill | Ridge estimates and CV error | |x − r| ≤ 1e-7 + 2e-6 × |r| | 319 | 7.6e-10 | pass |
| no_intercept_raw | polyfill | Ridge estimates and CV error | |x − r| ≤ 1e-7 + 2e-6 × |r| | 319 | 2.4e-10 | pass |
| unpenalized | polyfill | Ridge estimates and CV error | |x − r| ≤ 1e-7 + 2e-6 × |r| | 331 | 5.6e-12 | pass |
| bounded | polyfill | Ridge estimates and CV error | |x − r| ≤ 1e-7 + 2e-6 × |r| | 313 | 1.2e-14 | pass |
| bounded_zero_lambda | polyfill | Ridge estimates and CV error | |x − r| ≤ 1e-7 + 2e-6 × |r| | 321 | 1.1e-13 | pass |
| factors_interactions | polyfill | Ridge estimates and CV error | |x − r| ≤ 1e-7 + 2e-6 × |r| | 345 | 7.5e-10 | pass |
| weighted_bounded | polyfill | Ridge estimates and CV error | |x − r| ≤ 1e-7 + 2e-6 × |r| | 321 | 1.1e-10 | pass |
| missing | polyfill | Ridge estimates and CV error | |x − r| ≤ 1e-7 + 2e-6 × |r| | 325 | 3.2e-10 | pass |
| heating | polyfill | Ridge estimates and CV error | |x − r| ≤ 1e-7 + 2e-6 × |r| | 2,125 | 6.9e-8 | pass |
| cv/small_folds_ungrouped | polyfill | Ridge estimates and CV error | |x − r| ≤ 1e-7 + 2e-6 × |r| | 34 | 4.6e-8 | pass |
| cv/unequal_folds_and_weights | polyfill | Ridge estimates and CV error | |x − r| ≤ 1e-7 + 2e-6 × |r| | 34 | 1.7e-12 | pass |
| cv/bounded_weighted | polyfill | Ridge estimates and CV error | |x − r| ≤ 1e-7 + 2e-6 × |r| | 34 | 2.7e-12 | pass |
| cv/no_intercept | polyfill | Ridge estimates and CV error | |x − r| ≤ 1e-7 + 2e-6 × |r| | 34 | 3.9e-11 | pass |
| cv/missing_original_rows | polyfill | Ridge estimates and CV error | |x − r| ≤ 1e-7 + 2e-6 × |r| | 34 | 3.6e-12 | pass |
| cv/day_folds_with_age_weights | polyfill | Ridge estimates and CV error | |x − r| ≤ 1e-7 + 2e-6 × |r| | 29 | 5.1e-9 | pass |
Limitations
Known differences
- Explicit Gaussian lambda is divided by the weighted response scale to match glmnet output.
- Conditional covariance uses RSS/(n-df); lmridge uses a different residual-variance denominator, so covariance per sigma squared is compared separately.
- Default lambda paths are phit policy; explicit paths are used for glmnet comparisons.
Reproduction
From the repository root
Rscript docs/verifications/ridge.R
python3 docs/verifications/compare_ridge.py
- Raw record
- site/verifications/ridge.json
- Full results
- docs/verifications/ridge-results.json
- Input data
- tests/fixtures/ridge-r.json