Skip to main content

Crate solow_stats

Crate solow_stats 

Source
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§

AnovaRow
One row of an ANOVA table.
AnovaTable
A full ANOVA table.
ContingencyResult
Result of a contingency-table chi-squared test of independence.
CorrelationResult
A correlation coefficient with its two-sided p-value.
DcovTest
Result of the asymptotic distance-covariance (dCov) test of independence.
DescrStatsW
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: std uses ddof = 1, percentiles use linear interpolation.
DistDependStat
The full battery of distance-dependence statistics for a pair (X, Y).
FTestResult
Result of a linear-restriction F test.
GofResult
A generic (statistic, p-value) result for the tests in this module.
JarqueBera
Output of jarque_bera.
KappaResults
Results of cohens_kappa.
LjungBox
Per-lag output row of acorr_ljungbox.
Mediation
Specification of a linear mediation analysis (no formulas).
MediationResults
Deterministic point estimates from a linear mediation analysis.
MetaResult
Pooled meta-analysis result.
MetaStudy
One study contribution to a meta-analysis.
MultiTestResult
Result of multipletests: rejection flags and adjusted p-values, both in the original input order.
NormalIndPower
Power of a two-sample z-test for independent samples (normal approximation).
NpTestResult
A one-degree-of-freedom test statistic + p-value.
OaxacaBlinder
Blinder-Oaxaca decomposition model.
OnewayResult
Result of a one-way ANOVA.
PoissonResult
Result of test_poisson_2indep.
TTestPower
Power of a one-sample (or paired) t-test.
TTestResult
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.
ThreeFold
Three-fold Blinder-Oaxaca decomposition of the mean gap.
TostResult
Outcome of a TOST equivalence test.
TukeyHsdResult
Result of a pairwise Tukey HSD comparison.
TwoFold
Two-fold (“pooled”) Blinder-Oaxaca decomposition of the mean gap.
VarianceTestResult
Test-statistic + p-value pair returned by variance tests.
WaldResult
Result of a linear-restriction Wald test.

Enums§

Alternative
Alternative hypothesis for a location test.
AnovaType
Type of sum of squares for anova_lm.
Compare
Comparison target for test_poisson_2indep.
ConfintMethod
Confidence-interval method for a binomial proportion.
FleissMethod
Chance-correction convention used by fleiss_kappa.
LeveneCenter
Centering strategy for Levene’s test.
LillieforsDist
Assumed reference distribution for the Lilliefors test.
MetaModel
Pooling model.
MultiTestMethod
Correction method for multipletests.
NearestMethod
Method used by cov_nearest for the correlation-matrix correction.
OnewayUseVar
How heteroscedasticity is treated in anova_oneway.
PoissonMethod
Test statistic / p-value method for test_poisson_2indep.
ResetAug
Augmentation scheme for linear_reset.
TwoFoldType
Weighting scheme for the non-discriminatory coefficient vector β* used by the two-fold (“pooled”) decomposition. Mirrors the reference two_fold_type options.
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 × 1 matrix (the column-vector form expected by distance_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 reference corr2cov.
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 cov2corr but also returns the per-variable standard deviations σᵢ = sqrt(Cᵢᵢ) (the reference cov2corr(..., 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 maxlags lags.
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 leverages hᵢ.
cov_hc3
HC3: per-observation scale (uᵢ / (1 − hᵢ))² with leverages hᵢ.
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 x and y.
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, with df_denom denominator degrees of freedom (typically n - k for 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) where H approximately 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) with df d.o.f. and noncentrality nc.
nct_sf
Survival function 1 − CDF of 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 W test of normality (Royston 1992).
spearmanr
Spearman rank correlation.
srange_cdf
CDF of the studentized range with k groups and df degrees of freedom.
srange_ppf
Quantile (inverse CDF) of the studentized range at probability p.
srange_sf
Survival function 1 − CDF of 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_idx of the design matrix exog.
wald_test
Wald test on a linear restriction R θ = r.
ztest
One-sample z-test that mean(x1) == value.