@numero-uno-jpn/rstats 1.17.0 → 1.19.0
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 +39 -0
- package/README.ja.md +7 -7
- package/README.md +7 -7
- package/dist/causal/mediationProcedures.js +18 -1
- package/dist/causal/moderation.js +11 -2
- package/dist/causal.js +2 -2
- package/dist/chunks/chunk-2S45NNTL.js +2 -0
- package/dist/chunks/chunk-4JFGT4PN.js +2 -0
- package/dist/chunks/chunk-4JRJU5F5.js +2 -0
- package/dist/chunks/{chunk-KY53MB3J.js → chunk-5NW4WT4F.js} +2 -2
- package/dist/chunks/chunk-6ZGEYAFC.js +2 -0
- package/dist/chunks/{chunk-XR7Y4ZV6.js → chunk-7D7FBLWD.js} +2 -2
- package/dist/chunks/chunk-ANFN3X2M.js +2 -0
- package/dist/chunks/{chunk-NCRL33PQ.js → chunk-AS2XTRHH.js} +2 -2
- package/dist/chunks/chunk-BJ5WAL2C.js +2 -0
- package/dist/chunks/{chunk-EIUK6TKF.js → chunk-CEOSH3H2.js} +2 -2
- package/dist/chunks/{chunk-VZSQAGL2.js → chunk-CMNKXRZF.js} +2 -2
- package/dist/chunks/{chunk-XEJX5HBJ.js → chunk-CNJLPH6W.js} +2 -2
- package/dist/chunks/{chunk-TTOJDLIQ.js → chunk-DXSVV47D.js} +2 -2
- package/dist/chunks/{chunk-GIIURG5X.js → chunk-FAKOND5W.js} +2 -2
- package/dist/chunks/chunk-FCGTZ6BD.js +2 -0
- package/dist/chunks/{chunk-O4D43LWM.js → chunk-FELX2TZZ.js} +2 -2
- package/dist/chunks/{chunk-EB45CDFA.js → chunk-G4B2SQR6.js} +2 -2
- package/dist/chunks/chunk-HPIZAWMT.js +2 -0
- package/dist/chunks/chunk-I5XUWUEV.js +2 -0
- package/dist/chunks/{chunk-JG4TWDQ4.js → chunk-ILQ4VWSD.js} +2 -2
- package/dist/chunks/chunk-JLFRYDYO.js +2 -0
- package/dist/chunks/{chunk-GTSK4IN4.js → chunk-JXKHFSGK.js} +1 -1
- package/dist/chunks/{chunk-YMI33F7W.js → chunk-LBU73UMS.js} +2 -2
- package/dist/chunks/{chunk-ZRKXHVTJ.js → chunk-LSZTDKIB.js} +2 -2
- package/dist/chunks/chunk-LWFKGF43.js +2 -0
- package/dist/chunks/{chunk-NCDPZSI2.js → chunk-M5J3DHXB.js} +2 -2
- package/dist/chunks/{chunk-DD2GG4EC.js → chunk-MOYWWJP4.js} +1 -1
- package/dist/chunks/{chunk-I2KJMF4G.js → chunk-MPBFXHXT.js} +1 -1
- package/dist/chunks/chunk-NWNJEAKI.js +2 -0
- package/dist/chunks/{chunk-GOYTZ5RB.js → chunk-OTETSONJ.js} +2 -2
- package/dist/chunks/{chunk-V54MBEJM.js → chunk-QH4GK3JN.js} +2 -2
- package/dist/chunks/chunk-QVE7V5UG.js +2 -0
- package/dist/chunks/{chunk-RNGDVSTS.js → chunk-RMGEIU4Z.js} +2 -2
- package/dist/chunks/{chunk-LKKUUREA.js → chunk-SAFH76DR.js} +2 -2
- package/dist/chunks/{chunk-QCPGV7XH.js → chunk-SJJJ7Y4X.js} +2 -2
- package/dist/chunks/{chunk-L77QFL3C.js → chunk-TVU4N6BA.js} +2 -2
- package/dist/chunks/{chunk-6MLDKHTY.js → chunk-U6RXYALO.js} +2 -2
- package/dist/chunks/chunk-VNLSP22M.js +2 -0
- package/dist/chunks/chunk-W4EITKLJ.js +2 -0
- package/dist/chunks/{chunk-JHABMYNH.js → chunk-WWRKCRTZ.js} +1 -1
- package/dist/chunks/{chunk-NPWWGIFG.js → chunk-XHHDBEHB.js} +2 -2
- package/dist/chunks/{chunk-72I7GDWL.js → chunk-XJMBX6A2.js} +2 -2
- package/dist/chunks/chunk-YZ6SBFFG.js +2 -0
- package/dist/descriptive/qcc.d.ts +320 -0
- package/dist/descriptive/qcc.js +524 -0
- package/dist/descriptive/qccTools.d.ts +301 -0
- package/dist/descriptive/qccTools.js +390 -0
- package/dist/descriptive.js +2 -2
- package/dist/distributions/normal.d.ts +4 -0
- package/dist/distributions/normal.js +4 -2
- package/dist/distributions.js +2 -2
- package/dist/entries/descriptive.d.ts +2 -0
- package/dist/entries/descriptive.js +2 -0
- package/dist/entries/regression.d.ts +1 -0
- package/dist/entries/regression.js +2 -0
- package/dist/entries/tests.d.ts +1 -0
- package/dist/entries/tests.js +1 -0
- package/dist/htest/timeROC.d.ts +564 -0
- package/dist/htest/timeROC.js +1106 -0
- package/dist/linalg.js +2 -2
- package/dist/mixed.js +2 -2
- package/dist/models/betareg.js +14 -2
- package/dist/models/bradleyterry.d.ts +188 -0
- package/dist/models/bradleyterry.js +533 -0
- package/dist/models/survreg.d.ts +5 -0
- package/dist/models/survreg.js +23 -3
- package/dist/models/tobit.js +16 -5
- package/dist/multivariate.js +2 -2
- package/dist/numerics.js +2 -2
- package/dist/regression.js +3 -3
- package/dist/rstats.js +18 -18
- package/dist/special.js +2 -2
- package/dist/tests.js +15 -15
- package/dist/timeseries.js +2 -2
- package/package.json +1 -1
- package/dist/chunks/chunk-23QCIPET.js +0 -2
- package/dist/chunks/chunk-3UEYA6VG.js +0 -2
- package/dist/chunks/chunk-3Y4DNK4O.js +0 -2
- package/dist/chunks/chunk-4BGGWQWS.js +0 -2
- package/dist/chunks/chunk-5UFVACSV.js +0 -2
- package/dist/chunks/chunk-5W2OZAHQ.js +0 -2
- package/dist/chunks/chunk-BWDXJL7T.js +0 -2
- package/dist/chunks/chunk-GLABB425.js +0 -2
- package/dist/chunks/chunk-JV3POOET.js +0 -2
- package/dist/chunks/chunk-K3YSXDTU.js +0 -2
- package/dist/chunks/chunk-LY2UZGUL.js +0 -2
- package/dist/chunks/chunk-PSQ6MLJM.js +0 -2
- package/dist/chunks/chunk-RM5D7Q7W.js +0 -2
- package/dist/chunks/chunk-SA2E5GVO.js +0 -2
- package/dist/chunks/chunk-T5ZALLTJ.js +0 -2
- package/dist/chunks/chunk-XPYZOG5H.js +0 -2
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
import type { DataFrame } from "./modelFrame.js";
|
|
2
|
+
/**
|
|
3
|
+
* Options for {@link btm}.
|
|
4
|
+
* @category Regression
|
|
5
|
+
*/
|
|
6
|
+
export interface BtmOptions {
|
|
7
|
+
/** The outcome: two columns of wins (`[win1, win2]`, as `cbind(win1, win2)`) or one column, 1 when player1 won. */
|
|
8
|
+
outcome: string | readonly [string, string];
|
|
9
|
+
/** The column of the first player of each contest. */
|
|
10
|
+
player1: string;
|
|
11
|
+
/** The column of the second player. */
|
|
12
|
+
player2: string;
|
|
13
|
+
/**
|
|
14
|
+
* The model of the abilities, without a response: `"~ .."` (default, one ability per player), `"~ .. + home"` (with
|
|
15
|
+
* a contest-level variable from `contestCovariates`), or player covariates indexed by the player with random player
|
|
16
|
+
* effects, `"~ x[..] + z[..] + (1 | ..)"` (fitted by PQL; the covariates in `predictors`).
|
|
17
|
+
*/
|
|
18
|
+
formula?: string;
|
|
19
|
+
/** Player covariates: one row per player, in the order of `levels`. */
|
|
20
|
+
predictors?: DataFrame;
|
|
21
|
+
/** The players in order (default: the sorted distinct players of both columns). */
|
|
22
|
+
levels?: readonly string[];
|
|
23
|
+
/** Contest-level variables specific to each player: name -> [column for player1, column for player2]. */
|
|
24
|
+
contestCovariates?: Readonly<Record<string, readonly [string, string]>>;
|
|
25
|
+
/** The reference player, whose ability is 0 (default the first level). */
|
|
26
|
+
refcat?: string;
|
|
27
|
+
/** The link (default `"logit"`). */
|
|
28
|
+
link?: "logit" | "probit" | "cauchit";
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Result of {@link btm}.
|
|
32
|
+
* @category Regression
|
|
33
|
+
*/
|
|
34
|
+
export interface BtmResult {
|
|
35
|
+
/** The fixed coefficients. */
|
|
36
|
+
coefficients: number[];
|
|
37
|
+
/** Their names (`..B` for a player's ability, `x[..]` for a covariate, `..p03` for a separate ability). */
|
|
38
|
+
coefNames: string[];
|
|
39
|
+
/** Their standard errors. */
|
|
40
|
+
stdError: number[];
|
|
41
|
+
/** z = coefficient / standard error. */
|
|
42
|
+
statistic: number[];
|
|
43
|
+
/** The two-sided p-values of the z statistics. */
|
|
44
|
+
pValue: number[];
|
|
45
|
+
/** The covariance matrix of the fixed coefficients (varFix for PQL). */
|
|
46
|
+
vcov: number[][];
|
|
47
|
+
/** Deviance, null deviance and AIC of a model without random effects (NaN with random effects, as BTm). */
|
|
48
|
+
deviance: number;
|
|
49
|
+
/** The deviance of the model with all abilities 0 (NaN with random effects). */
|
|
50
|
+
nullDeviance: number;
|
|
51
|
+
/** Akaike's information criterion (NaN with random effects). */
|
|
52
|
+
aic: number;
|
|
53
|
+
/** The residual degrees of freedom: contests minus fixed coefficients. */
|
|
54
|
+
dfResidual: number;
|
|
55
|
+
/** The degrees of freedom of the null model: the number of contests. */
|
|
56
|
+
dfNull: number;
|
|
57
|
+
/** Iterations: of the glm, or of the outer PQL search. */
|
|
58
|
+
iter: number;
|
|
59
|
+
/** Whether the fit converged. */
|
|
60
|
+
converged: boolean;
|
|
61
|
+
/** The fitted probability that player1 wins, and the linear predictor (with the random effects). */
|
|
62
|
+
fittedValues: number[];
|
|
63
|
+
/** The linear predictor of each contest. */
|
|
64
|
+
linearPredictors: number[];
|
|
65
|
+
/** The players. */
|
|
66
|
+
levels: string[];
|
|
67
|
+
/** The reference player. */
|
|
68
|
+
refcat: string;
|
|
69
|
+
/** The link. */
|
|
70
|
+
link: "logit" | "probit" | "cauchit";
|
|
71
|
+
/** The standard deviation of the random player effects (null without them; 0 at the boundary). */
|
|
72
|
+
sigma: number | null;
|
|
73
|
+
/** The variance of sigma (null without random effects or at sigma = 0). */
|
|
74
|
+
varSigma: number | null;
|
|
75
|
+
/** The predicted random effects, one per player (null without them). */
|
|
76
|
+
random: number[] | null;
|
|
77
|
+
/** Players with a missing covariate, given an ability of their own. */
|
|
78
|
+
separate: string[];
|
|
79
|
+
/** R's warnings. */
|
|
80
|
+
warnings: string[];
|
|
81
|
+
/** How each player's ability is formed from the coefficients (for {@link btAbilities}). */
|
|
82
|
+
abilityDesign: number[][];
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* A Bradley-Terry model for paired comparisons: the probability that player1 beats player2 is
|
|
86
|
+
* `link^-1(lambda_1 - lambda_2)`. With `"~ .."` each player has an ability (the reference's is 0) and the model is the
|
|
87
|
+
* binomial glm without intercept on the +1 / -1 design of the two players; contest-level variables add their
|
|
88
|
+
* difference. With player covariates and random player effects (`"~ x[..] + (1 | ..)"`) the abilities are
|
|
89
|
+
* `x_j' beta + e_j`, `e ~ N(0, sigma^2)`, fitted by PQL to the fixed point where sigma maximizes the REML likelihood of
|
|
90
|
+
* the working linear mixed model (BTm stops at its tolerance, about 1e-7 from it); sigma at the boundary 0 gives the
|
|
91
|
+
* glm. A player with a missing covariate gets an ability of its own (as BTm).
|
|
92
|
+
*
|
|
93
|
+
* Equivalent to `BradleyTerry2::BTm()` in R.
|
|
94
|
+
*
|
|
95
|
+
* @param contests one row per contest, or per pair with the numbers of wins
|
|
96
|
+
* @category Regression
|
|
97
|
+
*/
|
|
98
|
+
export declare function btm(contests: DataFrame, options: BtmOptions): BtmResult;
|
|
99
|
+
/**
|
|
100
|
+
* Result of {@link btAbilities}.
|
|
101
|
+
* @category Regression
|
|
102
|
+
*/
|
|
103
|
+
export interface BtAbilitiesResult {
|
|
104
|
+
/** The players. */
|
|
105
|
+
levels: string[];
|
|
106
|
+
/** The ability of each player. */
|
|
107
|
+
ability: number[];
|
|
108
|
+
/** Standard errors (0 for the reference player). */
|
|
109
|
+
se: number[];
|
|
110
|
+
/** The covariance matrix of the abilities (a zero row for the reference). */
|
|
111
|
+
vcov: number[][];
|
|
112
|
+
/** Players whose ability was estimated separately (a missing covariate). */
|
|
113
|
+
separate: string[];
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* The abilities of the players of a Bradley-Terry model. They are the estimated abilities with the reference at 0,
|
|
117
|
+
* or, for abilities modelled by player covariates, `x_j' beta` (without the random effects) with
|
|
118
|
+
* standard errors from the covariance of beta; contest-level variables are taken as 0.
|
|
119
|
+
*
|
|
120
|
+
* Equivalent to `BradleyTerry2::BTabilities()` in R.
|
|
121
|
+
* @category Regression
|
|
122
|
+
*/
|
|
123
|
+
export declare function btAbilities(fit: BtmResult): BtAbilitiesResult;
|
|
124
|
+
/**
|
|
125
|
+
* Result of {@link countsToBinomial}.
|
|
126
|
+
* @category Regression
|
|
127
|
+
*/
|
|
128
|
+
export interface CountsToBinomialResult {
|
|
129
|
+
/** The first player of each pair. */
|
|
130
|
+
player1: string[];
|
|
131
|
+
/** The second player of each pair. */
|
|
132
|
+
player2: string[];
|
|
133
|
+
/** The wins of player1 over player2. */
|
|
134
|
+
win1: number[];
|
|
135
|
+
/** The wins of player2 over player1. */
|
|
136
|
+
win2: number[];
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* The wins of each pair of players from a table of wins. The rows of the table are the winners, the columns the
|
|
140
|
+
* losers. One row per pair i < j (in the order of the levels) that met at least once.
|
|
141
|
+
*
|
|
142
|
+
* Equivalent to `BradleyTerry2::countsToBinomial()` in R.
|
|
143
|
+
* @category Regression
|
|
144
|
+
*/
|
|
145
|
+
export declare function countsToBinomial(table: readonly (readonly number[])[], levels: readonly string[]): CountsToBinomialResult;
|
|
146
|
+
/**
|
|
147
|
+
* Result of {@link qvcalc}.
|
|
148
|
+
* @category Regression
|
|
149
|
+
*/
|
|
150
|
+
export interface QvcalcResult {
|
|
151
|
+
/** The levels. */
|
|
152
|
+
names: string[];
|
|
153
|
+
/** The estimates. */
|
|
154
|
+
estimate: number[];
|
|
155
|
+
/** Their standard errors. */
|
|
156
|
+
se: number[];
|
|
157
|
+
/** The quasi standard errors. */
|
|
158
|
+
quasiSE: number[];
|
|
159
|
+
/** The quasi variances. */
|
|
160
|
+
quasiVar: number[];
|
|
161
|
+
/** Relative errors of the quasi standard errors of the simple contrasts (pairs "A,B", ...). */
|
|
162
|
+
relerrs: number[];
|
|
163
|
+
/** The pairs of the relative errors, "A,B", ... */
|
|
164
|
+
relerrsNames: string[];
|
|
165
|
+
/** The covariance matrix used. */
|
|
166
|
+
covmat: number[][];
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Quasi variances (Firth 2003). They are the q_j minimizing `sum_{i<j} (log(q_i + q_j) - log var(b_i - b_j))^2`,
|
|
170
|
+
* so that `q_i + q_j` approximates the variance of every simple contrast. Accepts the abilities of a Bradley-Terry
|
|
171
|
+
* model or estimates with their covariance matrix.
|
|
172
|
+
*
|
|
173
|
+
* Equivalent to `qvcalc::qvcalc()` in R.
|
|
174
|
+
* @category Regression
|
|
175
|
+
*/
|
|
176
|
+
export declare function qvcalc(object: BtAbilitiesResult | {
|
|
177
|
+
estimate: readonly number[];
|
|
178
|
+
vcov: readonly (readonly number[])[];
|
|
179
|
+
names?: readonly string[];
|
|
180
|
+
}): QvcalcResult;
|
|
181
|
+
/**
|
|
182
|
+
* The worst relative errors of the quasi standard errors over all contrasts. They are the square roots
|
|
183
|
+
* of the extreme eigenvalues of `(C'VC)^-1 C'QC` minus 1, over a basis C of the contrasts, Q = diag(quasiVar).
|
|
184
|
+
*
|
|
185
|
+
* Equivalent to `qvcalc::worstErrors()` in R.
|
|
186
|
+
* @category Regression
|
|
187
|
+
*/
|
|
188
|
+
export declare function worstErrors(qv: QvcalcResult): [number, number];
|