@numero-uno-jpn/rstats 0.10.0 → 0.11.1
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/CHANGELOG.md +37 -0
- package/README.ja.md +13 -9
- package/README.md +13 -8
- package/dist/chunks/{chunk-QJJWGNJP.js → chunk-2X7JYQBI.js} +2 -2
- package/dist/chunks/{chunk-O6PT7IVU.js → chunk-36GVER3O.js} +2 -2
- package/dist/chunks/{chunk-EWC6I75B.js → chunk-3WUXRSM6.js} +1 -1
- package/dist/chunks/{chunk-4NM37MGA.js → chunk-6I6QKTFK.js} +2 -2
- package/dist/chunks/{chunk-2XKG3DX4.js → chunk-ETOEZTGL.js} +1 -1
- package/dist/chunks/{chunk-IT354SHV.js → chunk-FVPDVRJQ.js} +2 -2
- package/dist/chunks/{chunk-QULPY6YM.js → chunk-GG4BJMJW.js} +1 -1
- package/dist/chunks/{chunk-7HPVUVZB.js → chunk-HITD7CX6.js} +1 -1
- package/dist/chunks/{chunk-LIMZKONM.js → chunk-KK4GE65D.js} +2 -2
- package/dist/chunks/chunk-LAUYSGV4.js +3 -0
- package/dist/chunks/chunk-M6GDXKKS.js +2 -0
- package/dist/chunks/{chunk-QFULZNHL.js → chunk-PHHUHR7T.js} +1 -1
- package/dist/chunks/{chunk-ENL43FNO.js → chunk-WQPFDDIY.js} +2 -2
- package/dist/chunks/chunk-X2AWQSVS.js +2 -0
- package/dist/chunks/{chunk-ZRIM4R4A.js → chunk-ZRJQD7VS.js} +2 -2
- package/dist/data/grouping.d.ts +100 -0
- package/dist/data/grouping.js +264 -0
- package/dist/descriptive/basic.d.ts +130 -17
- package/dist/descriptive/basic.js +115 -14
- package/dist/descriptive/cov.d.ts +22 -12
- package/dist/descriptive/dataFrames.d.ts +138 -0
- package/dist/descriptive/dataFrames.js +400 -0
- package/dist/descriptive/factanal.d.ts +26 -6
- package/dist/descriptive/factanal.js +7 -3
- package/dist/descriptive/hist.d.ts +27 -6
- package/dist/descriptive/hist.js +9 -3
- package/dist/descriptive/missing.d.ts +42 -0
- package/dist/descriptive/missing.js +52 -0
- package/dist/descriptive/moments.d.ts +91 -13
- package/dist/descriptive/moments.js +66 -9
- package/dist/descriptive/omega.d.ts +28 -6
- package/dist/descriptive/omega.js +16 -4
- package/dist/descriptive/pivot.d.ts +105 -0
- package/dist/descriptive/pivot.js +347 -0
- package/dist/descriptive/quantile.d.ts +33 -5
- package/dist/descriptive/quantile.js +20 -2
- package/dist/descriptive/rank.d.ts +12 -2
- package/dist/descriptive/rank.js +2 -0
- package/dist/descriptive/table.d.ts +55 -7
- package/dist/descriptive/table.js +38 -4
- package/dist/descriptive.js +2 -2
- package/dist/distributions/arcsine.d.ts +40 -5
- package/dist/distributions/arcsine.js +35 -4
- package/dist/distributions/beta.d.ts +12 -0
- package/dist/distributions/beta.js +12 -0
- package/dist/distributions/binomial.d.ts +18 -0
- package/dist/distributions/binomial.js +18 -0
- package/dist/distributions/bvnorm.d.ts +4 -1
- package/dist/distributions/bvnorm.js +4 -1
- package/dist/distributions/cauchy.d.ts +24 -0
- package/dist/distributions/cauchy.js +24 -0
- package/dist/distributions/chisq.d.ts +18 -0
- package/dist/distributions/chisq.js +18 -0
- package/dist/distributions/exponential.d.ts +29 -1
- package/dist/distributions/exponential.js +24 -0
- package/dist/distributions/f.d.ts +18 -0
- package/dist/distributions/f.js +18 -0
- package/dist/distributions/gamma.d.ts +20 -0
- package/dist/distributions/gamma.js +18 -0
- package/dist/distributions/geometric.d.ts +24 -0
- package/dist/distributions/geometric.js +24 -0
- package/dist/distributions/hypergeometric.d.ts +24 -0
- package/dist/distributions/hypergeometric.js +24 -0
- package/dist/distributions/invgamma.d.ts +32 -4
- package/dist/distributions/invgamma.js +27 -3
- package/dist/distributions/kumaraswamy.d.ts +31 -3
- package/dist/distributions/kumaraswamy.js +31 -3
- package/dist/distributions/laplace.d.ts +36 -4
- package/dist/distributions/laplace.js +31 -3
- package/dist/distributions/logistic.d.ts +29 -1
- package/dist/distributions/logistic.js +24 -0
- package/dist/distributions/lognormal.d.ts +29 -1
- package/dist/distributions/lognormal.js +24 -0
- package/dist/distributions/multinomial.d.ts +7 -1
- package/dist/distributions/multinomial.js +2 -0
- package/dist/distributions/negbinomial.d.ts +29 -1
- package/dist/distributions/negbinomial.js +24 -0
- package/dist/distributions/normal.d.ts +11 -1
- package/dist/distributions/normal.js +6 -0
- package/dist/distributions/pareto.d.ts +36 -4
- package/dist/distributions/pareto.js +31 -3
- package/dist/distributions/poisson.d.ts +18 -0
- package/dist/distributions/poisson.js +18 -0
- package/dist/distributions/signrank.d.ts +24 -0
- package/dist/distributions/signrank.js +24 -0
- package/dist/distributions/summary.d.ts +20 -2
- package/dist/distributions/summary.js +4 -0
- package/dist/distributions/t.d.ts +18 -0
- package/dist/distributions/t.js +18 -0
- package/dist/distributions/triangular.d.ts +36 -4
- package/dist/distributions/triangular.js +31 -3
- package/dist/distributions/tukey.d.ts +15 -1
- package/dist/distributions/tukey.js +10 -0
- package/dist/distributions/uniform.d.ts +29 -1
- package/dist/distributions/uniform.js +24 -0
- package/dist/distributions/weibull.d.ts +29 -1
- package/dist/distributions/weibull.js +24 -0
- package/dist/distributions/wilcox.d.ts +24 -0
- package/dist/distributions/wilcox.js +24 -0
- package/dist/distributions.js +2 -2
- package/dist/entries/descriptive.d.ts +5 -1
- package/dist/entries/descriptive.js +4 -0
- package/dist/entries/numerics.d.ts +1 -1
- package/dist/entries/tests.js +1 -1
- package/dist/htest/agreement.d.ts +61 -23
- package/dist/htest/agreement.js +19 -9
- package/dist/htest/ansariTest.d.ts +19 -1
- package/dist/htest/ansariTest.js +5 -17
- package/dist/htest/aov.d.ts +43 -10
- package/dist/htest/aov.js +17 -3
- package/dist/htest/binomTest.d.ts +12 -2
- package/dist/htest/binomTest.js +2 -0
- package/dist/htest/brunnerMunzelTest.d.ts +9 -3
- package/dist/htest/brunnerMunzelTest.js +4 -2
- package/dist/htest/chisqTest.d.ts +19 -3
- package/dist/htest/cor.d.ts +31 -3
- package/dist/htest/cor.js +9 -27
- package/dist/htest/effectSize.d.ts +70 -12
- package/dist/htest/effectSize.js +40 -7
- package/dist/htest/fisherTest.d.ts +9 -1
- package/dist/htest/fisherTest.js +2 -0
- package/dist/htest/groups.d.ts +5 -1
- package/dist/htest/ksTest.d.ts +32 -2
- package/dist/htest/ksTest.js +5 -8
- package/dist/htest/leveneTest.d.ts +15 -4
- package/dist/htest/leveneTest.js +5 -2
- package/dist/htest/mantelhaenTest.d.ts +25 -3
- package/dist/htest/mantelhaenTest.js +15 -1
- package/dist/htest/mcnemarTest.d.ts +14 -4
- package/dist/htest/mcnemarTest.js +4 -2
- package/dist/htest/multipleComparisons.d.ts +173 -29
- package/dist/htest/multipleComparisons.js +123 -19
- package/dist/htest/normalityTests.d.ts +56 -9
- package/dist/htest/normalityTests.js +40 -6
- package/dist/htest/onewayTest.d.ts +45 -2
- package/dist/htest/onewayTest.js +15 -7
- package/dist/htest/pAdjust.d.ts +9 -1
- package/dist/htest/pAdjust.js +2 -0
- package/dist/htest/pairwise.d.ts +50 -5
- package/dist/htest/pairwise.js +25 -0
- package/dist/htest/poissonTest.d.ts +12 -2
- package/dist/htest/poissonTest.js +2 -0
- package/dist/htest/polycor.d.ts +29 -10
- package/dist/htest/power.d.ts +60 -6
- package/dist/htest/power.js +6 -0
- package/dist/htest/propTest.d.ts +13 -2
- package/dist/htest/propTest.js +2 -0
- package/dist/htest/pwr.d.ts +286 -36
- package/dist/htest/pwr.js +116 -15
- package/dist/htest/rankTests.d.ts +132 -7
- package/dist/htest/rankTests.js +30 -33
- package/dist/htest/tTest.d.ts +32 -2
- package/dist/htest/tTest.js +19 -24
- package/dist/htest/testFormula.d.ts +57 -0
- package/dist/htest/testFormula.js +171 -0
- package/dist/htest/trendTests.d.ts +29 -8
- package/dist/htest/trendTests.js +8 -4
- package/dist/htest/types.d.ts +14 -2
- package/dist/htest/varTest.d.ts +46 -6
- package/dist/htest/varTest.js +11 -21
- package/dist/htest/wilcoxTest.d.ts +23 -1
- package/dist/htest/wilcoxTest.js +9 -24
- package/dist/internal/dpq.d.ts +4 -0
- package/dist/internal/noncentral.d.ts +2 -0
- package/dist/internal/vectorize.d.ts +4 -0
- package/dist/linalg/basic.d.ts +39 -5
- package/dist/linalg/basic.js +15 -0
- package/dist/linalg/chol.d.ts +26 -5
- package/dist/linalg/chol.js +7 -0
- package/dist/linalg/eigen.d.ts +16 -7
- package/dist/linalg/eigen.js +6 -5
- package/dist/linalg/expm.d.ts +15 -5
- package/dist/linalg/expm.js +5 -3
- package/dist/linalg/kappa.d.ts +21 -1
- package/dist/linalg/kappa.js +16 -0
- package/dist/linalg/lu.d.ts +30 -6
- package/dist/linalg/lu.js +15 -3
- package/dist/linalg/matrix.d.ts +4 -0
- package/dist/linalg/norm.d.ts +16 -1
- package/dist/linalg/norm.js +9 -0
- package/dist/linalg/ops.d.ts +168 -36
- package/dist/linalg/ops.js +116 -20
- package/dist/linalg/qr.d.ts +87 -12
- package/dist/linalg/qr.js +31 -0
- package/dist/linalg/schur.d.ts +8 -2
- package/dist/linalg/schur.js +3 -1
- package/dist/linalg/solve.d.ts +42 -6
- package/dist/linalg/solve.js +22 -0
- package/dist/linalg/svd.d.ts +12 -2
- package/dist/linalg/svd.js +2 -0
- package/dist/linalg.js +2 -2
- package/dist/models/anovaSequential.d.ts +26 -4
- package/dist/models/anovaSequential.js +3 -1
- package/dist/models/aovEz.d.ts +29 -6
- package/dist/models/aovEz.js +5 -2
- package/dist/models/aovStrata.d.ts +12 -2
- package/dist/models/carAnova.d.ts +9 -3
- package/dist/models/carAnova.js +4 -2
- package/dist/models/coxph.d.ts +33 -7
- package/dist/models/coxph.js +8 -3
- package/dist/models/glm.d.ts +128 -21
- package/dist/models/glm.js +71 -14
- package/dist/models/glmAnova.d.ts +30 -5
- package/dist/models/glmAnova.js +15 -2
- package/dist/models/glmConfint.d.ts +16 -2
- package/dist/models/glmConfint.js +9 -1
- package/dist/models/glmFamily.d.ts +27 -5
- package/dist/models/lm.d.ts +75 -17
- package/dist/models/lm.js +22 -4
- package/dist/models/mauchly.d.ts +20 -5
- package/dist/models/mauchly.js +7 -3
- package/dist/models/modelFrame.d.ts +5 -1
- package/dist/models/modelMatrix.d.ts +18 -4
- package/dist/models/modelMatrix.js +3 -1
- package/dist/models/survival.d.ts +41 -9
- package/dist/models/survival.js +10 -4
- package/dist/numerics/deriv.d.ts +21 -6
- package/dist/numerics/deriv.js +16 -5
- package/dist/numerics/integrate.d.ts +37 -7
- package/dist/numerics/integrate.js +8 -2
- package/dist/numerics/interp.d.ts +63 -12
- package/dist/numerics/interp.js +30 -6
- package/dist/numerics/ode.d.ts +15 -5
- package/dist/numerics/ode.js +5 -3
- package/dist/numerics.js +2 -2
- package/dist/optim/optim.d.ts +32 -8
- package/dist/optim/optim.js +8 -4
- package/dist/random/beta.d.ts +8 -0
- package/dist/random/beta.js +8 -0
- package/dist/random/binomial.d.ts +16 -0
- package/dist/random/binomial.js +16 -0
- package/dist/random/continuous.d.ts +51 -0
- package/dist/random/continuous.js +51 -0
- package/dist/random/extra.d.ts +66 -6
- package/dist/random/extra.js +66 -6
- package/dist/random/gamma.d.ts +33 -0
- package/dist/random/gamma.js +33 -0
- package/dist/random/hyper.d.ts +8 -0
- package/dist/random/hyper.js +8 -0
- package/dist/random/poisson.d.ts +25 -0
- package/dist/random/poisson.js +25 -0
- package/dist/random/r2dtable.d.ts +2 -0
- package/dist/random/r2dtable.js +2 -0
- package/dist/random/rank.d.ts +16 -0
- package/dist/random/rank.js +16 -0
- package/dist/random/rng.d.ts +49 -6
- package/dist/random/rng.js +29 -2
- package/dist/random/sample.d.ts +10 -2
- package/dist/random/sample.js +5 -1
- package/dist/random/streams.d.ts +13 -0
- package/dist/random/streams.js +13 -0
- package/dist/rstats.js +14 -14
- package/dist/special/besselIK.d.ts +11 -3
- package/dist/special/besselIK.js +6 -2
- package/dist/special/besselJY.d.ts +6 -2
- package/dist/special/besselJY.js +6 -2
- package/dist/special/beta.d.ts +16 -2
- package/dist/special/beta.js +16 -2
- package/dist/special/choose.d.ts +13 -5
- package/dist/special/choose.js +13 -5
- package/dist/special/erf.d.ts +8 -3
- package/dist/special/erf.js +8 -3
- package/dist/special/extra.d.ts +30 -10
- package/dist/special/extra.js +25 -9
- package/dist/special/gamma.d.ts +18 -2
- package/dist/special/gamma.js +18 -2
- package/dist/special/log1p.d.ts +16 -7
- package/dist/special/log1p.js +16 -7
- package/dist/special/psigamma.d.ts +9 -3
- package/dist/special/psigamma.js +9 -3
- package/dist/special/rCompatible.d.ts +5 -1
- package/dist/special.js +2 -2
- package/dist/tests.js +12 -13
- package/llms.txt +14 -0
- package/package.json +1 -1
- package/dist/chunks/chunk-AECGWZHD.js +0 -2
- package/dist/chunks/chunk-XWTZ4RTR.js +0 -2
|
@@ -1,16 +1,28 @@
|
|
|
1
1
|
import { type FormulaNode, type ParsedFormula, type Terms } from "./formula.js";
|
|
2
2
|
import { type DataFrame, type ModelFrame } from "./modelFrame.js";
|
|
3
3
|
import type { Sample } from "../htest/types.js";
|
|
4
|
-
/**
|
|
4
|
+
/**
|
|
5
|
+
* A contrast of a factor: R's `contr.treatment`, `contr.sum` or `contr.helmert`.
|
|
6
|
+
*
|
|
7
|
+
* @category Linear models and ANOVA
|
|
8
|
+
*/
|
|
5
9
|
export type ContrastName = "contr.treatment" | "contr.sum" | "contr.helmert";
|
|
6
|
-
/**
|
|
10
|
+
/**
|
|
11
|
+
* Options for {@link modelMatrix}.
|
|
12
|
+
*
|
|
13
|
+
* @category Linear models and ANOVA
|
|
14
|
+
*/
|
|
7
15
|
export interface ModelMatrixOptions {
|
|
8
16
|
/** A contrast per factor (default `"contr.treatment"`). */
|
|
9
17
|
contrasts?: Record<string, ContrastName>;
|
|
10
18
|
/** The order of the levels of a factor (`{ A: ["c", "a", "b"] }`), as `factor(x, levels = ...)` in R. */
|
|
11
19
|
levels?: Record<string, readonly string[]>;
|
|
12
20
|
}
|
|
13
|
-
/**
|
|
21
|
+
/**
|
|
22
|
+
* Result of {@link modelMatrix}.
|
|
23
|
+
*
|
|
24
|
+
* @category Linear models and ANOVA
|
|
25
|
+
*/
|
|
14
26
|
export interface ModelMatrixResult {
|
|
15
27
|
/** Column names, such as `"(Intercept)"`, `"Ab"`, `"Ab:Bq"`, `"x"`. */
|
|
16
28
|
colNames: string[];
|
|
@@ -69,7 +81,7 @@ export interface DesignOptions extends ModelMatrixOptions {
|
|
|
69
81
|
export declare function design(parsed: ParsedFormula, data: DataFrame, options?: DesignOptions, rhs?: FormulaNode | undefined): Design;
|
|
70
82
|
/**
|
|
71
83
|
* The model matrix of a formula on a data frame, with the attributes of R's `terms()`. Equivalent to R's
|
|
72
|
-
* `model.matrix(formula, data)
|
|
84
|
+
* `model.matrix(formula, data)`. With `contrasts.arg`, together with `attr(terms(formula), ...)`.
|
|
73
85
|
*
|
|
74
86
|
* Strings are factors (levels sorted by code point unless `levels` gives them), booleans factors with levels FALSE
|
|
75
87
|
* and TRUE, numbers numeric. Rows with a missing value (`null`, or `NaN` in a numeric column) in any variable of the
|
|
@@ -84,5 +96,7 @@ export declare function design(parsed: ParsedFormula, data: DataFrame, options?:
|
|
|
84
96
|
* m.colNames; // ["(Intercept)", "Ab"]
|
|
85
97
|
* m.x; // [[1, 0], [1, 1], [1, 0], [1, 1]]
|
|
86
98
|
* ```
|
|
99
|
+
*
|
|
100
|
+
* @category Linear models and ANOVA
|
|
87
101
|
*/
|
|
88
102
|
export declare function modelMatrix(formula: string, data: DataFrame, options?: ModelMatrixOptions): ModelMatrixResult;
|
|
@@ -136,7 +136,7 @@ export function design(parsed, data, options = {}, rhs = parsed.rhs) {
|
|
|
136
136
|
}
|
|
137
137
|
/**
|
|
138
138
|
* The model matrix of a formula on a data frame, with the attributes of R's `terms()`. Equivalent to R's
|
|
139
|
-
* `model.matrix(formula, data)
|
|
139
|
+
* `model.matrix(formula, data)`. With `contrasts.arg`, together with `attr(terms(formula), ...)`.
|
|
140
140
|
*
|
|
141
141
|
* Strings are factors (levels sorted by code point unless `levels` gives them), booleans factors with levels FALSE
|
|
142
142
|
* and TRUE, numbers numeric. Rows with a missing value (`null`, or `NaN` in a numeric column) in any variable of the
|
|
@@ -151,6 +151,8 @@ export function design(parsed, data, options = {}, rhs = parsed.rhs) {
|
|
|
151
151
|
* m.colNames; // ["(Intercept)", "Ab"]
|
|
152
152
|
* m.x; // [[1, 0], [1, 1], [1, 0], [1, 1]]
|
|
153
153
|
* ```
|
|
154
|
+
*
|
|
155
|
+
* @category Linear models and ANOVA
|
|
154
156
|
*/
|
|
155
157
|
export function modelMatrix(formula, data, options = {}) {
|
|
156
158
|
const d = design(parseFormula(formula), data, options);
|
|
@@ -1,10 +1,18 @@
|
|
|
1
1
|
import type { GroupLabel } from "../htest/groups.js";
|
|
2
|
-
/**
|
|
2
|
+
/**
|
|
3
|
+
* Options for {@link survdiff}.
|
|
4
|
+
*
|
|
5
|
+
* @category Survival analysis
|
|
6
|
+
*/
|
|
3
7
|
export interface SurvdiffOptions {
|
|
4
8
|
/** Exponent of the weights S(t-)^rho (pooled Kaplan-Meier estimate just before each event time). Default 0. */
|
|
5
9
|
rho?: number;
|
|
6
10
|
}
|
|
7
|
-
/**
|
|
11
|
+
/**
|
|
12
|
+
* Result of {@link survdiff}.
|
|
13
|
+
*
|
|
14
|
+
* @category Survival analysis
|
|
15
|
+
*/
|
|
8
16
|
export interface SurvdiffResult {
|
|
9
17
|
/** Number of observations per group */
|
|
10
18
|
n: number[];
|
|
@@ -21,9 +29,17 @@ export interface SurvdiffResult {
|
|
|
21
29
|
/** Upper chi-squared tail on (number of groups with a positive expected count) - 1 degrees of freedom */
|
|
22
30
|
pvalue: number;
|
|
23
31
|
}
|
|
24
|
-
/**
|
|
32
|
+
/**
|
|
33
|
+
* Confidence interval type of {@link survfit}.
|
|
34
|
+
*
|
|
35
|
+
* @category Survival analysis
|
|
36
|
+
*/
|
|
25
37
|
export type SurvfitConfType = "log" | "plain" | "log-log";
|
|
26
|
-
/**
|
|
38
|
+
/**
|
|
39
|
+
* Options for {@link survfit}.
|
|
40
|
+
*
|
|
41
|
+
* @category Survival analysis
|
|
42
|
+
*/
|
|
27
43
|
export interface SurvfitOptions {
|
|
28
44
|
/** Group labels, one per observation: one curve per group. Omitted: a single curve. */
|
|
29
45
|
group?: readonly GroupLabel[];
|
|
@@ -32,19 +48,29 @@ export interface SurvfitOptions {
|
|
|
32
48
|
/** Confidence level. Default 0.95. */
|
|
33
49
|
confInt?: number;
|
|
34
50
|
}
|
|
35
|
-
/**
|
|
51
|
+
/**
|
|
52
|
+
* Result of {@link survfit}: the rows of R's `summary(fit, censored = TRUE)` and the medians.
|
|
53
|
+
*
|
|
54
|
+
* @category Survival analysis
|
|
55
|
+
*/
|
|
36
56
|
export interface SurvfitResult {
|
|
37
57
|
/** Stratum of each row (`"group=<label>"`, or `"all"` for a single curve) */
|
|
38
58
|
strata: string[];
|
|
59
|
+
/** Time of each row (the distinct times of the stratum, censored ones included) */
|
|
39
60
|
time: number[];
|
|
61
|
+
/** Number at risk just before the time (R's `n.risk`) */
|
|
40
62
|
nRisk: number[];
|
|
63
|
+
/** Number of events at the time (R's `n.event`) */
|
|
41
64
|
nEvent: number[];
|
|
65
|
+
/** Number censored at the time (R's `n.censor`) */
|
|
42
66
|
nCensor: number[];
|
|
43
67
|
/** Kaplan-Meier estimate S(t) */
|
|
44
68
|
surv: number[];
|
|
45
69
|
/** Standard error of S(t) (S times the standard error of log S) */
|
|
46
70
|
stdErr: number[];
|
|
71
|
+
/** Lower limit of the pointwise confidence interval of S(t) */
|
|
47
72
|
lower: number[];
|
|
73
|
+
/** Upper limit of the pointwise confidence interval of S(t) */
|
|
48
74
|
upper: number[];
|
|
49
75
|
/** Per stratum, [median, lower limit, upper limit] (NaN for R's NA) */
|
|
50
76
|
median: number[][];
|
|
@@ -53,7 +79,7 @@ export interface SurvfitResult {
|
|
|
53
79
|
}
|
|
54
80
|
/**
|
|
55
81
|
* Test of the difference between survival curves: the G-rho family of Harrington and Fleming, the log-rank test for
|
|
56
|
-
* `rho = 0`. Equivalent to R's `survdiff(Surv(time, status) ~ group, rho = rho)
|
|
82
|
+
* `rho = 0`. Equivalent to R's `survival::survdiff()`. As `survdiff(Surv(time, status) ~ group, rho = rho)`.
|
|
57
83
|
*
|
|
58
84
|
* Rows with a missing time, status or group are dropped.
|
|
59
85
|
*
|
|
@@ -64,14 +90,18 @@ export interface SurvfitResult {
|
|
|
64
90
|
*
|
|
65
91
|
* @example
|
|
66
92
|
* ```ts
|
|
67
|
-
* survdiff([1, 2, 3, 4, 5, 6], [1, 1, 0, 1, 1, 1], ["a", "b", "a", "b", "a", "b"])
|
|
93
|
+
* const r = survdiff([1, 2, 3, 4, 5, 6], [1, 1, 0, 1, 1, 1], ["a", "b", "a", "b", "a", "b"]);
|
|
94
|
+
* r.chisq; // 0.073903
|
|
95
|
+
* r.pvalue; // 0.78574
|
|
68
96
|
* ```
|
|
97
|
+
*
|
|
98
|
+
* @category Survival analysis
|
|
69
99
|
*/
|
|
70
100
|
export declare function survdiff(time: readonly number[], status: readonly number[], group: readonly (GroupLabel | null)[], options?: SurvdiffOptions): SurvdiffResult;
|
|
71
101
|
/**
|
|
72
102
|
* Kaplan-Meier estimate of the survival function with Greenwood's standard error and pointwise confidence intervals.
|
|
73
|
-
* Equivalent to R's `summary(survfit(Surv(time, status) ~ group, conf.type, conf.int),
|
|
74
|
-
*
|
|
103
|
+
* Equivalent to R's `survival::survfit()`. As `summary(survfit(Surv(time, status) ~ group, conf.type, conf.int),
|
|
104
|
+
* censored = TRUE)`, with the medians and their confidence limits of `summary(fit)$table`.
|
|
75
105
|
*
|
|
76
106
|
* Rows with a missing time, status or group are dropped.
|
|
77
107
|
*
|
|
@@ -83,5 +113,7 @@ export declare function survdiff(time: readonly number[], status: readonly numbe
|
|
|
83
113
|
* ```ts
|
|
84
114
|
* survfit([1, 2, 2, 3, 4], [1, 1, 0, 1, 0]).surv; // [0.8, 0.6, 0.3, 0.3]
|
|
85
115
|
* ```
|
|
116
|
+
*
|
|
117
|
+
* @category Survival analysis
|
|
86
118
|
*/
|
|
87
119
|
export declare function survfit(time: readonly number[], status: readonly number[], options?: SurvfitOptions): SurvfitResult;
|
package/dist/models/survival.js
CHANGED
|
@@ -43,7 +43,7 @@ function prepare(time, status, group) {
|
|
|
43
43
|
}
|
|
44
44
|
/**
|
|
45
45
|
* Test of the difference between survival curves: the G-rho family of Harrington and Fleming, the log-rank test for
|
|
46
|
-
* `rho = 0`. Equivalent to R's `survdiff(Surv(time, status) ~ group, rho = rho)
|
|
46
|
+
* `rho = 0`. Equivalent to R's `survival::survdiff()`. As `survdiff(Surv(time, status) ~ group, rho = rho)`.
|
|
47
47
|
*
|
|
48
48
|
* Rows with a missing time, status or group are dropped.
|
|
49
49
|
*
|
|
@@ -54,8 +54,12 @@ function prepare(time, status, group) {
|
|
|
54
54
|
*
|
|
55
55
|
* @example
|
|
56
56
|
* ```ts
|
|
57
|
-
* survdiff([1, 2, 3, 4, 5, 6], [1, 1, 0, 1, 1, 1], ["a", "b", "a", "b", "a", "b"])
|
|
57
|
+
* const r = survdiff([1, 2, 3, 4, 5, 6], [1, 1, 0, 1, 1, 1], ["a", "b", "a", "b", "a", "b"]);
|
|
58
|
+
* r.chisq; // 0.073903
|
|
59
|
+
* r.pvalue; // 0.78574
|
|
58
60
|
* ```
|
|
61
|
+
*
|
|
62
|
+
* @category Survival analysis
|
|
59
63
|
*/
|
|
60
64
|
export function survdiff(time, status, group, options = {}) {
|
|
61
65
|
const { rho = 0 } = options;
|
|
@@ -144,8 +148,8 @@ function curveMedian(time, nEvent, curve) {
|
|
|
144
148
|
}
|
|
145
149
|
/**
|
|
146
150
|
* Kaplan-Meier estimate of the survival function with Greenwood's standard error and pointwise confidence intervals.
|
|
147
|
-
* Equivalent to R's `summary(survfit(Surv(time, status) ~ group, conf.type, conf.int),
|
|
148
|
-
*
|
|
151
|
+
* Equivalent to R's `survival::survfit()`. As `summary(survfit(Surv(time, status) ~ group, conf.type, conf.int),
|
|
152
|
+
* censored = TRUE)`, with the medians and their confidence limits of `summary(fit)$table`.
|
|
149
153
|
*
|
|
150
154
|
* Rows with a missing time, status or group are dropped.
|
|
151
155
|
*
|
|
@@ -157,6 +161,8 @@ function curveMedian(time, nEvent, curve) {
|
|
|
157
161
|
* ```ts
|
|
158
162
|
* survfit([1, 2, 2, 3, 4], [1, 1, 0, 1, 0]).surv; // [0.8, 0.6, 0.3, 0.3]
|
|
159
163
|
* ```
|
|
164
|
+
*
|
|
165
|
+
* @category Survival analysis
|
|
160
166
|
*/
|
|
161
167
|
export function survfit(time, status, options = {}) {
|
|
162
168
|
const { group, confType = "log", confInt = 0.95 } = options;
|
package/dist/numerics/deriv.d.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/**
|
|
2
|
+
* Options for {@link grad}, {@link jacobian} and {@link hessian}.
|
|
3
|
+
*
|
|
4
|
+
* @category Numerical methods
|
|
5
|
+
*/
|
|
2
6
|
export interface DerivOptions {
|
|
3
7
|
/** `"Richardson"` (default) or `"simple"` (forward difference; not for `hessian`). */
|
|
4
8
|
method?: "Richardson" | "simple";
|
|
@@ -12,26 +16,37 @@ export interface DerivOptions {
|
|
|
12
16
|
r?: number;
|
|
13
17
|
}
|
|
14
18
|
/**
|
|
15
|
-
* Gradient of a scalar function of a vector. Equivalent to `numDeriv::grad(func, x, method)
|
|
19
|
+
* Gradient of a scalar function of a vector. Equivalent to `numDeriv::grad(func, x, method)` in R.
|
|
16
20
|
*
|
|
17
21
|
* @example
|
|
18
22
|
* ```ts
|
|
19
|
-
* grad((x) => x[0]! ** 2 + Math.sin(x[1]!), [1, 0]); //
|
|
23
|
+
* grad((x) => x[0]! ** 2 + Math.sin(x[1]!), [1, 0]); // [2, 1]
|
|
20
24
|
* ```
|
|
25
|
+
*
|
|
26
|
+
* @category Numerical methods
|
|
21
27
|
*/
|
|
22
28
|
export declare function grad(func: (x: number[]) => number, x: readonly number[], options?: DerivOptions): number[];
|
|
23
29
|
/**
|
|
24
30
|
* Jacobian of a vector function of a vector: row i holds the derivatives of the i-th value. Equivalent to
|
|
25
|
-
* `numDeriv::jacobian(func, x, method)
|
|
31
|
+
* `numDeriv::jacobian(func, x, method)` in R.
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```ts
|
|
35
|
+
* jacobian((x) => [x[0]! * x[1]!, x[0]! + 2 * x[1]!], [2, 3]); // [[3, 2], [1, 2]]
|
|
36
|
+
* ```
|
|
37
|
+
*
|
|
38
|
+
* @category Numerical methods
|
|
26
39
|
*/
|
|
27
40
|
export declare function jacobian(func: (x: number[]) => readonly number[], x: readonly number[], options?: DerivOptions): number[][];
|
|
28
41
|
/**
|
|
29
42
|
* Hessian matrix of a scalar function of a vector, by Richardson extrapolation (Bates and Watts). Equivalent to
|
|
30
|
-
* `numDeriv::hessian(func, x)
|
|
43
|
+
* `numDeriv::hessian(func, x)` in R.
|
|
31
44
|
*
|
|
32
45
|
* @example
|
|
33
46
|
* ```ts
|
|
34
|
-
* hessian((x) => x[0]! ** 2 * x[1]
|
|
47
|
+
* hessian((x) => x[0]! ** 2 * x[1]! ** 2, [1, 2]); // [[8, 8], [8, 2]]
|
|
35
48
|
* ```
|
|
49
|
+
*
|
|
50
|
+
* @category Numerical methods
|
|
36
51
|
*/
|
|
37
52
|
export declare function hessian(func: (x: number[]) => number, x: readonly number[], options?: DerivOptions): number[][];
|
package/dist/numerics/deriv.js
CHANGED
|
@@ -38,12 +38,14 @@ function method(options) {
|
|
|
38
38
|
return m;
|
|
39
39
|
}
|
|
40
40
|
/**
|
|
41
|
-
* Gradient of a scalar function of a vector. Equivalent to `numDeriv::grad(func, x, method)
|
|
41
|
+
* Gradient of a scalar function of a vector. Equivalent to `numDeriv::grad(func, x, method)` in R.
|
|
42
42
|
*
|
|
43
43
|
* @example
|
|
44
44
|
* ```ts
|
|
45
|
-
* grad((x) => x[0]! ** 2 + Math.sin(x[1]!), [1, 0]); //
|
|
45
|
+
* grad((x) => x[0]! ** 2 + Math.sin(x[1]!), [1, 0]); // [2, 1]
|
|
46
46
|
* ```
|
|
47
|
+
*
|
|
48
|
+
* @category Numerical methods
|
|
47
49
|
*/
|
|
48
50
|
export function grad(func, x, options = {}) {
|
|
49
51
|
const xs = [...x];
|
|
@@ -74,7 +76,14 @@ export function grad(func, x, options = {}) {
|
|
|
74
76
|
}
|
|
75
77
|
/**
|
|
76
78
|
* Jacobian of a vector function of a vector: row i holds the derivatives of the i-th value. Equivalent to
|
|
77
|
-
* `numDeriv::jacobian(func, x, method)
|
|
79
|
+
* `numDeriv::jacobian(func, x, method)` in R.
|
|
80
|
+
*
|
|
81
|
+
* @example
|
|
82
|
+
* ```ts
|
|
83
|
+
* jacobian((x) => [x[0]! * x[1]!, x[0]! + 2 * x[1]!], [2, 3]); // [[3, 2], [1, 2]]
|
|
84
|
+
* ```
|
|
85
|
+
*
|
|
86
|
+
* @category Numerical methods
|
|
78
87
|
*/
|
|
79
88
|
export function jacobian(func, x, options = {}) {
|
|
80
89
|
const xs = [...x];
|
|
@@ -105,12 +114,14 @@ export function jacobian(func, x, options = {}) {
|
|
|
105
114
|
}
|
|
106
115
|
/**
|
|
107
116
|
* Hessian matrix of a scalar function of a vector, by Richardson extrapolation (Bates and Watts). Equivalent to
|
|
108
|
-
* `numDeriv::hessian(func, x)
|
|
117
|
+
* `numDeriv::hessian(func, x)` in R.
|
|
109
118
|
*
|
|
110
119
|
* @example
|
|
111
120
|
* ```ts
|
|
112
|
-
* hessian((x) => x[0]! ** 2 * x[1]
|
|
121
|
+
* hessian((x) => x[0]! ** 2 * x[1]! ** 2, [1, 2]); // [[8, 8], [8, 2]]
|
|
113
122
|
* ```
|
|
123
|
+
*
|
|
124
|
+
* @category Numerical methods
|
|
114
125
|
*/
|
|
115
126
|
export function hessian(func, x, options = {}) {
|
|
116
127
|
if ((options.method ?? "Richardson") !== "Richardson")
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/**
|
|
2
|
+
* Options for {@link integrate}.
|
|
3
|
+
*
|
|
4
|
+
* @category Numerical methods
|
|
5
|
+
*/
|
|
2
6
|
export interface IntegrateOptions {
|
|
3
7
|
/** Maximum number of subintervals. Default `100`. */
|
|
4
8
|
subdivisions?: number;
|
|
@@ -9,8 +13,13 @@ export interface IntegrateOptions {
|
|
|
9
13
|
/** Throw when QUADPACK reports a problem (default `true`); otherwise return the result with its code. */
|
|
10
14
|
stopOnError?: boolean;
|
|
11
15
|
}
|
|
12
|
-
/**
|
|
16
|
+
/**
|
|
17
|
+
* Result of {@link integrate}.
|
|
18
|
+
*
|
|
19
|
+
* @category Numerical methods
|
|
20
|
+
*/
|
|
13
21
|
export interface IntegrateResult {
|
|
22
|
+
/** The estimate of the integral. */
|
|
14
23
|
value: number;
|
|
15
24
|
/** Estimate of the absolute error. */
|
|
16
25
|
absError: number;
|
|
@@ -27,11 +36,17 @@ export interface IntegrateResult {
|
|
|
27
36
|
*
|
|
28
37
|
* @example
|
|
29
38
|
* ```ts
|
|
30
|
-
* integrate((x) => Math.exp(-x * x / 2), -Infinity, Infinity).value; // 2.
|
|
39
|
+
* integrate((x) => Math.exp(-x * x / 2), -Infinity, Infinity).value; // 2.506628274115034 (sqrt(2 pi) = 2.5066282746310002)
|
|
31
40
|
* ```
|
|
41
|
+
*
|
|
42
|
+
* @category Numerical methods
|
|
32
43
|
*/
|
|
33
44
|
export declare function integrate(f: (x: number) => number, lower: number, upper: number, options?: IntegrateOptions): IntegrateResult;
|
|
34
|
-
/**
|
|
45
|
+
/**
|
|
46
|
+
* Options for {@link optimize}.
|
|
47
|
+
*
|
|
48
|
+
* @category Numerical methods
|
|
49
|
+
*/
|
|
35
50
|
export interface OptimizeOptions {
|
|
36
51
|
/** Maximise instead of minimise. Default `false`. */
|
|
37
52
|
maximum?: boolean;
|
|
@@ -40,19 +55,27 @@ export interface OptimizeOptions {
|
|
|
40
55
|
}
|
|
41
56
|
/**
|
|
42
57
|
* Minimum (or maximum) of a function of one variable on an interval, by Brent's golden-section and parabolic
|
|
43
|
-
* search. Equivalent to R's `optimize()
|
|
58
|
+
* search. Equivalent to R's `optimize()`. `optimum` is the location (R's `minimum`/`maximum`) and `objective` the
|
|
44
59
|
* function there. `lower` must be less than `upper`, as in R.
|
|
45
60
|
*
|
|
46
61
|
* @example
|
|
47
62
|
* ```ts
|
|
48
63
|
* optimize((x) => (x - 1 / 3) ** 2, 0, 1).optimum; // 0.3333333333333333
|
|
49
64
|
* ```
|
|
65
|
+
*
|
|
66
|
+
* @category Numerical methods
|
|
50
67
|
*/
|
|
51
68
|
export declare function optimize(f: (x: number) => number, lower: number, upper: number, options?: OptimizeOptions): {
|
|
69
|
+
/** Location of the minimum or maximum (R's `minimum` or `maximum`). */
|
|
52
70
|
optimum: number;
|
|
71
|
+
/** Value of the function there. */
|
|
53
72
|
objective: number;
|
|
54
73
|
};
|
|
55
|
-
/**
|
|
74
|
+
/**
|
|
75
|
+
* Options for {@link uniroot}.
|
|
76
|
+
*
|
|
77
|
+
* @category Numerical methods
|
|
78
|
+
*/
|
|
56
79
|
export interface UnirootOptions {
|
|
57
80
|
/** Accuracy. Default `eps^0.25`. */
|
|
58
81
|
tol?: number;
|
|
@@ -68,8 +91,13 @@ export interface UnirootOptions {
|
|
|
68
91
|
/** f(upper), when already known. */
|
|
69
92
|
fUpper?: number;
|
|
70
93
|
}
|
|
71
|
-
/**
|
|
94
|
+
/**
|
|
95
|
+
* Result of {@link uniroot}.
|
|
96
|
+
*
|
|
97
|
+
* @category Numerical methods
|
|
98
|
+
*/
|
|
72
99
|
export interface UnirootResult {
|
|
100
|
+
/** The root found. */
|
|
73
101
|
root: number;
|
|
74
102
|
/** f at the root. */
|
|
75
103
|
fRoot: number;
|
|
@@ -87,5 +115,7 @@ export interface UnirootResult {
|
|
|
87
115
|
* ```ts
|
|
88
116
|
* uniroot((x) => x * x - 2, 0, 2, { tol: 1e-12 }).root; // 1.4142135623731364
|
|
89
117
|
* ```
|
|
118
|
+
*
|
|
119
|
+
* @category Numerical methods
|
|
90
120
|
*/
|
|
91
121
|
export declare function uniroot(f: (x: number) => number, lower: number, upper: number, options?: UnirootOptions): UnirootResult;
|
|
@@ -25,8 +25,10 @@ const TOL = Number.EPSILON ** 0.25;
|
|
|
25
25
|
*
|
|
26
26
|
* @example
|
|
27
27
|
* ```ts
|
|
28
|
-
* integrate((x) => Math.exp(-x * x / 2), -Infinity, Infinity).value; // 2.
|
|
28
|
+
* integrate((x) => Math.exp(-x * x / 2), -Infinity, Infinity).value; // 2.506628274115034 (sqrt(2 pi) = 2.5066282746310002)
|
|
29
29
|
* ```
|
|
30
|
+
*
|
|
31
|
+
* @category Numerical methods
|
|
30
32
|
*/
|
|
31
33
|
export function integrate(f, lower, upper, options = {}) {
|
|
32
34
|
const limit = options.subdivisions ?? 100;
|
|
@@ -59,13 +61,15 @@ export function integrate(f, lower, upper, options = {}) {
|
|
|
59
61
|
}
|
|
60
62
|
/**
|
|
61
63
|
* Minimum (or maximum) of a function of one variable on an interval, by Brent's golden-section and parabolic
|
|
62
|
-
* search. Equivalent to R's `optimize()
|
|
64
|
+
* search. Equivalent to R's `optimize()`. `optimum` is the location (R's `minimum`/`maximum`) and `objective` the
|
|
63
65
|
* function there. `lower` must be less than `upper`, as in R.
|
|
64
66
|
*
|
|
65
67
|
* @example
|
|
66
68
|
* ```ts
|
|
67
69
|
* optimize((x) => (x - 1 / 3) ** 2, 0, 1).optimum; // 0.3333333333333333
|
|
68
70
|
* ```
|
|
71
|
+
*
|
|
72
|
+
* @category Numerical methods
|
|
69
73
|
*/
|
|
70
74
|
export function optimize(f, lower, upper, options = {}) {
|
|
71
75
|
const maximum = options.maximum ?? false;
|
|
@@ -82,6 +86,8 @@ export function optimize(f, lower, upper, options = {}) {
|
|
|
82
86
|
* ```ts
|
|
83
87
|
* uniroot((x) => x * x - 2, 0, 2, { tol: 1e-12 }).root; // 1.4142135623731364
|
|
84
88
|
* ```
|
|
89
|
+
*
|
|
90
|
+
* @category Numerical methods
|
|
85
91
|
*/
|
|
86
92
|
export function uniroot(f, lower, upper, options = {}) {
|
|
87
93
|
const tol = options.tol ?? TOL;
|
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
import type { Sample } from "../htest/types.js";
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
/**
|
|
3
|
+
* How equal `x` values are merged before interpolating (R's `ties`): `"mean"`, `"min"` or `"max"` of their `y`, or a
|
|
4
|
+
* function of their `y` values.
|
|
5
|
+
*
|
|
6
|
+
* @category Numerical methods
|
|
7
|
+
*/
|
|
8
|
+
export type Ties = "mean" | "min" | "max" | ((v: number[]) => number);
|
|
9
|
+
/**
|
|
10
|
+
* Options for {@link approx}.
|
|
11
|
+
*
|
|
12
|
+
* @category Numerical methods
|
|
13
|
+
*/
|
|
4
14
|
export interface ApproxOptions {
|
|
5
15
|
/** Points to interpolate at. Default: `n` equally spaced points over the range of `x`. */
|
|
6
16
|
xout?: Sample;
|
|
@@ -26,20 +36,34 @@ export interface ApproxOptions {
|
|
|
26
36
|
* ```ts
|
|
27
37
|
* approx([1, 2, 3], [10, 20, 40], { xout: [1.5, 2.5] }).y; // [15, 30]
|
|
28
38
|
* ```
|
|
39
|
+
*
|
|
40
|
+
* @category Numerical methods
|
|
29
41
|
*/
|
|
30
42
|
export declare function approx(x: Sample, y: Sample, options?: ApproxOptions): {
|
|
43
|
+
/** The points interpolated at (`xout`, or the equally spaced points). */
|
|
31
44
|
x: number[];
|
|
45
|
+
/** The interpolated values, one per point of `x`. */
|
|
32
46
|
y: number[];
|
|
33
47
|
};
|
|
34
|
-
/**
|
|
48
|
+
/**
|
|
49
|
+
* Cubic spline method.
|
|
50
|
+
*
|
|
51
|
+
* @category Numerical methods
|
|
52
|
+
*/
|
|
35
53
|
export type SplineMethod = "fmm" | "natural" | "periodic" | "hyman";
|
|
36
|
-
/**
|
|
54
|
+
/**
|
|
55
|
+
* Options for {@link spline}.
|
|
56
|
+
*
|
|
57
|
+
* @category Numerical methods
|
|
58
|
+
*/
|
|
37
59
|
export interface SplineOptions {
|
|
38
60
|
/** Number of equally spaced points from `xmin` to `xmax`. Default `3 * x.length`. */
|
|
39
61
|
n?: number;
|
|
40
62
|
/** `"fmm"` (default), `"natural"`, `"periodic"` or `"hyman"`. */
|
|
41
63
|
method?: SplineMethod;
|
|
64
|
+
/** Left end of the equally spaced points. Default: the smallest `x`. */
|
|
42
65
|
xmin?: number;
|
|
66
|
+
/** Right end of the equally spaced points. Default: the largest `x`. */
|
|
43
67
|
xmax?: number;
|
|
44
68
|
/** Points to interpolate at (then `n`, `xmin` and `xmax` are not used). */
|
|
45
69
|
xout?: Sample;
|
|
@@ -53,12 +77,20 @@ export interface SplineOptions {
|
|
|
53
77
|
* ```ts
|
|
54
78
|
* spline([1, 2, 3, 4], [1, 4, 9, 16], { xout: [2.5] }).y; // [6.25]
|
|
55
79
|
* ```
|
|
80
|
+
*
|
|
81
|
+
* @category Numerical methods
|
|
56
82
|
*/
|
|
57
83
|
export declare function spline(x: Sample, y: Sample, options?: SplineOptions): {
|
|
84
|
+
/** The points interpolated at (`xout`, or the equally spaced points). */
|
|
58
85
|
x: number[];
|
|
86
|
+
/** The interpolated values, one per point of `x`. */
|
|
59
87
|
y: number[];
|
|
60
88
|
};
|
|
61
|
-
/**
|
|
89
|
+
/**
|
|
90
|
+
* Options for {@link splinefun}.
|
|
91
|
+
*
|
|
92
|
+
* @category Numerical methods
|
|
93
|
+
*/
|
|
62
94
|
export interface SplinefunOptions {
|
|
63
95
|
/** `"fmm"` (default), `"natural"`, `"periodic"`, `"monoH.FC"` or `"hyman"`. */
|
|
64
96
|
method?: SplineMethod | "monoH.FC";
|
|
@@ -67,7 +99,7 @@ export interface SplinefunOptions {
|
|
|
67
99
|
}
|
|
68
100
|
/**
|
|
69
101
|
* The cubic spline through the points, as a function of `x` and the order of derivative (0 to 3; a fraction is
|
|
70
|
-
* truncated, as R does). Equivalent to R's `splinefun()
|
|
102
|
+
* truncated, as R does). Equivalent to R's `splinefun()`. Except that the third derivative of `"monoH.FC"` is the
|
|
71
103
|
* exact one (see {@link splinefunH}).
|
|
72
104
|
*
|
|
73
105
|
* @example
|
|
@@ -76,28 +108,47 @@ export interface SplinefunOptions {
|
|
|
76
108
|
* s([2.5]); // [6.25]
|
|
77
109
|
* s([2.5], 1); // [5]
|
|
78
110
|
* ```
|
|
111
|
+
*
|
|
112
|
+
* @category Numerical methods
|
|
79
113
|
*/
|
|
80
114
|
export declare function splinefun(x: Sample, y: Sample, options?: SplinefunOptions): (xq: Sample, deriv?: number) => number[];
|
|
81
115
|
/**
|
|
82
116
|
* The cubic Hermite spline with values `y` and slopes `m` at the points `x`, as a function of `x` and the order of
|
|
83
|
-
* derivative (0 to 3; a fraction is truncated, as R does); linear outside the data. Equivalent to R's `splinefunH()
|
|
84
|
-
*
|
|
117
|
+
* derivative (0 to 3; a fraction is truncated, as R does); linear outside the data. Equivalent to R's `splinefunH()`.
|
|
118
|
+
* Except for the third derivative: on [x_i, x_{i+1}] it is the exact (6 m_i + 6 m_{i+1} - 12 delta) / h^2, with
|
|
85
119
|
* h = x_{i+1} - x_i and delta = (y_{i+1} - y_i) / h, where R divides by h only once (the two agree when h = 1).
|
|
86
120
|
*
|
|
87
121
|
* @example
|
|
88
122
|
* ```ts
|
|
89
123
|
* splinefunH([0, 2], [0, 0], [1, 1])([1], 3); // [3] (R: 6)
|
|
90
124
|
* ```
|
|
125
|
+
*
|
|
126
|
+
* @category Numerical methods
|
|
91
127
|
*/
|
|
92
128
|
export declare function splinefunH(x: Sample, y: Sample, m: Sample): (xq: Sample, deriv?: number) => number[];
|
|
93
129
|
/**
|
|
94
|
-
* Lagrange interpolation in barycentric form through the points (xi, yi). Equivalent to `pracma::barylag()
|
|
95
|
-
* points must lie within the range of the nodes.
|
|
130
|
+
* Lagrange interpolation in barycentric form through the points (xi, yi). Equivalent to `pracma::barylag()` in R.
|
|
131
|
+
* The points must lie within the range of the nodes.
|
|
132
|
+
*
|
|
133
|
+
* @example
|
|
134
|
+
* ```ts
|
|
135
|
+
* barylag([0, 1, 2], [1, 3, 7], [0.5, 1.5]); // [1.75, 4.75]
|
|
136
|
+
* ```
|
|
137
|
+
*
|
|
138
|
+
* @category Numerical methods
|
|
96
139
|
*/
|
|
97
140
|
export declare function barylag(xi: Sample, yi: Sample, x: Sample): number[];
|
|
98
141
|
/**
|
|
99
142
|
* The polynomial of degree 2n - 1 through n points with given values and derivatives (global Hermite
|
|
100
|
-
* interpolation, jStat's hermite), evaluated at `x`.
|
|
143
|
+
* interpolation, jStat's hermite), evaluated at `x`. Not an R function. Neither base R nor the recommended packages
|
|
144
|
+
* have it (for piecewise cubic Hermite interpolation, see {@link splinefunH}). Computed by divided differences on
|
|
145
|
+
* the doubled nodes.
|
|
146
|
+
*
|
|
147
|
+
* @example
|
|
148
|
+
* ```ts
|
|
149
|
+
* hermiteInterp([0, 1], [0, 1], [0, 0], [0.25, 0.5]); // [0.15625, 0.5]
|
|
150
|
+
* ```
|
|
151
|
+
*
|
|
152
|
+
* @category Numerical methods
|
|
101
153
|
*/
|
|
102
154
|
export declare function hermiteInterp(xi: Sample, yi: Sample, di: Sample, x: Sample): number[];
|
|
103
|
-
export {};
|