linreg-core
A lightweight, self-contained linear regression library written in Rust. Compiles to WebAssembly for browser use, Python bindings via PyO3, a native Windows DLL for Excel VBA, an Excel XLL add-in with 27 worksheet UDFs, or runs as a native Rust crate.
Key design principle: All linear algebra and statistical distribution functions are implemented from scratch — no external math libraries required. This keeps binary sizes small and makes the crate highly portable.
Live Demo Link
Table of Contents
| Section | Description |
|---|---|
| Features | Regression methods, model statistics, feature importance, diagnostic tests |
| Rust Usage | Native Rust crate usage |
| WebAssembly Usage | Browser/JavaScript usage |
| Python Usage | Python bindings via PyO3 |
| VBA / Excel Usage | Excel VBA via native Windows DLL |
| Excel XLL Add-in | Native Excel worksheet UDFs |
| Feature Flags | Build configuration options |
| Validation | Testing and verification |
| Implementation Notes | Technical details |
Features
Regression Methods
- OLS Regression: Coefficients, standard errors, t-statistics, p-values, confidence intervals, model selection criteria (AIC, BIC, log-likelihood)
- Ridge Regression: L2-regularized regression with optional standardization, effective degrees of freedom, model selection criteria
- Lasso Regression: L1-regularized regression via coordinate descent with automatic variable selection, convergence tracking, model selection criteria
- Elastic Net: Combined L1 + L2 regularization for variable selection with multicollinearity handling, active set convergence, model selection criteria
- Polynomial Regression: Polynomial fitting of any degree with centering/standardization for numerical stability
- LOESS: Locally estimated scatterplot smoothing for non-parametric curve fitting with configurable span, polynomial degree, and robust fitting
- WLS (Weighted Least Squares): Regression with observation weights for heteroscedastic data, includes confidence intervals
- Prediction Intervals: Uncertainty bounds for individual future observations (OLS, Ridge, Lasso, Elastic Net)
- K-Fold Cross Validation: Model evaluation and hyperparameter tuning for all regression types (OLS, Ridge, Lasso, Elastic Net) with customizable folds, shuffling, and seeding
- Lambda Path Generation: Create regularization paths for cross-validation
- Model Serialization: Save/load trained models to/from JSON for all model types
Model Statistics
- Fit Metrics: R-squared, Adjusted R-squared, F-statistic, F-test p-value
- Error Metrics: Mean Squared Error (MSE), Root Mean Squared Error (RMSE), Mean Absolute Error (MAE)
- Model Selection: Log-likelihood, AIC (Akaike Information Criterion), BIC (Bayesian Information Criterion)
- Residuals: Raw residuals, standardized residuals, fitted values, leverage (hat matrix diagonal)
- Multicollinearity: Variance Inflation Factor (VIF) for each predictor
Feature Importance
- Standardized Coefficients: Coefficients scaled by standard deviation for cross-variable comparison
- SHAP Values: Exact SHAP (Shapley Additive Explanations) for linear models — local and global importance
- Permutation Importance: Performance drop when feature values are randomly shuffled
- VIF Ranking: Automatic multicollinearity assessment with interpretation guidance
Diagnostic Tests
| Category | Tests |
|---|---|
| Linearity | Rainbow Test, Harvey-Collier Test, RESET Test |
| Heteroscedasticity | Breusch-Pagan (Koenker variant), White Test (R & Python methods) |
| Normality | Jarque-Bera, Shapiro-Wilk (n ≤ 5000), Anderson-Darling |
| Autocorrelation | Durbin-Watson, Breusch-Godfrey (higher-order) |
| Multicollinearity | Variance Inflation Factor (VIF) |
| Influence | Cook's Distance, DFBETAS, DFFITS |
Rust Usage
Add to your Cargo.toml:
[]
= { = "0.8", = false }
OLS Regression (Rust)
use ols_regression;
Ridge Regression (Rust)
use ;
use Matrix;
Lasso Regression (Rust)
use ;
use Matrix;
Elastic Net Regression (Rust)
use ;
use Matrix;
Polynomial Regression (Rust)
use ;
Feature Importance (Rust)
use ;
Diagnostic Tests (Rust)
use ;
WLS Regression (Rust)
use wls_regression;
LOESS Regression (Rust)
use ;
Custom LOESS options:
use ;
let options = LoessOptions ;
let result = loess_fit?;
K-Fold Cross Validation (Rust)
Cross-validation is used for model evaluation and hyperparameter tuning. The library supports K-Fold CV for all regression types:
use ;
CV Result fields:
mean_rmse,std_rmse- Mean and std of RMSE across foldsmean_mae,std_mae- Mean and std of MAE across foldsmean_r_squared,std_r_squared- Mean and std of R² across foldsmean_train_r_squared- Mean training R² (for overfitting detection)fold_results- Per-fold metrics (train/test sizes, MSE, RMSE, MAE, R²)fold_coefficients- Coefficients from each fold (for stability analysis)
Lambda Path Generation (Rust)
use ;
use Matrix;
let x = new;
let y = vec!;
let options = LambdaPathOptions ;
let lambdas = make_lambda_path;
for &lambda in lambdas.iter
Model Save/Load (Rust)
All trained models can be saved to disk and loaded back later:
use ;
// Train a model
let result = ols_regression?;
// Save to file
result.save?;
// Or with a custom name
result.save_with_name?;
// Load back
let loaded = load?;
The same save() and load() methods work for all model types: RegressionOutput, RidgeFit, LassoFit, ElasticNetFit, WlsFit, and LoessFit.
WebAssembly Usage
Build with wasm-pack:
OLS Regression (WASM)
import init from './pkg/linreg_core.js';
;
Ridge Regression (WASM)
const result = JSON.;
console.log;
console.log;
console.log;
console.log;
console.log;
Lasso Regression (WASM)
const result = JSON.;
console.log;
console.log;
console.log;
console.log;
Elastic Net Regression (WASM)
const result = JSON.;
console.log;
console.log;
console.log;
console.log;
Lambda Path Generation (WASM)
const path = JSON.;
console.log;
console.log;
WLS Regression (WASM)
const result = JSON.;
console.log;
console.log;
console.log;
console.log;
console.log;
console.log;
console.log;
LOESS Regression (WASM)
const result = JSON.;
console.log;
console.log;
K-Fold Cross Validation (WASM)
// OLS cross-validation
const ols_cv = JSON.;
console.log;
console.log;
// Ridge cross-validation
const ridge_cv = JSON.;
// Lasso cross-validation
const lasso_cv = JSON.;
// Elastic Net cross-validation
const enet_cv = JSON.;
// Access per-fold results
ols_cv..;
Note: In WASM, boolean and seed parameters are passed as JSON strings. Use "true"/"false" for shuffle and "42" or "null" for seed.
Diagnostic Tests (WASM)
// Rainbow test
const rainbow = JSON.;
// Harvey-Collier test
const hc = JSON.;
// Breusch-Pagan test
const bp = JSON.;
// White test (method selection: "r", "python", or "both")
const white = JSON.;
// White test - R-specific method
const whiteR = JSON.;
// White test - Python-specific method
const whitePy = JSON.;
// Jarque-Bera test
const jb = JSON.;
// Durbin-Watson test
const dw = JSON.;
// Shapiro-Wilk test
const sw = JSON.;
// Anderson-Darling test
const ad = JSON.;
// Cook's Distance
const cd = JSON.;
// DFBETAS (influence on coefficients)
const dfbetas = JSON.;
// DFFITS (influence on fitted values)
const dffits = JSON.;
// VIF test (multicollinearity)
const vif = JSON.;
console.log;
// RESET test (functional form)
const reset = JSON.;
// Breusch-Godfrey test (higher-order autocorrelation)
const bg = JSON.;
Statistical Utilities (WASM)
// Student's t CDF: P(T <= t)
const tCDF = ;
// Critical t-value for two-tailed test
const tCrit = ;
// Normal inverse CDF (probit)
const zScore = ;
// Descriptive statistics (all return JSON strings)
const mean = JSON.;
const variance = JSON.;
const stddev = JSON.;
const median = JSON.;
const quantile = JSON.;
const correlation = JSON.;
CSV Parsing (WASM)
const csv = ;
const parsed = JSON.;
console.log;
console.log;
Helper Functions (WASM)
const version = ; // e.g., "0.5.0"
const msg = ; // "Rust WASM is working!"
Model Serialization (WASM)
// Train a model
const resultJson = ;
const result = JSON.;
// Serialize with metadata
const serialized = ;
// Get metadata without loading full model
const metadataJson = ;
const metadata = JSON.;
console.log;
console.log;
// Deserialize to get model data back
const modelJson = ;
const model = JSON.;
// Download in browser
const blob = ;
const url = ;
const a = document.;
a. = url;
a. = 'model.json';
a.;
Domain Security (WASM)
Optional domain restriction via build-time environment variable:
LINREG_DOMAIN_RESTRICT=example.com,mysite.com
When NOT set (default), all domains are allowed.
Python Usage
Install from PyPI:
Quick Start (Python)
The recommended way to use linreg-core in Python is with native types (lists or numpy arrays):
# Works with Python lists
=
=
=
=
# Access attributes directly
# Get a formatted summary
With NumPy arrays:
=
=
=
Result objects provide:
- Direct attribute access (
result.r_squared,result.coefficients,result.aic,result.bic,result.log_likelihood) summary()method for formatted outputto_dict()method for JSON serialization
OLS Regression (Python)
=
=
=
=
Ridge Regression (Python)
=
Lasso Regression (Python)
=
Elastic Net Regression (Python)
=
LOESS Regression (Python)
=
Lambda Path Generation (Python)
=
Diagnostic Tests (Python)
# Breusch-Pagan test (heteroscedasticity)
=
# Harvey-Collier test (linearity)
=
# Rainbow test (linearity) - supports "r", "python", or "both" methods
=
# White test - choose method: "r", "python", or "both"
=
# Or use specific method functions
=
=
# Jarque-Bera test (normality)
=
# Durbin-Watson test (autocorrelation)
=
# Shapiro-Wilk test (normality)
=
# Anderson-Darling test (normality)
=
# Cook's Distance (influential observations)
=
# DFBETAS (influence on each coefficient)
=
# DFFITS (influence on fitted values)
=
# RESET test (model specification)
=
# Breusch-Godfrey test (higher-order autocorrelation)
=
Statistical Utilities (Python)
# Student's t CDF
=
# Critical t-value (two-tailed)
=
# Normal inverse CDF (probit)
=
# Library version
=
Descriptive Statistics (Python)
# All return float directly (no parsing needed)
=
=
=
=
=
=
# Works with numpy arrays too
=
CSV Parsing (Python)
=
=
Model Save/Load (Python)
# Train a model
=
# Save to file
# Load back
=
The save_model() and load_model() functions work with all result types: OLSResult, RidgeResult, LassoResult, ElasticNetResult, LoessResult, and WlsResult.
VBA / Excel Usage
The library ships as a native Windows DLL, letting you call it directly from Excel VBA via Declare statements. Prebuilt binaries are included in the VBA_Example/ directory:
| File | Architecture |
|---|---|
linreg_core_x64.dll |
64-bit Excel (Office 2010+) |
linreg_core_x86.dll |
32-bit Excel (legacy) |
Installation
- Copy
linreg_core_x64.dll(and/orlinreg_core_x86.dll) to the same folder as your.xlsmworkbook. - Import
LinregCore.basinto your VBA project (ALT+F11 → File → Import File). - Optionally import
ExampleMacros.basfor ready-to-run demo macros. Once both files are imported, runSetupWorkbook()from the Immediate Window or a button to automatically create example sheets and load sample data.
Building from Source
# 64-bit (modern Excel)
# 32-bit (legacy Excel)
The 32-bit build automatically uses linreg_core.def to strip stdcall decoration, so VBA Declare statements work without modification.
High-Level Wrappers
LinregCore.bas exposes friendly wrapper functions that return 2D Excel arrays you can drop straight into cells with Application.Transpose:
' OLS regression - returns (k+6)×5 summary array
Dim result As Variant
result = LinReg_OLS(y, X)
' Regularized regression
result = LinReg_Ridge(y, X, lambda:=1.0, standardize:=True)
result = LinReg_Lasso(y, X, lambda:=0.1)
result = LinReg_ElasticNet(y, X, lambda:=0.1, alpha:=0.5)
' Weighted OLS
result = LinReg_WLS(y, X, weights)
' Prediction intervals (n_new × 4: predicted, lower, upper, SE)
result = LinReg_PredictionIntervals(y, X, newX, alpha:=0.05)
' Diagnostic tests - each returns 1×3: {statistic, p-value, df}
result = LinReg_BreuschPagan(y, X)
result = LinReg_White(y, X)
result = LinReg_JarqueBera(y, X)
result = LinReg_ShapiroWilk(y, X)
result = LinReg_AndersonDarling(y, X)
result = LinReg_HarveyCollier(y, X)
result = LinReg_Rainbow(y, X, fraction:=0.5)
result = LinReg_Reset(y, X)
result = LinReg_DurbinWatson(y, X) ' {DW statistic, ρ, ""}
result = LinReg_BreuschGodfrey(y, X, lagOrder:=1)
' Influence diagnostics
result = LinReg_VIF(y, X) ' p×1
result = LinReg_CooksDistance(y, X) ' n×1
result = LinReg_DFFITS(y, X) ' n×1
result = LinReg_DFBETAS(y, X) ' (n+1)×(p+1) with header row/col
' Regularization path and cross-validation
result = LinReg_LambdaPath(y, X, nLambda:=100, lmr:=0.01, alpha:=1.0)
result = LinReg_KFoldOLS(y, X, nFolds:=5) ' 1×6 CV metrics
result = LinReg_KFoldRidge(y, X, lambda:=1.0)
result = LinReg_KFoldLasso(y, X, lambda:=0.1)
result = LinReg_KFoldElasticNet(y, X, lambda:=0.1, alpha:=0.5)
All wrappers return a 1-element array containing an error string on failure:
If IsArray(result) And UBound(result, 1) = 0 Then
MsgBox "Error: " & result(0)
Exit Sub
End If
Low-Level Handle API
The DLL uses an opaque handle pattern. All LR_* functions return a usize handle (0 = error); call LR_Free when done:
' --- declarations already in LinregCore.bas ---
' Private Declare PtrSafe Function LR_OLS Lib "linreg_core_x64.dll" ...
' Private Declare PtrSafe Sub LR_Free Lib "linreg_core_x64.dll" ...
Sub LowLevelExample()
Dim n As Long, p As Long
n = 5 : p = 1
Dim y(4) As Double
y(0) = 2.5 : y(1) = 3.7 : y(2) = 4.2 : y(3) = 5.1 : y(4) = 6.3
' X is row-major, no intercept column (added automatically)
Dim X(4) As Double
X(0) = 1 : X(1) = 2 : X(2) = 3 : X(3) = 4 : X(4) = 5
Dim h As LongPtr
h = LR_OLS(VarPtr(y(0)), n, VarPtr(X(0)), n, p)
If h = 0 Then
MsgBox "Regression failed"
Exit Sub
End If
Dim r2 As Double, mse As Double
r2 = LR_GetRSquared(h)
mse = LR_GetMSE(h)
' Retrieve coefficient vector (intercept + slopes = p+1 values)
Dim coefs(1) As Double
LR_GetCoefficients h, VarPtr(coefs(0)), p + 1
Debug.Print "R²=" & r2 & " MSE=" & mse
Debug.Print "Intercept=" & coefs(0) & " Slope=" & coefs(1)
LR_Free h
End Sub
Key FFI Functions
| Category | Functions |
|---|---|
| Lifecycle | LR_Init, LR_Free, LR_GetLastError, LR_Version |
| Regression | LR_OLS, LR_Ridge, LR_Lasso, LR_ElasticNet, LR_WLS |
| Predictions | LR_PredictionIntervals |
| Diagnostics | LR_BreuschPagan, LR_White, LR_JarqueBera, LR_ShapiroWilk, LR_AndersonDarling, LR_HarveyCollier, LR_Rainbow, LR_Reset, LR_DurbinWatson, LR_BreuschGodfrey |
| Influence | LR_CooksDistance, LR_DFFITS, LR_DFBETAS, LR_VIF |
| Path / CV | LR_LambdaPath, LR_KFoldOLS, LR_KFoldRidge, LR_KFoldLasso, LR_KFoldElasticNet |
| Scalar getters | LR_GetRSquared, LR_GetAdjRSquared, LR_GetFStatistic, LR_GetFPValue, LR_GetMSE, LR_GetIntercept, LR_GetDF, LR_GetNNonzero, LR_GetStatistic, LR_GetPValue, LR_GetTestDF, LR_GetAutocorrelation |
| Vector getters | LR_GetCoefficients, LR_GetStdErrors, LR_GetTStats, LR_GetPValues, LR_GetResiduals, LR_GetFittedValues, LR_GetVector, LR_GetMatrix, LR_GetPredicted, LR_GetLowerBound, LR_GetUpperBound, LR_GetSEPred |
Running FFI Tests
Excel XLL Add-in
The library also compiles as a native Excel XLL add-in, exposing 27 worksheet UDFs directly in Excel. No VBA, no macros — just type =LINREG.OLS(A1:A20, B1:E20) in a cell.
The XLL is built entirely in pure Rust with zero external dependencies. No Excel SDK linkage required.
Installation
- Build (or obtain)
linreg_core_xll_x64.xll - In Excel: File > Options > Add-ins > Manage: Excel Add-ins > Go
- Browse to the
.xllfile and check the box - Type
=LINREG.VERSION()in any cell to verify
Building from Source
Available UDFs
| Formula | Description |
|---|---|
=LINREG.VERSION() |
Library version string |
=LINREG.OLS(y, X) |
OLS regression — coefficient table + fit stats |
=LINREG.WLS(y, X, weights) |
Weighted Least Squares |
=LINREG.RIDGE(y, X, lambda, [standardize]) |
Ridge regression |
=LINREG.LASSO(y, X, lambda, [standardize]) |
Lasso regression |
=LINREG.ELASTICNET(y, X, lambda, alpha, [standardize]) |
Elastic Net |
=LINREG.POLYNOMIAL(y, x, [degree], [center]) |
Polynomial regression |
=LINREG.LAMBDAPATH(y, X, [n_lambda], [alpha]) |
Lambda path generation |
=LINREG.KFOLDOLS(y, X, [n_folds]) |
K-Fold CV (OLS) |
=LINREG.KFOLDRIDGE(y, X, lambda, [n_folds], [standardize]) |
K-Fold CV (Ridge) |
=LINREG.KFOLDLASSO(y, X, lambda, [n_folds], [standardize]) |
K-Fold CV (Lasso) |
=LINREG.KFOLDELASTICNET(y, X, lambda, alpha, [n_folds], [standardize]) |
K-Fold CV (Elastic Net) |
=LINREG.PREDICTIONINTERVALS(y, X, newX, [alpha]) |
Prediction intervals |
=LINREG.BREUSCHPAGAN(y, X) |
Breusch-Pagan heteroscedasticity test |
=LINREG.WHITE(y, X) |
White heteroscedasticity test |
=LINREG.JARQUEBERA(y, X) |
Jarque-Bera normality test |
=LINREG.SHAPIROWILK(y, X) |
Shapiro-Wilk normality test |
=LINREG.ANDERSONDARLING(y, X) |
Anderson-Darling normality test |
=LINREG.HARVEYCOLLIER(y, X) |
Harvey-Collier linearity test |
=LINREG.RAINBOW(y, X, [fraction]) |
Rainbow linearity test |
=LINREG.RESET(y, X) |
RESET specification test |
=LINREG.DURBINWATSON(y, X) |
Durbin-Watson autocorrelation test |
=LINREG.BREUSCHGODFREY(y, X, [lag_order]) |
Breusch-Godfrey autocorrelation test |
=LINREG.VIF(y, X) |
Variance Inflation Factors |
=LINREG.COOKSDISTANCE(y, X) |
Cook's Distance |
=LINREG.DFFITS(y, X) |
DFFITS influence measure |
=LINREG.DFBETAS(y, X) |
DFBETAS influence measure |
All UDFs return dynamic arrays that spill automatically in Excel 365. In older versions, use Ctrl+Shift+Enter (CSE). Each function includes per-argument help visible in the Function Wizard (fx button).
Running XLL Tests
Feature Flags
| Feature | Default | Description |
|---|---|---|
wasm |
Yes | Enables WASM bindings and browser support |
python |
No | Enables Python bindings via PyO3 |
ffi |
No | Enables Windows DLL bindings for VBA/Excel use |
xll |
No | Enables Excel XLL add-in (27 worksheet UDFs) |
validation |
No | Includes test data for validation tests |
For native Rust without WASM overhead:
= { = "0.8", = false }
For Python bindings (built with maturin):
Validation
Results are validated against R (lmtest, car, skedastic, nortest, glmnet) and Python (statsmodels, scipy, sklearn). See the verification/ directory for test scripts and reference outputs.
Running Tests
# Unit tests
# WASM tests
# FFI tests (VBA/C bindings)
# Python tests (requires maturin build)
# All tests including doctests
Implementation Notes
Regularization
The Ridge and Lasso implementations follow the glmnet formulation:
minimize (1/(2n)) * Σ(yᵢ - β₀ - xᵢᵀβ)² + λ * [(1 - α) * ||β||₂² / 2 + α * ||β||₁]
- Ridge (α = 0): Closed-form solution with (X'X + λI)⁻¹X'y
- Lasso (α = 1): Coordinate descent algorithm
Numerical Precision
- QR decomposition used throughout for numerical stability
- Anderson-Darling uses Abramowitz & Stegun 7.1.26 for normal CDF (differs from R's Cephes by ~1e-6)
- Shapiro-Wilk implements Royston's 1995 algorithm matching R's implementation
Known Limitations
- Harvey-Collier test may fail on high-VIF datasets (VIF > 5) due to numerical instability in recursive residuals
- Shapiro-Wilk limited to n <= 5000 (matching R's limitation)
- White test may differ from R on collinear datasets due to numerical precision in near-singular matrices
Disclaimer
This library is under active development and has not reached 1.0 stability. While outputs are validated against R and Python implementations, do not use this library for critical applications (medical, financial, safety-critical systems) without independent verification. See the LICENSE for full terms. The software is provided "as is" without warranty of any kind.
Benchmarks
Benchmark results run on Windows with cargo bench --no-default-features. Times are median values.
Core Regression Benchmarks
| Benchmark | Size (n × p) | Time | Throughput |
|---|---|---|---|
| OLS Regression | 10 × 2 | 12.46 µs | 802.71 Kelem/s |
| OLS Regression | 50 × 3 | 53.72 µs | 930.69 Kelem/s |
| OLS Regression | 100 × 5 | 211.09 µs | 473.73 Kelem/s |
| OLS Regression | 500 × 10 | 7.46 ms | 67.04 Kelem/s |
| OLS Regression | 1000 × 20 | 47.81 ms | 20.91 Kelem/s |
| OLS Regression | 5000 × 50 | 2.86 s | 1.75 Kelem/s |
| Ridge Regression | 50 × 3 | 9.61 µs | 5.20 Melem/s |
| Ridge Regression | 100 × 5 | 70.41 µs | 1.42 Melem/s |
| Ridge Regression | 500 × 10 | 842.37 µs | 593.56 Kelem/s |
| Ridge Regression | 1000 × 20 | 1.38 ms | 724.71 Kelem/s |
| Ridge Regression | 5000 × 50 | 10.25 ms | 487.78 Kelem/s |
| Lasso Regression | 50 × 3 | 258.82 µs | 193.18 Kelem/s |
| Lasso Regression | 100 × 5 | 247.89 µs | 403.41 Kelem/s |
| Lasso Regression | 500 × 10 | 3.58 ms | 139.86 Kelem/s |
| Lasso Regression | 1000 × 20 | 1.54 ms | 651.28 Kelem/s |
| Lasso Regression | 5000 × 50 | 12.52 ms | 399.50 Kelem/s |
| Elastic Net Regression | 50 × 3 | 46.15 µs | 1.08 Melem/s |
| Elastic Net Regression | 100 × 5 | 358.07 µs | 279.27 Kelem/s |
| Elastic Net Regression | 500 × 10 | 1.61 ms | 310.18 Kelem/s |
| Elastic Net Regression | 1000 × 20 | 1.60 ms | 623.66 Kelem/s |
| Elastic Net Regression | 5000 × 50 | 12.57 ms | 397.77 Kelem/s |
| WLS Regression | 50 × 3 | 32.92 µs | 1.52 Melem/s |
| WLS Regression | 100 × 5 | 155.30 µs | 643.93 Kelem/s |
| WLS Regression | 500 × 10 | 6.63 ms | 75.37 Kelem/s |
| WLS Regression | 1000 × 20 | 42.68 ms | 23.43 Kelem/s |
| WLS Regression | 5000 × 50 | 2.64 s | 1.89 Kelem/s |
| LOESS Fit | 50 × 1 | 132.83 µs | 376.42 Kelem/s |
| LOESS Fit | 100 × 1 | 1.16 ms | 86.00 Kelem/s |
| LOESS Fit | 500 × 1 | 28.42 ms | 17.59 Kelem/s |
| LOESS Fit | 1000 × 1 | 113.00 ms | 8.85 Kelem/s |
| LOESS Fit | 100 × 2 | 7.10 ms | 14.09 Kelem/s |
| LOESS Fit | 500 × 2 | 1.05 s | 476.19 elem/s |
Lambda Path & Elastic Net Path Benchmarks
| Benchmark | Size (n × p) | Time | Throughput |
|---|---|---|---|
| Elastic Net Path | 100 × 5 | 198.60 ms | 503.52 elem/s |
| Elastic Net Path | 500 × 10 | 69.46 ms | 7.20 Kelem/s |
| Elastic Net Path | 1000 × 20 | 39.08 ms | 25.59 Kelem/s |
| Make Lambda Path | 100 × 5 | 1.09 µs | 91.58 Melem/s |
| Make Lambda Path | 500 × 10 | 8.10 µs | 61.70 Melem/s |
| Make Lambda Path | 1000 × 20 | 29.96 µs | 33.37 Melem/s |
| Make Lambda Path | 5000 × 50 | 424.18 µs | 11.79 Melem/s |
Diagnostic Test Benchmarks
| Benchmark | Size (n × p) | Time |
|---|---|---|
| Rainbow Test | 50 × 3 | 40.34 µs |
| Rainbow Test | 100 × 5 | 187.94 µs |
| Rainbow Test | 500 × 10 | 8.63 ms |
| Rainbow Test | 1000 × 20 | 60.09 ms |
| Rainbow Test | 5000 × 50 | 3.45 s |
| Harvey-Collier Test | 50 × 1 | 15.26 µs |
| Harvey-Collier Test | 100 × 1 | 30.32 µs |
| Harvey-Collier Test | 500 × 1 | 138.44 µs |
| Harvey-Collier Test | 1000 × 1 | 298.33 µs |
| Breusch-Pagan Test | 50 × 3 | 58.07 µs |
| Breusch-Pagan Test | 100 × 5 | 296.74 µs |
| Breusch-Pagan Test | 500 × 10 | 13.79 ms |
| Breusch-Pagan Test | 1000 × 20 | 96.49 ms |
| Breusch-Pagan Test | 5000 × 50 | 5.56 s |
| White Test | 50 × 3 | 14.31 µs |
| White Test | 100 × 5 | 44.25 µs |
| White Test | 500 × 10 | 669.40 µs |
| White Test | 1000 × 20 | 4.89 ms |
| Jarque-Bera Test | 50 × 3 | 30.13 µs |
| Jarque-Bera Test | 100 × 5 | 149.29 µs |
| Jarque-Bera Test | 500 × 10 | 6.64 ms |
| Jarque-Bera Test | 1000 × 20 | 47.89 ms |
| Jarque-Bera Test | 5000 × 50 | 2.75 s |
| Durbin-Watson Test | 50 × 3 | 31.80 µs |
| Durbin-Watson Test | 100 × 5 | 152.56 µs |
| Durbin-Watson Test | 500 × 10 | 6.87 ms |
| Durbin-Watson Test | 1000 × 20 | 48.65 ms |
| Durbin-Watson Test | 5000 × 50 | 2.76 s |
| Breusch-Godfrey Test | 50 × 3 | 71.73 µs |
| Breusch-Godfrey Test | 100 × 5 | 348.94 µs |
| Breusch-Godfrey Test | 500 × 10 | 14.77 ms |
| Breusch-Godfrey Test | 1000 × 20 | 100.08 ms |
| Breusch-Godfrey Test | 5000 × 50 | 5.64 s |
| Shapiro-Wilk Test | 10 × 2 | 2.04 µs |
| Shapiro-Wilk Test | 50 × 3 | 4.87 µs |
| Shapiro-Wilk Test | 100 × 5 | 10.67 µs |
| Shapiro-Wilk Test | 500 × 10 | 110.02 µs |
| Shapiro-Wilk Test | 1000 × 20 | 635.13 µs |
| Shapiro-Wilk Test | 5000 × 50 | 17.53 ms |
| Anderson-Darling Test | 50 × 3 | 34.02 µs |
| Anderson-Darling Test | 100 × 5 | 162.28 µs |
| Anderson-Darling Test | 500 × 10 | 6.95 ms |
| Anderson-Darling Test | 1000 × 20 | 48.15 ms |
| Anderson-Darling Test | 5000 × 50 | 2.78 s |
| Cook's Distance Test | 50 × 3 | 64.52 µs |
| Cook's Distance Test | 100 × 5 | 297.69 µs |
| Cook's Distance Test | 500 × 10 | 12.73 ms |
| Cook's Distance Test | 1000 × 20 | 94.02 ms |
| Cook's Distance Test | 5000 × 50 | 5.31 s |
| DFBETAS Test | 50 × 3 | 46.34 µs |
| DFBETAS Test | 100 × 5 | 185.52 µs |
| DFBETAS Test | 500 × 10 | 7.04 ms |
| DFBETAS Test | 1000 × 20 | 49.68 ms |
| DFFITS Test | 50 × 3 | 33.56 µs |
| DFFITS Test | 100 × 5 | 157.62 µs |
| DFFITS Test | 500 × 10 | 6.82 ms |
| DFFITS Test | 1000 × 20 | 48.35 ms |
| VIF Test | 50 × 3 | 5.36 µs |
| VIF Test | 100 × 5 | 12.68 µs |
| VIF Test | 500 × 10 | 128.04 µs |
| VIF Test | 1000 × 20 | 807.30 µs |
| VIF Test | 5000 × 50 | 26.33 ms |
| RESET Test | 50 × 3 | 77.85 µs |
| RESET Test | 100 × 5 | 359.12 µs |
| RESET Test | 500 × 10 | 14.40 ms |
| RESET Test | 1000 × 20 | 100.52 ms |
| RESET Test | 5000 × 50 | 5.67 s |
| Full Diagnostics | 100 × 5 | 2.75 ms |
| Full Diagnostics | 500 × 10 | 104.01 ms |
| Full Diagnostics | 1000 × 20 | 740.52 ms |
Linear Algebra Benchmarks
| Benchmark | Size | Time |
|---|---|---|
| Matrix Transpose | 10 × 10 | 209.50 ns |
| Matrix Transpose | 50 × 50 | 3.67 µs |
| Matrix Transpose | 100 × 100 | 14.92 µs |
| Matrix Transpose | 500 × 500 | 924.23 µs |
| Matrix Transpose | 1000 × 1000 | 5.56 ms |
| Matrix Multiply (matmul) | 10 × 10 × 10 | 1.54 µs |
| Matrix Multiply (matmul) | 50 × 50 × 50 | 144.15 µs |
| Matrix Multiply (matmul) | 100 × 100 × 100 | 1.39 ms |
| Matrix Multiply (matmul) | 200 × 200 × 200 | 11.90 ms |
| Matrix Multiply (matmul) | 1000 × 100 × 100 | 13.94 ms |
| QR Decomposition | 10 × 5 | 1.41 µs |
| QR Decomposition | 50 × 10 | 14.81 µs |
| QR Decomposition | 100 × 20 | 57.61 µs |
| QR Decomposition | 500 × 50 | 2.19 ms |
| QR Decomposition | 1000 × 100 | 19.20 ms |
| QR Decomposition | 5000 × 100 | 1.48 s |
| QR Decomposition | 10000 × 100 | 8.09 s |
| QR Decomposition | 1000 × 500 | 84.48 ms |
| SVD | 10 × 5 | 150.36 µs |
| SVD | 50 × 10 | 505.41 µs |
| SVD | 100 × 20 | 2.80 ms |
| SVD | 500 × 50 | 60.00 ms |
| SVD | 1000 × 100 | 513.35 ms |
| Matrix Invert | 5 × 5 | 877.32 ns |
| Matrix Invert | 10 × 10 | 2.48 µs |
| Matrix Invert | 20 × 20 | 5.46 µs |
| Matrix Invert | 50 × 50 | 31.94 µs |
| Matrix Invert | 100 × 100 | 141.38 µs |
| Matrix Invert | 200 × 200 | 647.03 µs |
Pressure Benchmarks (Large Datasets)
| Benchmark | Size (n) | Time |
|---|---|---|
| Pressure (OLS + all diagnostics) | 10000 | 11.28 s |
License
Dual-licensed under MIT or Apache-2.0.