statkit 0.5.0
statkit: ^0.5.0 copied to clipboard
Pure Dart statistics kernel: descriptives, hypothesis tests (t, ANOVA, chi-square), correlation, regression, nonparametric tests, reliability, clustering, ROC, PCA and logistic regression. Zero Flutte [...]
Changelog #
0.5.0 #
Statistical capability upgrade: ordered-alternative and permutation tests, Lilliefors normality, multinomial logistic regression, and ANCOVA. Two correctness defects in binary logistic regression are fixed (see Fixed).
Entries added in this release are annotated @experimental; see "Versioning"
in README.md for what that promises.
Added #
NparExtended.jonckheereTerpstra— Jonckheere-Terpstra ordered-alternative trend test: pair counting in O(n log n), tie-corrected variance, frequency weights, one-tailed p inextra['pOneTail']Permutation.random/Permutation.exact,twoSampleMeanDifference,pairedDifference— permutation framework with(1 + #{|s| ≥ |obs|}) / (1 + B)p-values (Phipson & Smyth 2010), a fixed default seed, and an exact enumeration mode for small sample sizesNonparametric.lillieforsP— Lilliefors correction for the one-sample KS test with parameters estimated from the sample (Dallal & Wilkinson 1986; same approximation as Rnortest::lillie.testand statsmodelspvalmethod='approx')multinomialLogistic+MultinomialResult/MultinomialWald— softmax regression by Newton-Raphson on the analytic multinomial information; selectable reference category (default: the highest level, as SPSS NOMREG); per-equation Wald χ², odds ratios with 95% CI, likelihood-ratio χ², McFadden pseudo-R², classification table, raw-scale covariance matrixancova+AncovaResult/AnovaTerm/AncovaSlope/AncovaMean— analysis of covariance,y ~ A [* B] + covariates, with type III sums of squares (model-comparison definition: SAS-compatible, invariant to unequal cell counts), covariate slopes on the original scale with t/CI, and adjusted means (EMM) with standard errors and 95% CILogisticFullResult.iterations/LogisticFullResult.convergednormalQuantile— inverse standard normal CDF Φ⁻¹(p) (Acklam approximation, |error| < 1.15e-9), the inverse ofnormCdf; used for normal scores and Blom plotting positions (the Q-Q plot now shares it instead of a private copy)
Fixed #
logisticRegressionFull: the IRLS step dropped the working weight of the work response (z + residual / winstead ofw * z + residual), so the iteration oscillated between two points instead of reaching the maximum-likelihood estimate. Coefficients, odds ratios, standard errors and p-values came from a non-converged point — the intercept-only model with 12 ones and 9 zeros returned 0.5053020 instead oflog(12/9) = 0.2876821, at a worse log-likelihood (−14.4614 vs −14.3411).logisticRegressionFull: the intercept standard error was read off the standardized scale instead of being transformed back withA·cov·Aᵀ.logisticRegression(factor_logistic.dart): was a fixed-step batch gradient descent that never reached the MLE. It now delegates to the corrected IRLS; returned fields and their meaning are unchanged.Nonparametric.kolmogorovSmirnovNormal: reported the plain Kolmogorov asymptotic p under a "Lilliefors" label even though mean and SD were estimated, which made the test almost never reject.Dis now computed with signedD+/D−and the Lilliefors p is the primary p; the plain asymptotic value is kept inextra['pKolmogorovAsymptotic'].leveneTest: the default centre was the group median (Brown-Forsythe) while PSPP 2.1.2 and SPSS centre Levene's test on the group mean in ONEWAY/STATISTICS=homogeneity, T-TEST and GLM (PSPPsrc/math/levene.c, wheret_bar = Σ value·weight / n).useMeannow defaults totrue; the median-centred Brown-Forsythe remains available asuseMean: false. On PSPP'soneway.atexample this changes F from 0.1176 to 0.0917 (PSPP prints.09), which also feeds the equal/unequal-variance choice ofTTest.independentSamples.Nonparametric.mannWhitney: the asymptotic variance of the U statistic ignored ties, so Z and p were wrong whenever the pooled sample had repeated values (σ² = n1·n2·(n+1)/12instead ofn1·n2·[(n+1)/12 − Σ(t³−t)/(12·n·(n−1))], which is PSPP's(n³−n)/12 − Σ(t³−t)/12after scaling, and what SPSS and R use). On PSPP'snpar.atMann-Whitney example the corrected Z is −0.6020 (PSPP prints-.6020, p.547) where the old variance gave −0.6014.pis now2·Φ(z)with no continuity correction — PSPP's "Asymp. Sig. (2-tailed)" — and the continuity-correctedZ/p(SPSS, Rcorrect = TRUE) moved toextra['zContinuityCorrected']/extra['pContinuityCorrected']; the reportedzandpare now consistent with each other.extraalso gainsrankSum1,rankSum2andtieTerm.
Changed #
normalityTestnow decides on the Lilliefors p, i.e. a strictly more conservative criterion for the same data (estimating the parameters makes the p smaller). The skewness/kurtosis guard (|skewness| < 1.5,|kurtosis| < 3) is unchanged. The previous Kolmogorov asymptotic p remains available asNormalityResult.pKolmogorovAsymptotic.logisticRegressionFullalso addsiterations/converged; on complete separation it now returns the last finite iterate withconverged == falseinstead of failing.
Tests #
statkit_v05_test.dart(new): Jonckheere-Terpstra (hand-verified trends, frequency weights, ties), permutation (exact enumeration vs random, monotone statistic), Lilliefors (closed-form and Monte-Carlo cross-checks), multinomial logistic (intercept-only and saturated closed forms, binary degeneracy, reference-category shift), ANCOVA (FWL residualization,glmTwoWayagreement in balanced designs, hand-computed type III SS, adjusted-mean identity, confounding)statkit_v04_test.dart: closed-form checks for the corrected binary IRLS
0.4.0 #
Modeling enhancements.
Added #
- logisticRegressionFull: IRLS, Wald SE, OR 95% CI, classification table, Hosmer-Lemeshow
- glmOneWay / glmTwoWay fixed-effects ANOVA (A, B, A×B, partial eta²)
- stepwiseRegression (forward / backward / both)
- crosstabSummary CTABLES-lite (count / mean / sum / sd / min / max / median)
Tests #
- statkit_v04_test.dart
0.3.0 #
Exploratory analysis: EXAMINE suite, chart data, enhanced normality and factor analysis.
Added #
examine()— descriptives, percentiles, extremes, box plot, stem-and-leaf, Q-Q, D'Agostino-Pearsonpercentiles,extremes,boxPlot,boxPlotGroups,stemAndLeaf,normalQQPoints/normalQQPointsStandardized,errorBarsFromGroups,dagostinoPearsonnormality test- Factor:
varimax,kmo,bartlettSphericity,factorAnalyze
Tests #
statkit_v03_test.dart(examine, charts, KMO/Bartlett, varimax)
0.2.0 #
Weighted estimation, SPLIT FILE helpers, complete NPAR set additions, and exact tests.
Added #
WeightedDescriptives— frequency-weighted mean, variance, SE, CIWeightedTTest.oneSample/independentWeightedCorrelation.pearsonweightedSimpleRegressionsplitGroups()/applyWeights()for SPLIT FILE & WEIGHT CASES semanticsexactBinomial,exactSignTest,fisherExact(2×2)NparExtended.binomial,kendallTau,mcnemar,cochranQ,medianTest,friedman
Tests #
- New
statkit_v02_test.dartcovering weights, split, exact tests, NPAR extensions
0.1.0 #
Initial release of statkit, a pure-Dart statistics kernel.
Modules #
- Distributions: normal, Student's t, chi-square, F, incomplete beta/gamma, binomial
- Descriptives: mean, SD, variance, skewness, kurtosis, quartiles, CI
- Frequencies: frequency tables, histogram binning
- Hypothesis: one-sample / independent / paired t-tests, Oneway ANOVA, Levene, chi-square
- Correlation: Pearson, Spearman, correlation matrices
- Regression: simple and multiple linear regression (VIF, Durbin-Watson)
- Nonparametric: Mann-Whitney, Wilcoxon, Kruskal-Wallis, Friedman, sign, runs, KS
- Reliability: Cronbach's alpha
- Clustering: k-means (k-means++ init)
- Extra: means tables, normality test, ROC/AUC, Tukey HSD, PCA factor analysis, logistic regression