statkit library

statkit — 纯 Dart 统计分析内核

Classes

AncovaMean
调整均值(EMM)。协变量以相加形式进入模型,因此 EMM 等于 「把协变量固定在各自均值、因子固定在该水平」时的模型预测值; 边缘均值对另一个因子的各水平等权平均。
AncovaResult
协方差分析结果
AncovaSlope
协变量斜率(原始尺度,未标准化:每增加 1 个单位因变量的变化)
AnovaGroup
AnovaResult
AnovaTerm
方差分析表的一行(因子项或协变量项)
BartlettResult
Bartlett 球形检验(相关阵是否为单位阵)
BoxPlotData
箱线图数据
ChiSquareCell
ChiSquareResult
ChiSquareTest
ClassificationTable
ClusterCenter
Correlation
CorrelationResult
CTableCell
CTablesResult
Descriptives
数值向量完整描述
ErrorBarData
误差条数据(均值 ± k·SE 或 CI)
ExactBinomialResult
精确二项检验 H0: p = p0
ExamineResult
完整 EXAMINE 结果包
ExtremeRow
极值表(Extrim)
ExtremesResult
FactorFullResult
扩展因子分析:PCA + 可选 varimax + 诊断
FactorResult
FisherExactResult
2×2 Fisher 精确检验
Frequencies
FrequencyRow
FrequencyTable
GlmResult
GlmTerm
HistogramBin
HosmerLemeshow
KMeans
KMeansResult
KmoResult
KMO 抽样适切性
LeveneResult
LogisticFullResult
LogisticResult
LogisticWald
MeansResult
MeansRow
分层/分组均值表(MEANS)
MultinomialResult
多项 logistic 回归结果(softmax / 参考类别参数化)
MultinomialWald
多项 logistic 回归的一个系数(某条 logit 方程中的某一项)
Nonparametric
NonparametricResult
NormalityDP
D'Agostino-Pearson 正态性(偏度/峰度联合)——近似 Shapiro-Wilk 意图
NormalityResult
正态性检验结果
NparExtended
v0.2 起加入的一批非参数过程:二项、Kendall、McNemar、Friedman、Cochran 与 Median 检验;v0.5 又加了 Jonckheere-Terpstra 有序备择趋势检验。
OnewayAnova
PairwiseDiff
单因素方差分析 + 事后 Tukey HSD
PercentileRow
百分位表(EXAMINE PERCENTILES)
PercentileTable
Permutation
置换检验入口(随机置换与完全枚举)
PermutationResult
置换检验结果
QQPoint
Q-Q 图点(正态)
Regression
RegressionCoefficient
RegressionResult
Reliability
ReliabilityItem
ReliabilityResult
RocResult
ROC 曲线下面积(Mann-Whitney 统计量)
StemLeafResult
StemLeafRow
茎叶图(stem-and-leaf)
StepwiseResult
StepwiseStep
TTest
TTestResult
WeightedCorrelation
加权 Pearson 相关
WeightedDescriptives
加权描述统计(频数权:每个观测代表 w 个个案)
WeightedLinFit
加权简单回归结果
WeightedTTest
加权单样本 t

Functions

