@mark1russell7/rigor-statistics 0.1.13 → 0.1.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/build/index.d.ts +36 -1
- package/build/index.d.ts.map +1 -1
- package/build/index.js +105 -1
- package/build/index.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -125,6 +125,7 @@ The default expansion has one product for each pair of levels of two dimensions.
|
|
|
125
125
|
| `partialConjunction(pValues, need)` | The p of the claim that at least `need` of these tests have a real effect. |
|
|
126
126
|
| `spearman`, `kendallTau`, `ranks` | The rank correlations, with mean ranks for ties. |
|
|
127
127
|
| `compareRatios`, `noiseFloor`, `noiseVerdict` | The comparison with a baseline, the noise floor of the 5-seed rule with a margin of practical effect, and the state of a difference over the seeds. |
|
|
128
|
+
| `optionFloor({ sigma, delta, tests, alpha, power })`, `tQuantile(p, df)` | The fewest values for each of two options, so that one test of a Bonferroni family finds a difference of `delta` with the stated power, from the Student t law. It assumes unpaired groups of equal size and equal `sigma`. The quantile of the Student t law. |
|
|
128
129
|
| `modeCount(values, { minShare, valleyRatio })` | The count of the modes of a sample, from a kernel density estimate. |
|
|
129
130
|
| `smoothLawScores(values)`, `bestSmoothLaw(values)` | The mean log density of the uniform, normal, exponential, log-normal and Pareto laws at their fits, and the best of them. |
|
|
130
131
|
| `brier`, `calibration` | The Brier score of predictions, and the hit rate of each stated level. |
|
package/build/index.d.ts
CHANGED
|
@@ -998,5 +998,40 @@ interface CalibrationLevel {
|
|
|
998
998
|
}
|
|
999
999
|
/** The hit rate of each stated level, from the lowest level. */
|
|
1000
1000
|
export declare function calibration(forecasts: readonly Forecast[]): CalibrationLevel[];
|
|
1001
|
-
|
|
1001
|
+
/**
|
|
1002
|
+
* This function gives the quantile of the Student t law, from a bisection of its distribution function.
|
|
1003
|
+
*
|
|
1004
|
+
* @param p - The share of the law below the result, above 0 and below 1.
|
|
1005
|
+
* @param df - The degrees of freedom, above 0.
|
|
1006
|
+
*/
|
|
1007
|
+
export declare function tQuantile(p: number, df: number): number;
|
|
1008
|
+
/** The options of `optionFloor`. */
|
|
1009
|
+
interface OptionFloorOptions {
|
|
1010
|
+
/** The standard deviation of one value about the mean of its option. All options have the same value. */
|
|
1011
|
+
readonly sigma: number;
|
|
1012
|
+
/** The smallest difference between the means of two options that the comparison finds. */
|
|
1013
|
+
readonly delta: number;
|
|
1014
|
+
/** The count of tests in the family. The level of each test is `alpha / tests`. */
|
|
1015
|
+
readonly tests: number;
|
|
1016
|
+
/** The two-sided level of the family. The default is 0.05. */
|
|
1017
|
+
readonly alpha?: number;
|
|
1018
|
+
/** The share of comparisons that find a difference of `delta`. The default is 0.8. */
|
|
1019
|
+
readonly power?: number;
|
|
1020
|
+
}
|
|
1021
|
+
/**
|
|
1022
|
+
* This function gives the smallest count of values for each of two options. With it, one test finds a difference of
|
|
1023
|
+
* `delta` with the stated power. The form is `n = 2 ((t(1 - alpha / (2 tests), df) + t(power, df)) sigma / delta)^2`,
|
|
1024
|
+
* with `df = 2 n - 2`. The count is on both sides of that form, so the function takes the first count that meets it.
|
|
1025
|
+
*
|
|
1026
|
+
* The function assumes independent values, unpaired groups of equal size, equal `sigma`, and a Bonferroni family.
|
|
1027
|
+
* Holm gives each test a level of `alpha / tests` or more. Thus for a Holm family the count is an upper bound, not the exact count.
|
|
1028
|
+
* The tests read the power by simulation: 2,000 draws at the floor for 1, 5 and 67 tests, from the fixed seeds `rigor-statistics/optionFloor/at/<tests>`.
|
|
1029
|
+
* Each read gives 0.78 or more, and one count below the floor gives less.
|
|
1030
|
+
* A value of `sigma` from an older run gives a count for that run. Read `sigma` again on the new values.
|
|
1031
|
+
*
|
|
1032
|
+
* @param options - The spread, the difference, the family and the targets.
|
|
1033
|
+
* @returns A whole number of 2 or more.
|
|
1034
|
+
*/
|
|
1035
|
+
export declare function optionFloor(options: OptionFloorOptions): number;
|
|
1036
|
+
export type { BootstrapOptions, CalibrationLevel, CategoricalDimension, CompareOptions, Comparison, ContinuousDimension, Corrected, CountInterval, Effect, Forecast, Interval, LeastSquaresFit, LeastSquaresOptions, MedianInterval, ModeOptions, NoiseOptions, NoiseState, NoiseVerdict, OptionFloorOptions, OrdinalDimension, ParsedResponseRecord, PermutationOptions, PermutationResult, Proportion, QuantileInterval, QuantileMethod, ResponseAbsentPoint, ResponseBand, ResponseCurvePoint, ResponseData, ResponseDimension, ResponseDimensionBase, ResponseFactor, ResponseFault, ResponseFitOptions, ResponseFold, ResponseFoldError, ResponseHeldOutError, ResponseInputValue, ResponseMeasure, ResponseModel, ResponseModelBase, ResponsePoint, ResponseReason, ResponseRecord, ResponseSlice, ResponseSliceOptions, ResponseSlicePoint, ResponseSurface, ResponseSurfaceAbsentPoint, ResponseSurfaceOptions, ResponseSurfacePoint, ResponseTableCell, ResponseValue, ResponseViewOptions, ResponseWhen, RidgeInput, RidgeInputBase, RidgeLevelInput, RidgeNumberInput, RidgeOptions, RidgeRankInput, RidgeResponseModel, RidgeTerm, SmoothLaw, SmoothLawScore, Summary, TableResponseModel, TwoSamplePermutationOptions, TwoSamplePermutationResult };
|
|
1002
1037
|
//# sourceMappingURL=index.d.ts.map
|
package/build/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/describe.ts","../src/regression.ts","../src/bootstrap.ts","../src/distribution.ts","../src/ridge.ts","../src/response.ts","../src/response-parse.ts","../src/response-fit.ts","../src/tests.ts","../src/rank.ts","../src/discrete.ts","../src/compare.ts"],"mappings":";;;;;;KAOY;;wBAmBI,OAAO;wBAIP,KAAK;;;;;wBAgBL,GAAG;;;;;;;wBAgBH,eAAe,iCAAiC,WAAW,SAAQ;;wBAkBnE,SAAS,2BAA2B,WAAW,SAAQ;;;;;wBASvD,OAAO;;UAQN;WACN;WACA;;WAEA;WACA;;WAEA;WACA;;WAEA;WACA;;WAEA;;wBAGK,UAAU,4BAA4B;;;;;;UC3GrC;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AEA;WACA;;;;;;wBAOK,kBAAkB,8BAA8B,6BAA6B,UAAS,qBAA0B;;UAmB/G;;WAEN;;WAEA;;WAEA,aAAa,sBAAsB;;;UAI7B,mCAAmC;;WAEzC;;;;;;;;;wBAuCK,qBAAqB,sBAAsB,sBAAsB,UAAS,8BAAmC;;wBC1M7G,MAAM;;;;;wBAgBN,SAAS,sBAAsB;;qBAmBlC;;;;;;wBAQG,WAAW,sBAAsB,sBAAsB;;UC1BtD;WACN;WACA;;WAEA;;WAEA;;;;;;;;;;wBAWK,eAAe,2BAA2B,iBAAe;;UAqBxD;;WAEN;;WAEA;;WAEA;;WAEA;;WAEA;;;;;;;;;wBAUK,iBAAiB,2BAA2B,WAAW,iBAAe;;;;;;wBAsCtE,gBAAgB,WAAW;;UAW1B;WACN;WACA;;WAEA;;;;;;;wBAQK,iBAAiB,WAAW,WAAW,iBAAe;;;;;;wBA2BtD,yBAAyB,mBAAmB,WAAW,iBAAe;UCvKrE;;WAEN;;WAEA;;;;;;WAMA;;;;;;wBAgBK,WAAW,2BAA2B,UAAS;;;;;KASnD;;UAGK;;WAEN;WACA;;WAEA;;WAEA;WACA;;WAEA;WACA,OAAO;;;;;;;;wBASF,aAAa,2BAA2B,UAAS;WAA0B;IAAqC;UAW/G;;WAEN;;WAEA;;WAEA;;;UAIM;WACN;WACA;;WAEA;;WAEA;;UAGM;;WAEN;WACA;;WAEA;;WAEA;;WAEA;;WAEA,QAAQ;;WAER;;WAEA;;WAEA;WACA,cAAc;;WAEd;WACA,cAAc;;;;;;;;wBAST,cAAc,2BAA2B,UAAS,iBAAsB;;UA6CvE;WACN;WACA;;;wBASK,MAAM,oBAAoB;;UAQzB;WACN;WACA;WACA;;WAEA;;WAEA,UAAU;;;wBAIL,YAAY,oBAAoB,aAAa"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/describe.ts","../src/regression.ts","../src/bootstrap.ts","../src/distribution.ts","../src/ridge.ts","../src/response.ts","../src/response-parse.ts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WAER;;WAEA;;WAEA;WACA,cAAc;;WAEd;WACA,cAAc;;;;;;;;wBAST,cAAc,2BAA2B,UAAS,iBAAsB;;UA6CvE;WACN;WACA;;;wBASK,MAAM,oBAAoB;;UAQzB;WACN;WACA;WACA;;WAEA;;WAEA,UAAU;;;wBAIL,YAAY,oBAAoB,aAAa;;;;;;;wBChJ7C,UAAU,WAAW;;UAgBpB;;WAEN;;WAEA;;WAEA;;WAEA;;WAEA;;;;;;;;;;;;;;;;wBAiBK,YAAY,SAAS"}
|
package/build/index.js
CHANGED
|
@@ -2770,6 +2770,110 @@ function calibration(forecasts) {
|
|
|
2770
2770
|
interval: wilson(hits, n)
|
|
2771
2771
|
}));
|
|
2772
2772
|
}
|
|
2773
|
-
|
|
2773
|
+
// src/power.ts
|
|
2774
|
+
/**
|
|
2775
|
+
* The count of values that a comparison of options needs before it starts. The Student t law gives this count, because the
|
|
2776
|
+
* normal formula is too low at a small count. These functions make no draws, so a caller reads the count with no bench.
|
|
2777
|
+
*/
|
|
2778
|
+
/** The log of the gamma function, by the form of Lanczos with 6 terms. The argument is above 0. */
|
|
2779
|
+
function logGamma(x) {
|
|
2780
|
+
const terms = [
|
|
2781
|
+
76.18009172947146,
|
|
2782
|
+
-86.50532032941678,
|
|
2783
|
+
24.01409824083091,
|
|
2784
|
+
-1.231739572450155,
|
|
2785
|
+
.001208650973866179,
|
|
2786
|
+
-5395239384953e-18
|
|
2787
|
+
];
|
|
2788
|
+
const base = x + 5.5 - (x + .5) * Math.log(x + 5.5);
|
|
2789
|
+
let series = 1.000000000190015;
|
|
2790
|
+
terms.forEach((term, i) => {
|
|
2791
|
+
series += term / (x + i + 1);
|
|
2792
|
+
});
|
|
2793
|
+
return -base + Math.log(2.5066282746310007 * series / x);
|
|
2794
|
+
}
|
|
2795
|
+
/** The continued fraction of the incomplete beta function, by the method of Lentz. */
|
|
2796
|
+
function betaFraction(x, a, b) {
|
|
2797
|
+
const tiny = 1e-300;
|
|
2798
|
+
const guard = (value) => Math.abs(value) < tiny ? tiny : value;
|
|
2799
|
+
let c = 1;
|
|
2800
|
+
let d = 1 / guard(1 - (a + b) * x / (a + 1));
|
|
2801
|
+
let h = d;
|
|
2802
|
+
for (let m = 1; m <= 500; m++) {
|
|
2803
|
+
const twice = 2 * m;
|
|
2804
|
+
const even = m * (b - m) * x / ((a + twice - 1) * (a + twice));
|
|
2805
|
+
d = 1 / guard(1 + even * d);
|
|
2806
|
+
c = guard(1 + even / c);
|
|
2807
|
+
h *= d * c;
|
|
2808
|
+
const odd = -(a + m) * (a + b + m) * x / ((a + twice) * (a + twice + 1));
|
|
2809
|
+
d = 1 / guard(1 + odd * d);
|
|
2810
|
+
c = guard(1 + odd / c);
|
|
2811
|
+
const step = d * c;
|
|
2812
|
+
h *= step;
|
|
2813
|
+
if (Math.abs(step - 1) < 1e-15) return h;
|
|
2814
|
+
}
|
|
2815
|
+
return h;
|
|
2816
|
+
}
|
|
2817
|
+
/** The regularized incomplete beta function at `x`, from 0 to 1. */
|
|
2818
|
+
function incompleteBeta(x, a, b) {
|
|
2819
|
+
if (x <= 0) return 0;
|
|
2820
|
+
if (x >= 1) return 1;
|
|
2821
|
+
const front = Math.exp(logGamma(a + b) - logGamma(a) - logGamma(b) + a * Math.log(x) + b * Math.log(1 - x));
|
|
2822
|
+
return x < (a + 1) / (a + b + 2) ? front * betaFraction(x, a, b) / a : 1 - front * betaFraction(1 - x, b, a) / b;
|
|
2823
|
+
}
|
|
2824
|
+
/** The share of the Student t law with `df` degrees of freedom below `t`, for `t` of 0 or more. */
|
|
2825
|
+
function upperHalf(t, df) {
|
|
2826
|
+
return 1 - .5 * incompleteBeta(df / (df + t * t), df / 2, .5);
|
|
2827
|
+
}
|
|
2828
|
+
/**
|
|
2829
|
+
* This function gives the quantile of the Student t law, from a bisection of its distribution function.
|
|
2830
|
+
*
|
|
2831
|
+
* @param p - The share of the law below the result, above 0 and below 1.
|
|
2832
|
+
* @param df - The degrees of freedom, above 0.
|
|
2833
|
+
*/
|
|
2834
|
+
function tQuantile(p, df) {
|
|
2835
|
+
if (!(p > 0 && p < 1)) throw new RangeError(`tQuantile: p is above 0 and below 1, not ${p}.`);
|
|
2836
|
+
if (!(df > 0 && Number.isFinite(df))) throw new RangeError(`tQuantile: df is a finite number above 0, not ${df}.`);
|
|
2837
|
+
if (p < .5) return -tQuantile(1 - p, df);
|
|
2838
|
+
let high = 1;
|
|
2839
|
+
while (upperHalf(high, df) < p) high *= 2;
|
|
2840
|
+
let low = 0;
|
|
2841
|
+
for (let step = 0; step < 200 && high - low > 1e-12 * high; step++) {
|
|
2842
|
+
const middle = (low + high) / 2;
|
|
2843
|
+
if (upperHalf(middle, df) < p) low = middle;
|
|
2844
|
+
else high = middle;
|
|
2845
|
+
}
|
|
2846
|
+
return (low + high) / 2;
|
|
2847
|
+
}
|
|
2848
|
+
/**
|
|
2849
|
+
* This function gives the smallest count of values for each of two options. With it, one test finds a difference of
|
|
2850
|
+
* `delta` with the stated power. The form is `n = 2 ((t(1 - alpha / (2 tests), df) + t(power, df)) sigma / delta)^2`,
|
|
2851
|
+
* with `df = 2 n - 2`. The count is on both sides of that form, so the function takes the first count that meets it.
|
|
2852
|
+
*
|
|
2853
|
+
* The function assumes independent values, unpaired groups of equal size, equal `sigma`, and a Bonferroni family.
|
|
2854
|
+
* Holm gives each test a level of `alpha / tests` or more. Thus for a Holm family the count is an upper bound, not the exact count.
|
|
2855
|
+
* The tests read the power by simulation: 2,000 draws at the floor for 1, 5 and 67 tests, from the fixed seeds `rigor-statistics/optionFloor/at/<tests>`.
|
|
2856
|
+
* Each read gives 0.78 or more, and one count below the floor gives less.
|
|
2857
|
+
* A value of `sigma` from an older run gives a count for that run. Read `sigma` again on the new values.
|
|
2858
|
+
*
|
|
2859
|
+
* @param options - The spread, the difference, the family and the targets.
|
|
2860
|
+
* @returns A whole number of 2 or more.
|
|
2861
|
+
*/
|
|
2862
|
+
function optionFloor(options) {
|
|
2863
|
+
const { sigma, delta, tests, alpha = .05, power = .8 } = options;
|
|
2864
|
+
if (!(sigma > 0 && Number.isFinite(sigma))) throw new RangeError(`optionFloor: sigma is a finite number above 0, not ${sigma}.`);
|
|
2865
|
+
if (!(delta > 0 && Number.isFinite(delta))) throw new RangeError(`optionFloor: delta is a finite number above 0, not ${delta}.`);
|
|
2866
|
+
if (!Number.isSafeInteger(tests) || tests < 1) throw new RangeError(`optionFloor: tests is a whole number of 1 or more, not ${tests}.`);
|
|
2867
|
+
if (!(alpha > 0 && alpha < 1)) throw new RangeError(`optionFloor: alpha is above 0 and below 1, not ${alpha}.`);
|
|
2868
|
+
if (!(power > .5 && power < 1)) throw new RangeError(`optionFloor: power is above 0.5 and below 1, not ${power}.`);
|
|
2869
|
+
const level = 1 - alpha / (2 * tests);
|
|
2870
|
+
for (let n = 2; n < 1e7; n++) {
|
|
2871
|
+
const df = 2 * n - 2;
|
|
2872
|
+
const need = 2 * ((tQuantile(level, df) + tQuantile(power, df)) * sigma / delta) ** 2;
|
|
2873
|
+
if (n >= need) return n;
|
|
2874
|
+
}
|
|
2875
|
+
throw new RangeError(`optionFloor: no count under 10,000,000 for sigma ${sigma} and delta ${delta}.`);
|
|
2876
|
+
}
|
|
2877
|
+
export { KENDALL_EXACT, RESPONSE_LAMBDAS, RESPONSE_MAX_POWER, RESPONSE_MAX_TERMS, RESPONSE_RECORDS_SCHEMA, Z95, bestSmoothLaw, binomialInterval, bootstrap, bootstrapClusters, bootstrapLeastSquares, bootstrapMedian, bootstrapMedianRatio, bootstrapTwo, brier, calibration, compareRatios, fitResponse, heldOutError, heldOutErrorAt, holm, kendallTau, leastSquares, mean, median, medianInterval, modeCount, negativeBinomialInterval, noiseFloor, noiseVerdict, optionFloor, pairedPermutation, parseResponseRecord, partialConjunction, predictResponse, quantile, quantileInterval, quantileSamples, quantileSorted, ranks, responseCells, ridgeSolve, sd, signTest, signTestPower, sliceResponse, smoothLawScores, sorted, spearman, summarize, surfaceResponse, tQuantile, twoSamplePermutation, whenHolds, wilson };
|
|
2774
2878
|
|
|
2775
2879
|
//# sourceMappingURL=index.js.map
|