Expand description
§solow-stats
Statistical diagnostics and hypothesis tests, validated against an authoritative reference implementation.
The crate provides the standard battery of regression-diagnostic and
normality tests, simple weighted descriptive statistics, two-sample
location tests, autocorrelation tests, and multiple-testing corrections.
Every public quantity is cross-validated to tight tolerances against the
reference (see tests/reference.rs).
use ndarray::array;
use solow_stats::durbin_watson;
let resid = array![0.1, -0.2, 0.05, 0.15, -0.1];
let dw = durbin_watson(&resid);
assert!((0.0..=4.0).contains(&dw));Structs§
- Anova
Row - One row of an ANOVA table.
- Anova
Table - A full ANOVA table.
- Contingency
Result - Result of a contingency-table chi-squared test of independence.
- Correlation
Result - A correlation coefficient with its two-sided p-value.
- Dcov
Test - Result of the asymptotic distance-covariance (dCov) test of independence.
- Descr
StatsW - Weighted descriptive statistics for a 1-D sample.
- Description
- Summary statistics for a numeric sample (the numeric block of the reference
Description). All values are computed with the same conventions as the reference:stdusesddof = 1, percentiles use linear interpolation. - Dist
Depend Stat - The full battery of distance-dependence statistics for a pair
(X, Y). - FTest
Result - Result of a linear-restriction F test.
- GofResult
- A generic (statistic, p-value) result for the tests in this module.
- Jarque
Bera - Output of
jarque_bera. - Kappa
Results - Results of
cohens_kappa. - Ljung
Box - Per-lag output row of
acorr_ljungbox. - Mediation
- Specification of a linear mediation analysis (no formulas).
- Mediation
Results - Deterministic point estimates from a linear mediation analysis.
- Meta
Result - Pooled meta-analysis result.
- Meta
Study - One study contribution to a meta-analysis.
- Multi
Test Result - Result of
multipletests: rejection flags and adjusted p-values, both in the original input order. - Normal
IndPower - Power of a two-sample z-test for independent samples (normal approximation).
- NpTest
Result - A one-degree-of-freedom test statistic + p-value.
- Oaxaca
Blinder - Blinder-Oaxaca decomposition model.
- Oneway
Result - Result of a one-way ANOVA.
- Poisson
Result - Result of
test_poisson_2indep. - TTest
Power - Power of a one-sample (or paired) t-test.
- TTest
Result - Result of a t- or z-test: statistic, p-value, and degrees of freedom.
- Table
- A two-way contingency table of observed counts.
- Term
- A named model term and the half-open column range
[start, stop)it spans in the design matrix. - Three
Fold - Three-fold Blinder-Oaxaca decomposition of the mean gap.
- Tost
Result - Outcome of a TOST equivalence test.
- Tukey
HsdResult - Result of a pairwise Tukey HSD comparison.
- TwoFold
- Two-fold (“pooled”) Blinder-Oaxaca decomposition of the mean gap.
- Variance
Test Result - Test-statistic + p-value pair returned by variance tests.
- Wald
Result - Result of a linear-restriction Wald test.
Enums§
- Alternative
- Alternative hypothesis for a location test.
- Anova
Type - Type of sum of squares for
anova_lm. - Compare
- Comparison target for
test_poisson_2indep. - Confint
Method - Confidence-interval method for a binomial proportion.
- Fleiss
Method - Chance-correction convention used by
fleiss_kappa. - Levene
Center - Centering strategy for Levene’s test.
- Lilliefors
Dist - Assumed reference distribution for the Lilliefors test.
- Meta
Model - Pooling model.
- Multi
Test Method - Correction method for
multipletests. - Nearest
Method - Method used by
cov_nearestfor the correlation-matrix correction. - Oneway
UseVar - How heteroscedasticity is treated in
anova_oneway. - Poisson
Method - Test statistic / p-value method for
test_poisson_2indep. - Reset
Aug - Augmentation scheme for
linear_reset. - TwoFold
Type - Weighting scheme for the non-discriminatory coefficient vector
β*used by the two-fold (“pooled”) decomposition. Mirrors the referencetwo_fold_typeoptions. - UseVar
- Whether a two-sample test assumes pooled (equal) or unequal variances.
Constants§
- PERCENTILES
- Percentile levels reported by
describe(the reference default).
Functions§
- acorr_
breusch_ godfrey - Breusch–Godfrey Lagrange-multiplier test for residual autocorrelation.
- acorr_
ljungbox - Ljung–Box test of autocorrelation in the series
x. - acorr_
lm - Generic Lagrange-multiplier test for autocorrelation (Engle’s
acorr_lm). - aggregate_
raters - Aggregate a
(subject, rater)assignment matrix into category counts. - anderson_
darling - Anderson-Darling test with the Stephens (1974) correction for normality (parameters estimated from the data).
- anova_
generic - One-way ANOVA from summary statistics. Mirrors
anova_generic. - anova_
lm - ANOVA table for one fitted linear model. Mirrors the single-model
anova_lm(model, typ=...). - anova_
oneway - One-way ANOVA from raw samples. Mirrors
anova_oneway(no trimming). - as_
column - Reshape a 1-D sample into an
n × 1matrix (the column-vector form expected bydistance_statistics). - bartlett
- Bartlett’s test — classical normal-theory χ² test on log-variance ratios.
- chi2_
contingency - Pearson χ² test of independence on a contingency table (rows ×
cols). Returns
(χ², p, dof, expected). - cohens_
kappa - Cohen’s (simple) kappa with variance, confidence interval and zero-test.
- compare_
f_ test - F-test comparison of a restricted (nested) OLS fit against the full fit.
- compare_
lr_ test - Likelihood-ratio comparison of a restricted (nested) OLS fit against the full fit.
- corr2cov
- Convert a correlation matrix to a covariance matrix given standard
deviations
std:Rᵢⱼ · σᵢ σⱼ. Mirrors the referencecorr2cov. - corr_
clipped - Nearest PSD correlation matrix by a single eigenvalue clip plus rescaling so the diagonal is one.
- corr_
nearest - Nearest PSD correlation matrix by Higham-style alternating projection.
- cov2corr
- Convert a covariance matrix to a correlation matrix,
Cᵢⱼ / (σᵢ σⱼ). - cov2corr_
std - Like
cov2corrbut also returns the per-variable standard deviationsσᵢ = sqrt(Cᵢᵢ)(the referencecov2corr(..., return_std=True)). - cov_
cluster - One-way cluster-robust covariance.
- cov_hac
- Newey–West heteroskedasticity- and autocorrelation-consistent (HAC)
covariance with Bartlett weights and a window of
maxlagslags. - cov_hc0
- White’s HC0 heteroskedasticity-consistent covariance:
(X'X)⁻¹ X' diag(uᵢ²) X (X'X)⁻¹. - cov_hc1
- HC1: HC0 scaled by
n / (n − k)(a degrees-of-freedom correction). - cov_hc2
- HC2: per-observation scale
uᵢ² / (1 − hᵢ)with leverageshᵢ. - cov_hc3
- HC3: per-observation scale
(uᵢ / (1 − hᵢ))²with leverageshᵢ. - cov_
nearest - Nearest PSD covariance matrix, leaving the variances (diagonal) unchanged.
- describe
- Compute the descriptive statistics of a numeric sample.
- distance_
correlation - Empirical distance correlation
dCor(X, Y)in[0, 1]. - distance_
covariance - Empirical distance covariance
dCov(X, Y). - distance_
covariance_ test - Asymptotic distance-covariance (dCov) test of independence.
- distance_
statistics - Compute every distance-dependence statistic for matched samples
xandy. - distance_
variance - Empirical distance variance of
X,dVar(X) = dCov(X, X). - durbin_
watson - Durbin–Watson statistic for first-order serial correlation in
resid. - f_
oneway - Classic one-way ANOVA F-test (equal variances), as in SciPy’s
f_oneway. - f_test
- F test on the same restriction
R θ = r, withdf_denomdenominator degrees of freedom (typicallyn - kfor OLS). - fleiss_
kappa - Fleiss’ or Randolph’s kappa for multi-rater agreement.
- fligner
- Fligner-Killeen (1976) rank-based variance test.
- hat_
diag - Leverage (hat-matrix diagonal)
hᵢ = xᵢ (X'X)⁻¹ xᵢ'. - het_
arch - Engle’s ARCH Lagrange-multiplier test (
het_arch). - het_
breuschpagan - Breusch–Pagan Lagrange-multiplier test for heteroscedasticity.
- het_
white - White’s Lagrange-multiplier test for heteroscedasticity.
- jarque_
bera - Jarque–Bera test of normality.
- kendalltau
- Kendall τ-b — with ties correction.
- kruskal
- Kruskal-Wallis one-way ANOVA on ranks. Returns
(H, p)whereHapproximately follows a χ²(k − 1) distribution. - ks_
2samp - Two-sample Kolmogorov-Smirnov test.
- kstest_
normal - Alias for the Lilliefors normality test, matching the reference name
kstest_normal. Returns(statistic, pvalue). - levene
- Levene’s test / Brown-Forsythe variant.
- lilliefors
- Lilliefors test of normality with estimated parameters.
- linear_
reset - Ramsey’s RESET test for neglected nonlinearity.
- mannwhitneyu
- Mann-Whitney U test — two-sided, normal-approximation p-value with tie correction (Mann-Whitney 1947).
- mcnemar
- McNemar’s test on a 2 × 2 paired-binary table.
- meta_
fixed_ effect - Fixed-effect meta-analysis.
- meta_
random_ effects - DerSimonian-Laird random-effects meta-analysis.
- multipletests
- Adjust a set of p-values for multiple testing.
- nct_cdf
- CDF of the noncentral t-distribution:
P(T ≤ t)withdfd.o.f. and noncentralitync. - nct_sf
- Survival function
1 − CDFof the noncentral t-distribution. - omni_
normtest - D’Agostino–Pearson omnibus test of normality (the reference’s
omni_normtest). - pairwise_
tukeyhsd - All pairwise Tukey HSD comparisons.
- pearsonr
- Pearson product-moment correlation.
- proportion_
confint (1 − alpha)confidence interval for a binomial proportion.- proportions_
ztest - One- or two-sample test for proportions based on the normal approximation.
- robust_
bse - Robust standard errors:
sqrt(diag(cov))of any covariance matrix. - runs_
test - Wald-Wolfowitz runs test for randomness (dichotomised at the median).
- shapiro_
wilk - Shapiro-Wilk
Wtest of normality (Royston 1992). - spearmanr
- Spearman rank correlation.
- srange_
cdf - CDF of the studentized range with
kgroups anddfdegrees of freedom. - srange_
ppf - Quantile (inverse CDF) of the studentized range at probability
p. - srange_
sf - Survival function
1 − CDFof the studentized range. - test_
poisson_ 2indep - Test the equality of two independent Poisson rates.
- ttest_
ind - Two-sample independent t-test of
mean(x1) - mean(x2) == value. - ttost_
ind - Two one-sided equivalence test for two independent samples.
- variance_
inflation_ factor - Variance-inflation factor of column
exog_idxof the design matrixexog. - wald_
test - Wald test on a linear restriction
R θ = r. - ztest
- One-sample z-test that
mean(x1) == value.