ancova({required List<double> y, required List<String> a, List<String>? b, Map<String, List<double>> covariates = const {}, String yName = 'Y', String aName = 'A', String bName = 'B'}) → AncovaResult
协方差分析:y ~ A * B + 连续协变量
applyWeights(List<double> values, List<double> weights) → (List<double>, List<double>)
按权重向量过滤后的副本
averageRanks(List<double> values) → List<double>
平均秩(并列取平均)
bartlettSphericity(List<List<double>> columns) → BartlettResult
betaInc(double a, double b, double x) → double
正则化不完全 Beta I_x(a,b)
binomialPmf(int k, int n, double p) → double
二项分布 P(X = k)
binomialSf(int k, int n, double p) → double
二项分布上尾 P(X >= k)
boxPlot(List<double> values) → BoxPlotData
boxPlotGroups(List<List<double>> groups) → List<BoxPlotData>
多组箱线图数据
chiSquareCdf(double x, int df) → double
卡方 CDF(下尾)
chiSquareCritical(int df, double alpha) → double
卡方临界值(上尾 alpha)
chiSquarePdf(double x, int df) → double
卡方分布的概率密度(df 为自由度)
chiSquareSf(double x, int df) → double
卡方上尾 p(常用)
cochranQ(List<List<bool>> treatments) → double
Cochran Q(k 相关二分样本)
combinations(int n, int k) → double
组合数 C(n,k)
crosstabSummary({required List<Object?> rowKeys, required List<Object?> colKeys, List<double?>? values, required String rowVar, required String colVar, String valueVar = '', CellSummary summary = CellSummary.count, Map<Object?, String>? rowLabels, Map<Object?, String>? colLabels}) → CTablesResult
二维透视汇总 rows / cols: 每行的行键与列键;values: 可选数值(计数模式可全 null)
dagostinoPearson(List<double> values) → NormalityDP
errorBarsFromGroups(Map<String, List<double>> groups, {double z = 1.96}) → List<ErrorBarData>
exactBinomial(int k, int n, {double p0 = 0.5}) → ExactBinomialResult
exactSignTest(int positive, int negative, {double p0 = 0.5}) → ExactBinomialResult
精确符号检验(正/负个数)
examine(List<double> values, {int extremesCount = 5}) → ExamineResult
extremes(List<double> values, {int nShow = 5}) → ExtremesResult
factorAnalyze(List<List<double>> columns, {List<String>? names, int maxFactors = 3, bool rotate = true}) → FactorFullResult
factorPca(List<List<double>> columns, {List<String>? names, int maxFactors = 3}) → FactorResult
主成分因子分析(相关矩阵特征分解,雅可比)
fCdf(double f, int df1, int df2) → double
F 分布 CDF
fCritical(int df1, int df2, double alpha) → double
F 临界值
fisherExact(int a, int b, int c, int d) → FisherExactResult
表: | a b | | c d |
formatNum(double v, {int digits = 3}) → String
格式化数值
formatP(double p) → String
格式化 p 值(APA 风格)
fSf(double f, int df1, int df2) → double
F 上尾 p
gammaFn(double x) → double
Gamma 函数 Γ(x)(由 lnGamma 取指数,避免中间量溢出)
glmOneWay(Map<String, List<double>> groups, {String yName = 'Y', String factorName = 'A'}) → GlmResult
单元 ANOVA(退化为 OnewayAnova,便于统一接口)
glmTwoWay(Map<(String, String), List<double>> cells, {String yName = 'Y'}) → GlmResult
双元方差分析:y ~ A * B cells: Map of (labelA, labelB) → values
hosmerLemeshow(List<double> probs, List<int> y, {int groups = 10}) → HosmerLemeshow
kmo(List<List<double>> columns, {List<String>? names}) → KmoResult
leveneTest(List<List<double>> groups, {bool useMean = true}) → LeveneResult
Levene 方差齐性:默认对组均值(经典 Levene,与 PSPP 2.1.2 / SPSS 的 ONEWAY /STATISTICS=homogeneity、T-TEST 与 GLM 的方差齐性检验一致 —— PSPP 见 src/math/levene.c,中心 t_bar 就是 Σ value·weight / n)。
lnGamma(double x) → double
ln Γ(x)(Lanczos 近似)
logisticRegression(List<List<double>> xs, List<int> y, {List<String>? names, int maxIter = 100, double lr = 0.1}) → LogisticResult
逻辑回归(二分类)。
logisticRegressionFull(List<List<double>> xs, List<int> y, {List<String>? names, double threshold = 0.5, int hlGroups = 10, int maxIter = 50}) → LogisticFullResult
二分类逻辑回归(IRLS / 牛顿-拉夫逊),支持 SE / Wald / OR CI
lowerIncGamma(double s, double x) → double
下不完全 gamma P(s,x)(正则化,返回 0..1)
mcnemar(int b, int c) → ({int b, int c, double chiSquare, double p})
McNemar(配对二分)
meansTable(Map<String, List<double>> groups, {required String layerVar, required String valueVar}) → MeansResult
modes(List<double> values) → List<double>
众数(可多个;若全不重复返回空)
multinomialLogistic(List<List<double>> xs, List<int> y, {List<String>? names, List<String>? levelLabels, int? referenceLevel, int maxIter = 100, double ridge = 1e-6, double tol = 1e-10}) → MultinomialResult
多项 logistic 回归(softmax,牛顿–拉夫逊,参考类别参数化)。
normalityTest(List<double> data) → NormalityResult
Lilliefors(K-S,均值方差由样本估计)正态性 + 偏度峰度辅助判断。
normalQQPoints(List<double> values) → List<QQPoint>
normalQQPointsStandardized(List<double> values) → List<QQPoint>
将样本标准化后的 Q-Q 点
normalQuantile(double p) → double
标准正态分位数 Φ⁻¹(p)(Acklam 近似,|误差| < 1.15e-9)。
normCdf(double z) → double
标准正态 CDF Φ(z)
normPdf(double z) → double
标准正态 PDF
normTwoTail(double z) → double
正态双侧 p 值
normUpper(double z) → double
正态单侧上尾 p
percentile(List<double> sorted, double p) → double
线性插值百分位数
percentiles(List<double> values, {List<double>? probs}) → PercentileTable
rocCurve(List<double> positives, List<double> negatives) → RocResult
significanceStars(double p) → String
显著性星号
splitGroups(List<Object?> groupColumn, {Map<Object?, String>? valueLabels}) → Map<String, List<int>>
SPLIT FILE:按分组键拆分行索引 返回 Map<组标签, List<行索引>>
stemAndLeaf(List<double> values, {double? unit}) → StemLeafResult
stepwiseRegression(List<List<double>> xs, List<double> y, {required List<String> names, StepwiseMethod method = StepwiseMethod.both, double enterP = 0.05, double removeP = 0.10}) → StepwiseResult
tCdf(double t, int df) → double
t 分布 CDF
tCritical(int df, double alpha) → double
t 临界值(双侧 alpha)
tPdf(double t, int df) → double
t PDF
tTwoTail(double t, int df) → double
t 双侧 p
tukeyHsd(AnovaResult anova) → List<PairwiseDiff>
tUpper(double t, int df) → double
t 单侧上尾 p
upperIncGamma(double s, double x) → double
上不完全 gamma Q(s,x)(正则化,返回 0..1)
varimax(List<List<double>> loadings, {int maxIter = 100}) → (List<List<double>>, double)
方差最大旋转(Kaiser 1958) loadings: p × k
weightedSimpleRegression(List<double> x, List<double> y, List<double> w) → WeightedLinFit
加权线性回归(简单最小二乘 + 频数权)
zCritical(double alpha) → double
z 临界值(双侧)