polars-statistics API Reference¶
Complete API documentation for polars-statistics.
Quick Links¶
| Category | Description |
|---|---|
| Conventions | API patterns, column references, return types |
| Statistical Tests | |
| Parametric Tests | t-tests, Brown-Forsythe, Yuen, one_way_anova, two_way_anova, repeated_measures_anova |
| Non-Parametric Tests | Mann-Whitney, Wilcoxon, Kruskal-Wallis, Brunner-Munzel |
| Post-hoc Tests & Multiple Comparisons | tukey_hsd, pairwise_t_test, dunn_test, p_adjust, ptukey, qtukey |
| Distributional Tests | Shapiro-Wilk, D'Agostino, Jarque-Bera normality tests |
| Forecast Tests | Diebold-Mariano, Clark-West, SPA, MCS |
| Correlation Tests | Pearson, Spearman, Kendall, distance correlation, partial correlation, icc (matrix-input) |
| Categorical Tests | Chi-square, Fisher exact (incl. conditional), McNemar, Cohen's Kappa |
| TOST Equivalence | Two One-Sided Tests for equivalence |
| Effect Sizes & Bootstrap CIs | Cohen's d, rank-biserial, percentile bootstrap CIs |
| Regression | |
| Linear Models | OLS, Ridge, Elastic Net, WLS, RLS, BLS, NNLS, Quantile, Isotonic |
| GLM Models | Logistic, Poisson, Negative Binomial, Tweedie, Probit, Cloglog |
| Penalized GLM | Family-generic penalized GLM with priors (Poisson, Binomial, Logistic, Negative Binomial, Gamma, Tweedie) |
| Survival Regression (AFT) | Accelerated failure time survival regression (Weibull, log-normal, log-logistic, exponential) |
| ALM | Augmented Linear Model (24+ distributions) |
| Dynamic Models | LmDynamic time-varying coefficients |
| Demand Classification | AID demand patterns and anomaly detection |
| Formula Syntax | R-style formulas with interactions and polynomials |
| Summary & Predict | Coefficient tables and prediction intervals |
| Diagnostics | Condition number, quasi-separation detection, augment per-observation diagnostics, gamma_* GLM diagnostics |
| Empirical-Bayes Shrinkage | eb_shrink — random-effects meta-analytic shrinkage toward a pooled mean |
| Model Classes | |
| Linear Model Classes | OLS, Ridge, ElasticNet, WLS, RLS, BLS, Quantile, Isotonic, TheilSen, RANSAC, BayesianRidge, ARD, LARS, PassiveAggressive, MomentAccumulator — every class exposes model_info and OLS/WLS expose .augment() |
| GLM Model Classes | Logistic, Poisson, NegativeBinomial, Tweedie, Probit, Cloglog, Gamma, PenalizedGLM, GLMM, PSpline — every class exposes model_info; GLMM adds negative-binomial/Gamma/Tweedie families, offsets, per-factor random slopes |
| Survival model classes | AFT (accelerated failure time survival regression) |
| ALM Class | Augmented Linear Model class |
| LmDynamic Class | Dynamic linear model class |
| Aid Class | Demand classification class |
| Test Classes | Statistical test classes |
| Bootstrap Classes | Stationary and circular block bootstrap |
| Reference | |
| Output Structures | All return type definitions |
Installation¶
Basic Usage¶
All functions work as Polars expressions:
import polars as pl
import polars_statistics as ps
df = pl.DataFrame({
"group": ["A"] * 50 + ["B"] * 50,
"y": [...],
"x1": [...],
})
# Run regression per group
result = df.group_by("group").agg(
ps.ols("y", "x1").alias("model")
)
# Extract results
result.with_columns(
pl.col("model").struct.field("r_squared"),
)
See Also¶
- README - Quick start guide
- Polars Documentation