Skip to main content

Crate inferust

Crate inferust 

Source
Expand description

§inferust

Statistical modeling for Rust - a statsmodels-inspired library.

§Modules

ModuleContents
regressionOLS/WLS/GLS/FGLS, quantile regression, plus rolling and recursive OLS with fast/stable/HAC solvers, HC0-HC3 and Newey-West SEs, confidence intervals, influence diagnostics, full summary, and Ridge/Lasso/ElasticNet regularization
glmBinary logistic, Poisson, and Gamma regression with Wald inference, LRT, residual diagnostics, prediction intervals, classification metrics
gamGaussian additive models with spline basis expansion
gmmInstrumental variables / 2SLS econometrics starter
survivalKaplan-Meier estimator, log-rank test, Cox proportional hazards regression
statespaceScalar Kalman filter and local-level state-space model
time_seriesARIMA/SARIMA/SARIMAX via CSS or exact state-space MLE, VAR/VECM/VARMAX, AR, ACF/PACF, Ljung-Box, ADF unit root, KPSS stationarity, Granger causality, Engle-Granger cointegration
hypothesist-tests, chi-squared, ANOVA, Tukey HSD post-hoc, multiple-testing corrections (Bonferroni/Holm/BH/BY), Mann-Whitney U, Kruskal-Wallis, Wilcoxon signed-rank, sign test, KS tests, Shapiro-Wilk, Anderson-Darling, Lilliefors, Wald linear-restriction tests
contingency2x2 tables, odds/risk ratios, McNemar, CMH
diagnosticsVIF, Breusch-Pagan, White, and RESET diagnostics
discreteProbit, ordered logit, negative binomial, multinomial logit, and zero-inflated Poisson
glm_familyGeneric Gaussian/Binomial/Poisson/Gamma GLM front-end
multivariateMANOVA and PCA starters
imputationMean imputation and MICE-style chained equations
treatmentPropensity scores, IPW treatment effects, and balance diagnostics
evaluationRegression/classification metrics and bootstrap intervals
graphicsDependency-light SVG plots for lines, scatter, residuals, and ACF bars
plotFull-featured SVG/ASCII plot builder: line, scatter, bar, step, band, ACF, survival, and residual charts
robustHuber robust linear regression
geeIndependence-working-correlation GEE
mixedRandom-intercept mixed linear model
descriptiveSummary stats (mean, std, skewness, kurtosis, quartiles)
dataNamed-column DataFrame with formula API: y ~ C(g) + x1*x2 - 1 + offset(e)
correlationPearson, Spearman, correlation matrices

§OLS covariance options

regression::Ols defaults to classical (homoskedastic) standard errors. Switch with .robust() (HC1), .with_covariance(OlsCovariance::Hc3), or .hac(lags) (Newey-West) for time series regressions.

§Formula syntax

data::DataFrame accepts R-style formulas:

  • "y ~ x1 + x2" - main effects
  • "y ~ x1 + x2 - 1" - no intercept
  • "y ~ C(group) + x1" - inline one-hot encoding
  • "y ~ x1:x2" - interaction term
  • "y ~ x1 * x2" - main effects + interaction
  • "y ~ log(x) + sqrt(z)" - numeric transforms
  • "y ~ x + offset(exp)" - Poisson offset

For Rust-native ergonomics, the formula! macro turns formula-like tokens into a formula string:

let f = inferust::formula!(y ~ x1 + C(group));
assert_eq!(f, "y ~ x1 + C(group)");

§Quick start

use inferust::regression::Ols;

let x = vec![vec![1.0], vec![2.0], vec![3.0], vec![4.0], vec![5.0]];
let y = vec![2.1, 3.9, 6.2, 7.8, 10.1];

Ols::new()
    .with_feature_names(vec!["hours".to_string()])
    .fit(&x, &y)
    .unwrap()
    .print_summary();

Re-exports§

pub use error::InferustError;
pub use error::Result;

Modules§

contingency
Contingency table statistics.
correlation
data
descriptive
diagnostics
discrete
error
evaluation
gam
Generalized Additive Model starters.
gee
glm
glm_family
gmm
Generalized Method of Moments and instrumental-variable estimators.
graphics
Lightweight plotting helpers that render statistical graphics as SVG.
hypothesis
imputation
Multiple-imputation starters.
mixed
multivariate
Multivariate statistics.
panel
Panel-data estimators.
plot
Plotting utilities — SVG file output and ASCII terminal charts.
polars_bridge
Optional Polars bridge (inferust feature polars).
post_estimation
Unified post-estimation helpers across model result types.
regression
robust
statespace
State-space models and Kalman filtering.
survival
Survival analysis: Kaplan-Meier estimator and Cox proportional hazards regression.
time_series
Time series modelling and diagnostics.
treatment
Treatment-effect estimators and balance diagnostics.

Macros§

formula
Build a formula string from Rust tokens.