Skip to main content

Module linear

Module linear 

Source
Expand description

Multiple linear regression (ISL ch 3) — ordinary least squares with full inference, solved through the engine’s linear-algebra library (no re-implemented solver) and the statistics distributions (real p-values).

Fit y = β₀ + β₁x₁ + … + β_p x_p by the normal equations (XᵀX)β = Xᵀy, formed with linear_algebra::gemm/matvec and solved (and inverted, for the coefficient standard errors) with linear_algebra::cholesky. Inference — t-tests on each coefficient and the overall F-test — uses statistics::distributions.

Kernel-class: DenseLinear (the GEMM/solve), so it is dispatch-ready against ComputePolicy; for the small p×p normal-equations solve the CPU path is the right one — the GPU win is in forming XᵀX for large n, wired with the bridge.

Structs§

LinearModel
A fitted OLS model with inferential output. When fit_intercept is true, coefficients[0] is the intercept and coefficients[1..] align with the predictor columns; the *_per_coef vectors are aligned the same way.

Functions§

fit
Fit OLS of y (length n) on a row-major n × p predictor matrix x. fit_intercept prepends a constant column. Fails closed: InvalidDimension on a shape mismatch, InsufficientData if n ≤ params, Singular on collinear predictors.