@elaraai/east-py-datascience 1.0.11 → 1.0.13
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 -1
- package/dist/src/causal/causal.d.ts +1377 -1383
- package/dist/src/causal/causal.d.ts.map +1 -1
- package/dist/src/causal/causal.js +266 -478
- package/dist/src/causal/causal.js.map +1 -1
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +2 -2
- package/dist/src/index.js.map +1 -1
- package/package.json +3 -3
|
@@ -5,15 +5,18 @@
|
|
|
5
5
|
/**
|
|
6
6
|
* Causal inference for East.
|
|
7
7
|
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
8
|
+
* One declarative entry point — {@link Causal.experiment} — answers *"did X
|
|
9
|
+
* change Y, and can I trust it?"* for a binary treatment: the naive vs
|
|
10
|
+
* backdoor-adjusted effect, confounder balance, propensity overlap, a
|
|
11
|
+
* robustness check, and an honesty **verdict** that refuses (`adjusted = none`)
|
|
12
|
+
* when the data can't support an answer. The raw DoWhy / EconML / PyALE
|
|
13
|
+
* estimators are internal implementation it composes — not a public surface.
|
|
11
14
|
*
|
|
12
15
|
* @packageDocumentation
|
|
13
16
|
*/
|
|
14
|
-
import { StructType, VariantType, OptionType, ArrayType, IntegerType, FloatType, BooleanType, StringType,
|
|
15
|
-
import { VectorType
|
|
16
|
-
export { VectorType
|
|
17
|
+
import { StructType, VariantType, OptionType, ArrayType, IntegerType, FloatType, BooleanType, StringType, NullType } from "@elaraai/east";
|
|
18
|
+
import { VectorType } from "../types.js";
|
|
19
|
+
export { VectorType } from "../types.js";
|
|
17
20
|
/**
|
|
18
21
|
* Inverse propensity weighting scheme for the propensity score
|
|
19
22
|
* weighting estimator.
|
|
@@ -30,7 +33,7 @@ export declare const CausalWeightingSchemeType: VariantType<{
|
|
|
30
33
|
* Backdoor-adjusted effect estimator.
|
|
31
34
|
*/
|
|
32
35
|
export declare const CausalEstimatorType: VariantType<{
|
|
33
|
-
/** Linear regression of outcome on treatment + common causes */
|
|
36
|
+
/** Linear regression of outcome on treatment + common causes (default) */
|
|
34
37
|
readonly linear_regression: NullType;
|
|
35
38
|
/** Inverse propensity score weighting (binary treatment only) */
|
|
36
39
|
readonly propensity_score_weighting: StructType<{
|
|
@@ -56,58 +59,56 @@ export declare const CausalTargetUnitsType: VariantType<{
|
|
|
56
59
|
/** Average treatment effect on the controls */
|
|
57
60
|
readonly atc: NullType;
|
|
58
61
|
}>;
|
|
59
|
-
/**
|
|
60
|
-
* Propensity-based sample trimming applied before estimation
|
|
61
|
-
* (propensity score weighting only).
|
|
62
|
-
*/
|
|
63
|
-
export declare const PropensityTrimType: VariantType<{
|
|
64
|
-
/** Keep units inside the common-support overlap of treated and control propensities */
|
|
65
|
-
readonly overlap: NullType;
|
|
66
|
-
/** Keep units with propensity inside explicit bounds */
|
|
67
|
-
readonly bounds: StructType<{
|
|
68
|
-
/** Minimum propensity score to keep */
|
|
69
|
-
readonly lower: FloatType;
|
|
70
|
-
/** Maximum propensity score to keep */
|
|
71
|
-
readonly upper: FloatType;
|
|
72
|
-
}>;
|
|
73
|
-
}>;
|
|
74
62
|
/**
|
|
75
63
|
* Bootstrap confidence interval configuration.
|
|
76
64
|
*
|
|
77
|
-
* When `cluster_column` is set, whole clusters are resampled with
|
|
78
|
-
*
|
|
79
|
-
*
|
|
65
|
+
* When `cluster_column` is set, whole clusters are resampled with replacement
|
|
66
|
+
* (the cluster is the exchangeable unit) — use this when rows are autocorrelated
|
|
67
|
+
* within a group.
|
|
80
68
|
*/
|
|
81
69
|
export declare const CausalBootstrapConfigType: StructType<{
|
|
82
|
-
/** Number of bootstrap replicates */
|
|
70
|
+
/** Number of bootstrap replicates (default 200) */
|
|
83
71
|
readonly reps: IntegerType;
|
|
84
72
|
/** Column whose values identify clusters to resample (default: resample rows) */
|
|
85
73
|
readonly cluster_column: OptionType<StringType>;
|
|
86
74
|
/** Confidence level for the percentile interval (default 0.95) */
|
|
87
75
|
readonly confidence_level: OptionType<FloatType>;
|
|
88
76
|
}>;
|
|
77
|
+
/** A confidence interval — the one CI type used across the result. */
|
|
78
|
+
export declare const CiType: StructType<{
|
|
79
|
+
readonly lower: FloatType;
|
|
80
|
+
readonly upper: FloatType;
|
|
81
|
+
}>;
|
|
89
82
|
/**
|
|
90
|
-
*
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
83
|
+
* Which robustness checks to run inside {@link causal_experiment}.
|
|
84
|
+
*/
|
|
85
|
+
export declare const RefuteSpecType: StructType<{
|
|
86
|
+
/** Permuted-treatment negative control — a real effect should vanish. */
|
|
87
|
+
readonly placebo: BooleanType;
|
|
88
|
+
/** Inject an independent random common cause — the effect should hold. */
|
|
89
|
+
readonly random_common_cause: BooleanType;
|
|
90
|
+
/** Re-estimate on random subsamples — the effect should be stable. */
|
|
91
|
+
readonly data_subset: BooleanType;
|
|
92
|
+
/** Unobserved-confounder strengths to simulate → the sensitivity / tipping curve. */
|
|
93
|
+
readonly sensitivity: OptionType<ArrayType<FloatType>>;
|
|
94
|
+
}>;
|
|
95
|
+
/**
|
|
96
|
+
* Configuration for {@link causal_experiment} — the staged "question + method"
|
|
97
|
+
* the surface edits. Binary treatment only (v1). Reuses the estimator / target
|
|
98
|
+
* / bootstrap vocabularies.
|
|
96
99
|
*/
|
|
97
|
-
export declare const
|
|
98
|
-
/**
|
|
99
|
-
readonly columns: ArrayType<StringType>;
|
|
100
|
-
/** Treatment column (must be 0/1 for propensity score weighting) */
|
|
100
|
+
export declare const CausalExperimentConfigType: StructType<{
|
|
101
|
+
/** Binary (0/1) treatment column. */
|
|
101
102
|
readonly treatment: StringType;
|
|
102
|
-
/** Outcome column */
|
|
103
|
+
/** Outcome column. */
|
|
103
104
|
readonly outcome: StringType;
|
|
104
|
-
/**
|
|
105
|
+
/** Confounders to adjust for (the backdoor set). */
|
|
105
106
|
readonly common_causes: ArrayType<StringType>;
|
|
106
|
-
/**
|
|
107
|
+
/** Confounder columns holding categories (string or int codes), one-hot encoded. */
|
|
107
108
|
readonly categorical: OptionType<ArrayType<StringType>>;
|
|
108
|
-
/**
|
|
109
|
+
/** Estimator (default: linear_regression). */
|
|
109
110
|
readonly method: OptionType<VariantType<{
|
|
110
|
-
/** Linear regression of outcome on treatment + common causes */
|
|
111
|
+
/** Linear regression of outcome on treatment + common causes (default) */
|
|
111
112
|
readonly linear_regression: NullType;
|
|
112
113
|
/** Inverse propensity score weighting (binary treatment only) */
|
|
113
114
|
readonly propensity_score_weighting: StructType<{
|
|
@@ -122,8 +123,8 @@ export declare const CausalEffectConfigType: StructType<{
|
|
|
122
123
|
}>>;
|
|
123
124
|
}>;
|
|
124
125
|
}>>;
|
|
125
|
-
/** Target population (default: ate) */
|
|
126
|
-
readonly
|
|
126
|
+
/** Target population (default: ate). */
|
|
127
|
+
readonly estimand: OptionType<VariantType<{
|
|
127
128
|
/** Average treatment effect over all units */
|
|
128
129
|
readonly ate: NullType;
|
|
129
130
|
/** Average treatment effect on the treated */
|
|
@@ -131,281 +132,211 @@ export declare const CausalEffectConfigType: StructType<{
|
|
|
131
132
|
/** Average treatment effect on the controls */
|
|
132
133
|
readonly atc: NullType;
|
|
133
134
|
}>>;
|
|
134
|
-
/**
|
|
135
|
-
readonly
|
|
136
|
-
/**
|
|
137
|
-
readonly
|
|
138
|
-
/**
|
|
139
|
-
readonly
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
}>;
|
|
135
|
+
/** Which robustness checks to run. */
|
|
136
|
+
readonly refute: OptionType<StructType<{
|
|
137
|
+
/** Permuted-treatment negative control — a real effect should vanish. */
|
|
138
|
+
readonly placebo: BooleanType;
|
|
139
|
+
/** Inject an independent random common cause — the effect should hold. */
|
|
140
|
+
readonly random_common_cause: BooleanType;
|
|
141
|
+
/** Re-estimate on random subsamples — the effect should be stable. */
|
|
142
|
+
readonly data_subset: BooleanType;
|
|
143
|
+
/** Unobserved-confounder strengths to simulate → the sensitivity / tipping curve. */
|
|
144
|
+
readonly sensitivity: OptionType<ArrayType<FloatType>>;
|
|
145
145
|
}>>;
|
|
146
|
-
/**
|
|
146
|
+
/** Continuous column for the ALE dose-response curve (the "How much?" view). */
|
|
147
|
+
readonly dose_feature: OptionType<StringType>;
|
|
148
|
+
/** Positivity guard — common-support fraction below this → non_identifiable_positivity (default 0.10). */
|
|
149
|
+
readonly min_overlap: OptionType<FloatType>;
|
|
150
|
+
/** Not-estimable guard — minority-arm fraction below this → not_estimable (default 0.02). */
|
|
151
|
+
readonly min_treatment_variation: OptionType<FloatType>;
|
|
152
|
+
/** Bootstrap CI config (default: 200 reps, 0.95). */
|
|
147
153
|
readonly bootstrap: OptionType<StructType<{
|
|
148
|
-
/** Number of bootstrap replicates */
|
|
154
|
+
/** Number of bootstrap replicates (default 200) */
|
|
149
155
|
readonly reps: IntegerType;
|
|
150
156
|
/** Column whose values identify clusters to resample (default: resample rows) */
|
|
151
157
|
readonly cluster_column: OptionType<StringType>;
|
|
152
158
|
/** Confidence level for the percentile interval (default 0.95) */
|
|
153
159
|
readonly confidence_level: OptionType<FloatType>;
|
|
154
160
|
}>>;
|
|
155
|
-
/** Random seed
|
|
161
|
+
/** Random seed. */
|
|
156
162
|
readonly random_state: OptionType<IntegerType>;
|
|
157
163
|
}>;
|
|
158
|
-
/**
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
readonly
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
readonly random_common_cause: StructType<{
|
|
169
|
-
/** Number of simulations (default 100) */
|
|
170
|
-
readonly num_simulations: OptionType<IntegerType>;
|
|
171
|
-
}>;
|
|
172
|
-
/** Re-estimate on random data subsets - effect should be stable */
|
|
173
|
-
readonly data_subset: StructType<{
|
|
174
|
-
/** Fraction of rows kept per simulation (default 0.8) */
|
|
175
|
-
readonly subset_fraction: OptionType<FloatType>;
|
|
176
|
-
/** Number of simulations (default 100) */
|
|
177
|
-
readonly num_simulations: OptionType<IntegerType>;
|
|
178
|
-
}>;
|
|
179
|
-
/**
|
|
180
|
-
* Simulate an unobserved confounder at each given strength - a
|
|
181
|
-
* sensitivity/tipping curve. Strength acts on both treatment
|
|
182
|
-
* (flip probability for binary treatment, linear coefficient otherwise)
|
|
183
|
-
* and outcome (linear coefficient).
|
|
184
|
-
*/
|
|
185
|
-
readonly unobserved_common_cause: StructType<{
|
|
186
|
-
/** Confounder effect strengths to simulate, one new effect per entry */
|
|
187
|
-
readonly effect_strengths: ArrayType<FloatType>;
|
|
188
|
-
}>;
|
|
164
|
+
/** One confounder's before-adjustment imbalance (categoricals → one row per level). */
|
|
165
|
+
export declare const BalanceRowType: StructType<{
|
|
166
|
+
readonly column: StringType;
|
|
167
|
+
/** The original confounder this row belongs to — equals `column` for a numeric
|
|
168
|
+
* confounder; the base confounder for a one-hot categorical level. */
|
|
169
|
+
readonly base_column: StringType;
|
|
170
|
+
readonly treated_mean: FloatType;
|
|
171
|
+
readonly control_mean: FloatType;
|
|
172
|
+
/** Standardized mean difference, (mt-mc)/sqrt((vt+vc)/2). */
|
|
173
|
+
readonly std_diff: FloatType;
|
|
189
174
|
}>;
|
|
190
|
-
/**
|
|
191
|
-
|
|
192
|
-
*/
|
|
193
|
-
|
|
194
|
-
/**
|
|
195
|
-
readonly
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
/** Maximum tree depth (default unlimited) */
|
|
201
|
-
readonly max_depth: OptionType<IntegerType>;
|
|
202
|
-
}>;
|
|
203
|
-
/** Gradient boosting (regressor, or classifier for a discrete treatment) */
|
|
204
|
-
readonly gradient_boosting: StructType<{
|
|
205
|
-
/** Number of boosting stages (default 100) */
|
|
206
|
-
readonly n_estimators: OptionType<IntegerType>;
|
|
207
|
-
/** Learning rate (default 0.1) */
|
|
208
|
-
readonly learning_rate: OptionType<FloatType>;
|
|
209
|
-
/** Maximum tree depth (default 3) */
|
|
210
|
-
readonly max_depth: OptionType<IntegerType>;
|
|
211
|
-
}>;
|
|
212
|
-
/** Linear/logistic regression */
|
|
213
|
-
readonly linear: NullType;
|
|
175
|
+
/** Positivity / common-support diagnostic (binary treatment). */
|
|
176
|
+
export declare const OverlapDiagnosticType: StructType<{
|
|
177
|
+
/** Propensity histogram (20 bins over [0,1]) for the treated arm. */
|
|
178
|
+
readonly treated_propensity: VectorType<FloatType>;
|
|
179
|
+
/** Propensity histogram for the control arm. */
|
|
180
|
+
readonly control_propensity: VectorType<FloatType>;
|
|
181
|
+
/** Fraction of rows inside the treated/control common support. */
|
|
182
|
+
readonly common_support_frac: FloatType;
|
|
183
|
+
/** Whether common support clears `min_overlap`. */
|
|
184
|
+
readonly positivity_ok: BooleanType;
|
|
214
185
|
}>;
|
|
215
|
-
/**
|
|
216
|
-
|
|
217
|
-
*/
|
|
218
|
-
|
|
219
|
-
/**
|
|
220
|
-
readonly
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
readonly
|
|
232
|
-
|
|
233
|
-
readonly n_estimators: OptionType<IntegerType>;
|
|
234
|
-
/** Learning rate (default 0.1) */
|
|
235
|
-
readonly learning_rate: OptionType<FloatType>;
|
|
236
|
-
/** Maximum tree depth (default 3) */
|
|
237
|
-
readonly max_depth: OptionType<IntegerType>;
|
|
238
|
-
}>;
|
|
239
|
-
/** Linear/logistic regression */
|
|
240
|
-
readonly linear: NullType;
|
|
186
|
+
/** The robustness summary the verdict + Trust tab consume. */
|
|
187
|
+
export declare const RefutationType: StructType<{
|
|
188
|
+
/** Effect under a permuted (placebo) treatment — should be ≈ 0. */
|
|
189
|
+
readonly placebo_effect: OptionType<FloatType>;
|
|
190
|
+
/** Whether the placebo effect vanished. */
|
|
191
|
+
readonly placebo_passes: OptionType<BooleanType>;
|
|
192
|
+
/** Whether a decoy random common cause left the estimate inside its CI. */
|
|
193
|
+
readonly random_cc_within_ci: OptionType<BooleanType>;
|
|
194
|
+
/** Mean effect across data subsamples (stability). */
|
|
195
|
+
readonly data_subset_effect: OptionType<FloatType>;
|
|
196
|
+
/** Std of the effect across data subsamples. */
|
|
197
|
+
readonly data_subset_std: OptionType<FloatType>;
|
|
198
|
+
/** Closed-form E-value — confounder strength needed to explain the effect away. */
|
|
199
|
+
readonly robustness_value: OptionType<FloatType>;
|
|
200
|
+
/** Unobserved-confounder sensitivity (tipping) curve: effect at each simulated strength. */
|
|
201
|
+
readonly sensitivity: OptionType<StructType<{
|
|
202
|
+
readonly strengths: VectorType<FloatType>;
|
|
203
|
+
readonly effects: VectorType<FloatType>;
|
|
241
204
|
}>>;
|
|
242
|
-
/** Nuisance model for the treatment stage (default: random_forest) */
|
|
243
|
-
readonly model_t: OptionType<VariantType<{
|
|
244
|
-
/** Random forest (regressor, or classifier for a discrete treatment) */
|
|
245
|
-
readonly random_forest: StructType<{
|
|
246
|
-
/** Number of trees (default 100) */
|
|
247
|
-
readonly n_estimators: OptionType<IntegerType>;
|
|
248
|
-
/** Minimum samples per leaf (default 5) */
|
|
249
|
-
readonly min_samples_leaf: OptionType<IntegerType>;
|
|
250
|
-
/** Maximum tree depth (default unlimited) */
|
|
251
|
-
readonly max_depth: OptionType<IntegerType>;
|
|
252
|
-
}>;
|
|
253
|
-
/** Gradient boosting (regressor, or classifier for a discrete treatment) */
|
|
254
|
-
readonly gradient_boosting: StructType<{
|
|
255
|
-
/** Number of boosting stages (default 100) */
|
|
256
|
-
readonly n_estimators: OptionType<IntegerType>;
|
|
257
|
-
/** Learning rate (default 0.1) */
|
|
258
|
-
readonly learning_rate: OptionType<FloatType>;
|
|
259
|
-
/** Maximum tree depth (default 3) */
|
|
260
|
-
readonly max_depth: OptionType<IntegerType>;
|
|
261
|
-
}>;
|
|
262
|
-
/** Linear/logistic regression */
|
|
263
|
-
readonly linear: NullType;
|
|
264
|
-
}>>;
|
|
265
|
-
/** Treat the treatment as discrete/categorical (default false) */
|
|
266
|
-
readonly discrete_treatment: OptionType<BooleanType>;
|
|
267
|
-
/** Cross-fitting folds (default 2) */
|
|
268
|
-
readonly cv_folds: OptionType<IntegerType>;
|
|
269
|
-
/** Confidence level for effect/ATE intervals (default 0.95) */
|
|
270
|
-
readonly confidence_level: OptionType<FloatType>;
|
|
271
|
-
/** Random seed */
|
|
272
|
-
readonly random_state: OptionType<IntegerType>;
|
|
273
205
|
}>;
|
|
274
|
-
/**
|
|
275
|
-
|
|
276
|
-
*
|
|
277
|
-
* Fits a gradient-boosting emulator of the outcome on all non-outcome
|
|
278
|
-
* columns, then computes the correlation-robust ALE curve of `feature`.
|
|
279
|
-
*/
|
|
280
|
-
export declare const CausalALEConfigType: StructType<{
|
|
281
|
-
/** Column names for the data matrix (one per column, in order) */
|
|
282
|
-
readonly columns: ArrayType<StringType>;
|
|
283
|
-
/** Outcome column the emulator predicts */
|
|
284
|
-
readonly outcome: StringType;
|
|
285
|
-
/** Continuous feature column to compute the ALE curve for */
|
|
206
|
+
/** A dose-response (ALE) curve of a continuous feature on the outcome. */
|
|
207
|
+
export declare const DoseResponseType: StructType<{
|
|
286
208
|
readonly feature: StringType;
|
|
287
|
-
|
|
288
|
-
readonly
|
|
289
|
-
|
|
290
|
-
readonly
|
|
291
|
-
/**
|
|
292
|
-
readonly
|
|
293
|
-
/** Confidence level for the CI (default 0.95) */
|
|
294
|
-
readonly confidence_level: OptionType<FloatType>;
|
|
295
|
-
/** Emulator (HistGradientBoosting) hyperparameters */
|
|
296
|
-
readonly emulator: OptionType<StructType<{
|
|
297
|
-
/** Number of boosting iterations (default 300) */
|
|
298
|
-
readonly n_estimators: OptionType<IntegerType>;
|
|
299
|
-
/** Learning rate (default 0.05) */
|
|
300
|
-
readonly learning_rate: OptionType<FloatType>;
|
|
301
|
-
/** Maximum tree depth (default unlimited) */
|
|
302
|
-
readonly max_depth: OptionType<IntegerType>;
|
|
303
|
-
/** Minimum samples per leaf (default 20; lower for small datasets) */
|
|
304
|
-
readonly min_samples_leaf: OptionType<IntegerType>;
|
|
305
|
-
}>>;
|
|
306
|
-
/** Random seed for the emulator */
|
|
307
|
-
readonly random_state: OptionType<IntegerType>;
|
|
209
|
+
readonly grid: VectorType<FloatType>;
|
|
210
|
+
readonly effect: VectorType<FloatType>;
|
|
211
|
+
readonly lower: OptionType<VectorType<FloatType>>;
|
|
212
|
+
readonly upper: OptionType<VectorType<FloatType>>;
|
|
213
|
+
/** Rows per dose bin — drives the surface's "you are here" (busiest bin) marker. */
|
|
214
|
+
readonly size: VectorType<IntegerType>;
|
|
308
215
|
}>;
|
|
309
216
|
/**
|
|
310
|
-
*
|
|
217
|
+
* The honesty verdict — a thin tag; the numbers live top-level on the result.
|
|
218
|
+
* Only `not_estimable` carries a (human-readable) reason.
|
|
311
219
|
*/
|
|
312
|
-
export declare const
|
|
313
|
-
/**
|
|
314
|
-
readonly
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
220
|
+
export declare const ExperimentVerdictType: VariantType<{
|
|
221
|
+
/** A real, robust, material effect. */
|
|
222
|
+
readonly causal: NullType;
|
|
223
|
+
/** A small but real effect, or no clear effect after adjustment. */
|
|
224
|
+
readonly modest: NullType;
|
|
225
|
+
/** Adjusted, but the estimate isn't trustworthy (placebo fails). */
|
|
226
|
+
readonly adjustment_insufficient: NullType;
|
|
227
|
+
/** No like-for-like comparison exists (positivity violated). */
|
|
228
|
+
readonly non_identifiable_positivity: NullType;
|
|
229
|
+
/** The estimand can't be formed (treatment barely varies). */
|
|
230
|
+
readonly not_estimable: StringType;
|
|
322
231
|
}>;
|
|
323
232
|
/**
|
|
324
|
-
*
|
|
233
|
+
* The complete, honest result of {@link causal_experiment}. `adjusted` is
|
|
234
|
+
* `none` when the engine refuses (positivity / no-variation); the `verdict` tag
|
|
235
|
+
* carries the headline; every word/colour on the surface derives from these numbers.
|
|
325
236
|
*/
|
|
326
|
-
export declare const
|
|
327
|
-
/**
|
|
328
|
-
readonly
|
|
329
|
-
|
|
330
|
-
readonly ci: OptionType<StructType<{
|
|
331
|
-
/** Lower bound */
|
|
237
|
+
export declare const CausalExperimentResultType: StructType<{
|
|
238
|
+
/** The raw (unadjusted) mean difference — always computable. */
|
|
239
|
+
readonly naive: FloatType;
|
|
240
|
+
readonly naive_ci: OptionType<StructType<{
|
|
332
241
|
readonly lower: FloatType;
|
|
333
|
-
/** Upper bound */
|
|
334
242
|
readonly upper: FloatType;
|
|
335
243
|
}>>;
|
|
336
|
-
/**
|
|
337
|
-
readonly
|
|
338
|
-
|
|
244
|
+
/** The adjusted (like-for-like) effect + CI; `none` ⇒ the engine refused. */
|
|
245
|
+
readonly adjusted: OptionType<StructType<{
|
|
246
|
+
readonly effect: FloatType;
|
|
247
|
+
readonly ci: OptionType<StructType<{
|
|
248
|
+
readonly lower: FloatType;
|
|
249
|
+
readonly upper: FloatType;
|
|
250
|
+
}>>;
|
|
251
|
+
}>>;
|
|
252
|
+
readonly n_total: IntegerType;
|
|
339
253
|
readonly n_treated: IntegerType;
|
|
340
|
-
/** Control rows used */
|
|
341
254
|
readonly n_control: IntegerType;
|
|
255
|
+
readonly n_dropped: IntegerType;
|
|
256
|
+
/** Per-confounder before-adjustment imbalance, most-imbalanced first. */
|
|
257
|
+
readonly balance: ArrayType<StructType<{
|
|
258
|
+
readonly column: StringType;
|
|
259
|
+
/** The original confounder this row belongs to — equals `column` for a numeric
|
|
260
|
+
* confounder; the base confounder for a one-hot categorical level. */
|
|
261
|
+
readonly base_column: StringType;
|
|
262
|
+
readonly treated_mean: FloatType;
|
|
263
|
+
readonly control_mean: FloatType;
|
|
264
|
+
/** Standardized mean difference, (mt-mc)/sqrt((vt+vc)/2). */
|
|
265
|
+
readonly std_diff: FloatType;
|
|
266
|
+
}>>;
|
|
267
|
+
readonly overlap: StructType<{
|
|
268
|
+
/** Propensity histogram (20 bins over [0,1]) for the treated arm. */
|
|
269
|
+
readonly treated_propensity: VectorType<FloatType>;
|
|
270
|
+
/** Propensity histogram for the control arm. */
|
|
271
|
+
readonly control_propensity: VectorType<FloatType>;
|
|
272
|
+
/** Fraction of rows inside the treated/control common support. */
|
|
273
|
+
readonly common_support_frac: FloatType;
|
|
274
|
+
/** Whether common support clears `min_overlap`. */
|
|
275
|
+
readonly positivity_ok: BooleanType;
|
|
276
|
+
}>;
|
|
277
|
+
readonly refutation: OptionType<StructType<{
|
|
278
|
+
/** Effect under a permuted (placebo) treatment — should be ≈ 0. */
|
|
279
|
+
readonly placebo_effect: OptionType<FloatType>;
|
|
280
|
+
/** Whether the placebo effect vanished. */
|
|
281
|
+
readonly placebo_passes: OptionType<BooleanType>;
|
|
282
|
+
/** Whether a decoy random common cause left the estimate inside its CI. */
|
|
283
|
+
readonly random_cc_within_ci: OptionType<BooleanType>;
|
|
284
|
+
/** Mean effect across data subsamples (stability). */
|
|
285
|
+
readonly data_subset_effect: OptionType<FloatType>;
|
|
286
|
+
/** Std of the effect across data subsamples. */
|
|
287
|
+
readonly data_subset_std: OptionType<FloatType>;
|
|
288
|
+
/** Closed-form E-value — confounder strength needed to explain the effect away. */
|
|
289
|
+
readonly robustness_value: OptionType<FloatType>;
|
|
290
|
+
/** Unobserved-confounder sensitivity (tipping) curve: effect at each simulated strength. */
|
|
291
|
+
readonly sensitivity: OptionType<StructType<{
|
|
292
|
+
readonly strengths: VectorType<FloatType>;
|
|
293
|
+
readonly effects: VectorType<FloatType>;
|
|
294
|
+
}>>;
|
|
295
|
+
}>>;
|
|
296
|
+
/** ALE dose-response of `dose_feature` (present when `config.dose_feature` is set). */
|
|
297
|
+
readonly dose_response: OptionType<StructType<{
|
|
298
|
+
readonly feature: StringType;
|
|
299
|
+
readonly grid: VectorType<FloatType>;
|
|
300
|
+
readonly effect: VectorType<FloatType>;
|
|
301
|
+
readonly lower: OptionType<VectorType<FloatType>>;
|
|
302
|
+
readonly upper: OptionType<VectorType<FloatType>>;
|
|
303
|
+
/** Rows per dose bin — drives the surface's "you are here" (busiest bin) marker. */
|
|
304
|
+
readonly size: VectorType<IntegerType>;
|
|
305
|
+
}>>;
|
|
306
|
+
readonly verdict: VariantType<{
|
|
307
|
+
/** A real, robust, material effect. */
|
|
308
|
+
readonly causal: NullType;
|
|
309
|
+
/** A small but real effect, or no clear effect after adjustment. */
|
|
310
|
+
readonly modest: NullType;
|
|
311
|
+
/** Adjusted, but the estimate isn't trustworthy (placebo fails). */
|
|
312
|
+
readonly adjustment_insufficient: NullType;
|
|
313
|
+
/** No like-for-like comparison exists (positivity violated). */
|
|
314
|
+
readonly non_identifiable_positivity: NullType;
|
|
315
|
+
/** The estimand can't be formed (treatment barely varies). */
|
|
316
|
+
readonly not_estimable: StringType;
|
|
317
|
+
}>;
|
|
342
318
|
}>;
|
|
343
319
|
/**
|
|
344
|
-
*
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
/** The original estimated effect being refuted */
|
|
348
|
-
readonly estimated_effect: FloatType;
|
|
349
|
-
/**
|
|
350
|
-
* Effect under the refutation. One entry for placebo/random-common-cause/
|
|
351
|
-
* data-subset; one entry per strength for unobserved_common_cause.
|
|
352
|
-
*/
|
|
353
|
-
readonly new_effects: VectorType<FloatType>;
|
|
354
|
-
/** Refutation p-value where the refuter provides one */
|
|
355
|
-
readonly p_value: OptionType<FloatType>;
|
|
356
|
-
}>;
|
|
357
|
-
/**
|
|
358
|
-
* Average treatment effect with confidence interval.
|
|
359
|
-
*/
|
|
360
|
-
export declare const CausalATEResultType: StructType<{
|
|
361
|
-
/** Average treatment effect over the given X */
|
|
362
|
-
readonly ate: FloatType;
|
|
363
|
-
/** Lower bound at the model's confidence level */
|
|
364
|
-
readonly lower: FloatType;
|
|
365
|
-
/** Upper bound at the model's confidence level */
|
|
366
|
-
readonly upper: FloatType;
|
|
367
|
-
}>;
|
|
368
|
-
/**
|
|
369
|
-
* Accumulated local effects curve.
|
|
370
|
-
*/
|
|
371
|
-
export declare const ALEResultType: StructType<{
|
|
372
|
-
/** Feature grid values (interval edges) */
|
|
373
|
-
readonly grid: VectorType<FloatType>;
|
|
374
|
-
/** Centered ALE effect at each grid value (outcome units) */
|
|
375
|
-
readonly effect: VectorType<FloatType>;
|
|
376
|
-
/** Lower CI at each grid value (present when include_ci) */
|
|
377
|
-
readonly lower: OptionType<VectorType<FloatType>>;
|
|
378
|
-
/** Upper CI at each grid value (present when include_ci) */
|
|
379
|
-
readonly upper: OptionType<VectorType<FloatType>>;
|
|
380
|
-
/** Number of samples in each grid interval */
|
|
381
|
-
readonly size: VectorType<IntegerType>;
|
|
382
|
-
}>;
|
|
383
|
-
/**
|
|
384
|
-
* Estimate a backdoor-adjusted causal effect of treatment on outcome.
|
|
385
|
-
*
|
|
386
|
-
* Identifies the effect with DoWhy given the common causes, then estimates
|
|
387
|
-
* it by linear regression or inverse propensity score weighting. Optionally
|
|
388
|
-
* trims to propensity common support and computes a (cluster) bootstrap
|
|
389
|
-
* confidence interval.
|
|
320
|
+
* One declarative causal experiment — naive vs adjusted effect, balance,
|
|
321
|
+
* overlap, robustness, and an honesty verdict, in a single call. Generic over
|
|
322
|
+
* the row struct (fields = columns), binary treatment.
|
|
390
323
|
*
|
|
391
|
-
* @param data -
|
|
392
|
-
* @param config -
|
|
393
|
-
* @returns
|
|
324
|
+
* @param data - Array of row structs (one per unit; fields are the columns)
|
|
325
|
+
* @param config - The experiment configuration
|
|
326
|
+
* @returns The honest result + verdict; `adjusted` is `none` when refused
|
|
394
327
|
*/
|
|
395
|
-
export declare const
|
|
396
|
-
/**
|
|
397
|
-
readonly columns: ArrayType<StringType>;
|
|
398
|
-
/** Treatment column (must be 0/1 for propensity score weighting) */
|
|
328
|
+
export declare const causal_experiment: import("@elaraai/east").GenericPlatformDefinition<readonly ["T"], readonly [ArrayType<unknown>, StructType<{
|
|
329
|
+
/** Binary (0/1) treatment column. */
|
|
399
330
|
readonly treatment: StringType;
|
|
400
|
-
/** Outcome column */
|
|
331
|
+
/** Outcome column. */
|
|
401
332
|
readonly outcome: StringType;
|
|
402
|
-
/**
|
|
333
|
+
/** Confounders to adjust for (the backdoor set). */
|
|
403
334
|
readonly common_causes: ArrayType<StringType>;
|
|
404
|
-
/**
|
|
335
|
+
/** Confounder columns holding categories (string or int codes), one-hot encoded. */
|
|
405
336
|
readonly categorical: OptionType<ArrayType<StringType>>;
|
|
406
|
-
/**
|
|
337
|
+
/** Estimator (default: linear_regression). */
|
|
407
338
|
readonly method: OptionType<VariantType<{
|
|
408
|
-
/** Linear regression of outcome on treatment + common causes */
|
|
339
|
+
/** Linear regression of outcome on treatment + common causes (default) */
|
|
409
340
|
readonly linear_regression: NullType;
|
|
410
341
|
/** Inverse propensity score weighting (binary treatment only) */
|
|
411
342
|
readonly propensity_score_weighting: StructType<{
|
|
@@ -420,8 +351,8 @@ export declare const causal_effect: import("@elaraai/east").PlatformDefinition<[
|
|
|
420
351
|
}>>;
|
|
421
352
|
}>;
|
|
422
353
|
}>>;
|
|
423
|
-
/** Target population (default: ate) */
|
|
424
|
-
readonly
|
|
354
|
+
/** Target population (default: ate). */
|
|
355
|
+
readonly estimand: OptionType<VariantType<{
|
|
425
356
|
/** Average treatment effect over all units */
|
|
426
357
|
readonly ate: NullType;
|
|
427
358
|
/** Average treatment effect on the treated */
|
|
@@ -429,72 +360,236 @@ export declare const causal_effect: import("@elaraai/east").PlatformDefinition<[
|
|
|
429
360
|
/** Average treatment effect on the controls */
|
|
430
361
|
readonly atc: NullType;
|
|
431
362
|
}>>;
|
|
432
|
-
/**
|
|
433
|
-
readonly
|
|
434
|
-
/**
|
|
435
|
-
readonly
|
|
436
|
-
/**
|
|
437
|
-
readonly
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
}>;
|
|
363
|
+
/** Which robustness checks to run. */
|
|
364
|
+
readonly refute: OptionType<StructType<{
|
|
365
|
+
/** Permuted-treatment negative control — a real effect should vanish. */
|
|
366
|
+
readonly placebo: BooleanType;
|
|
367
|
+
/** Inject an independent random common cause — the effect should hold. */
|
|
368
|
+
readonly random_common_cause: BooleanType;
|
|
369
|
+
/** Re-estimate on random subsamples — the effect should be stable. */
|
|
370
|
+
readonly data_subset: BooleanType;
|
|
371
|
+
/** Unobserved-confounder strengths to simulate → the sensitivity / tipping curve. */
|
|
372
|
+
readonly sensitivity: OptionType<ArrayType<FloatType>>;
|
|
443
373
|
}>>;
|
|
444
|
-
/**
|
|
374
|
+
/** Continuous column for the ALE dose-response curve (the "How much?" view). */
|
|
375
|
+
readonly dose_feature: OptionType<StringType>;
|
|
376
|
+
/** Positivity guard — common-support fraction below this → non_identifiable_positivity (default 0.10). */
|
|
377
|
+
readonly min_overlap: OptionType<FloatType>;
|
|
378
|
+
/** Not-estimable guard — minority-arm fraction below this → not_estimable (default 0.02). */
|
|
379
|
+
readonly min_treatment_variation: OptionType<FloatType>;
|
|
380
|
+
/** Bootstrap CI config (default: 200 reps, 0.95). */
|
|
445
381
|
readonly bootstrap: OptionType<StructType<{
|
|
446
|
-
/** Number of bootstrap replicates */
|
|
382
|
+
/** Number of bootstrap replicates (default 200) */
|
|
447
383
|
readonly reps: IntegerType;
|
|
448
384
|
/** Column whose values identify clusters to resample (default: resample rows) */
|
|
449
385
|
readonly cluster_column: OptionType<StringType>;
|
|
450
386
|
/** Confidence level for the percentile interval (default 0.95) */
|
|
451
387
|
readonly confidence_level: OptionType<FloatType>;
|
|
452
388
|
}>>;
|
|
453
|
-
/** Random seed
|
|
389
|
+
/** Random seed. */
|
|
454
390
|
readonly random_state: OptionType<IntegerType>;
|
|
455
391
|
}>], StructType<{
|
|
456
|
-
/**
|
|
457
|
-
readonly
|
|
458
|
-
|
|
459
|
-
readonly ci: OptionType<StructType<{
|
|
460
|
-
/** Lower bound */
|
|
392
|
+
/** The raw (unadjusted) mean difference — always computable. */
|
|
393
|
+
readonly naive: FloatType;
|
|
394
|
+
readonly naive_ci: OptionType<StructType<{
|
|
461
395
|
readonly lower: FloatType;
|
|
462
|
-
/** Upper bound */
|
|
463
396
|
readonly upper: FloatType;
|
|
464
397
|
}>>;
|
|
465
|
-
/**
|
|
466
|
-
readonly
|
|
467
|
-
|
|
398
|
+
/** The adjusted (like-for-like) effect + CI; `none` ⇒ the engine refused. */
|
|
399
|
+
readonly adjusted: OptionType<StructType<{
|
|
400
|
+
readonly effect: FloatType;
|
|
401
|
+
readonly ci: OptionType<StructType<{
|
|
402
|
+
readonly lower: FloatType;
|
|
403
|
+
readonly upper: FloatType;
|
|
404
|
+
}>>;
|
|
405
|
+
}>>;
|
|
406
|
+
readonly n_total: IntegerType;
|
|
468
407
|
readonly n_treated: IntegerType;
|
|
469
|
-
/** Control rows used */
|
|
470
408
|
readonly n_control: IntegerType;
|
|
409
|
+
readonly n_dropped: IntegerType;
|
|
410
|
+
/** Per-confounder before-adjustment imbalance, most-imbalanced first. */
|
|
411
|
+
readonly balance: ArrayType<StructType<{
|
|
412
|
+
readonly column: StringType;
|
|
413
|
+
/** The original confounder this row belongs to — equals `column` for a numeric
|
|
414
|
+
* confounder; the base confounder for a one-hot categorical level. */
|
|
415
|
+
readonly base_column: StringType;
|
|
416
|
+
readonly treated_mean: FloatType;
|
|
417
|
+
readonly control_mean: FloatType;
|
|
418
|
+
/** Standardized mean difference, (mt-mc)/sqrt((vt+vc)/2). */
|
|
419
|
+
readonly std_diff: FloatType;
|
|
420
|
+
}>>;
|
|
421
|
+
readonly overlap: StructType<{
|
|
422
|
+
/** Propensity histogram (20 bins over [0,1]) for the treated arm. */
|
|
423
|
+
readonly treated_propensity: VectorType<FloatType>;
|
|
424
|
+
/** Propensity histogram for the control arm. */
|
|
425
|
+
readonly control_propensity: VectorType<FloatType>;
|
|
426
|
+
/** Fraction of rows inside the treated/control common support. */
|
|
427
|
+
readonly common_support_frac: FloatType;
|
|
428
|
+
/** Whether common support clears `min_overlap`. */
|
|
429
|
+
readonly positivity_ok: BooleanType;
|
|
430
|
+
}>;
|
|
431
|
+
readonly refutation: OptionType<StructType<{
|
|
432
|
+
/** Effect under a permuted (placebo) treatment — should be ≈ 0. */
|
|
433
|
+
readonly placebo_effect: OptionType<FloatType>;
|
|
434
|
+
/** Whether the placebo effect vanished. */
|
|
435
|
+
readonly placebo_passes: OptionType<BooleanType>;
|
|
436
|
+
/** Whether a decoy random common cause left the estimate inside its CI. */
|
|
437
|
+
readonly random_cc_within_ci: OptionType<BooleanType>;
|
|
438
|
+
/** Mean effect across data subsamples (stability). */
|
|
439
|
+
readonly data_subset_effect: OptionType<FloatType>;
|
|
440
|
+
/** Std of the effect across data subsamples. */
|
|
441
|
+
readonly data_subset_std: OptionType<FloatType>;
|
|
442
|
+
/** Closed-form E-value — confounder strength needed to explain the effect away. */
|
|
443
|
+
readonly robustness_value: OptionType<FloatType>;
|
|
444
|
+
/** Unobserved-confounder sensitivity (tipping) curve: effect at each simulated strength. */
|
|
445
|
+
readonly sensitivity: OptionType<StructType<{
|
|
446
|
+
readonly strengths: VectorType<FloatType>;
|
|
447
|
+
readonly effects: VectorType<FloatType>;
|
|
448
|
+
}>>;
|
|
449
|
+
}>>;
|
|
450
|
+
/** ALE dose-response of `dose_feature` (present when `config.dose_feature` is set). */
|
|
451
|
+
readonly dose_response: OptionType<StructType<{
|
|
452
|
+
readonly feature: StringType;
|
|
453
|
+
readonly grid: VectorType<FloatType>;
|
|
454
|
+
readonly effect: VectorType<FloatType>;
|
|
455
|
+
readonly lower: OptionType<VectorType<FloatType>>;
|
|
456
|
+
readonly upper: OptionType<VectorType<FloatType>>;
|
|
457
|
+
/** Rows per dose bin — drives the surface's "you are here" (busiest bin) marker. */
|
|
458
|
+
readonly size: VectorType<IntegerType>;
|
|
459
|
+
}>>;
|
|
460
|
+
readonly verdict: VariantType<{
|
|
461
|
+
/** A real, robust, material effect. */
|
|
462
|
+
readonly causal: NullType;
|
|
463
|
+
/** A small but real effect, or no clear effect after adjustment. */
|
|
464
|
+
readonly modest: NullType;
|
|
465
|
+
/** Adjusted, but the estimate isn't trustworthy (placebo fails). */
|
|
466
|
+
readonly adjustment_insufficient: NullType;
|
|
467
|
+
/** No like-for-like comparison exists (positivity violated). */
|
|
468
|
+
readonly non_identifiable_positivity: NullType;
|
|
469
|
+
/** The estimand can't be formed (treatment barely varies). */
|
|
470
|
+
readonly not_estimable: StringType;
|
|
471
|
+
}>;
|
|
471
472
|
}>>;
|
|
473
|
+
/** Why the trial is sized the way it is — set from the verdict. */
|
|
474
|
+
export declare const DesignBasisType: VariantType<{
|
|
475
|
+
/** Clear effect → power the trial to detect the observed effect. */
|
|
476
|
+
readonly detect_observed: NullType;
|
|
477
|
+
/** Fuzzy / maybe-nothing → power to the smallest effect worth acting on. */
|
|
478
|
+
readonly resolve_vs_null: NullType;
|
|
479
|
+
/** A trust check failed → randomise to remove the bias adjustment couldn't. */
|
|
480
|
+
readonly de_bias: NullType;
|
|
481
|
+
/** No overlap → randomise within the comparable range. */
|
|
482
|
+
readonly restrict_to_overlap: NullType;
|
|
483
|
+
/** No control group exists → hold back a random sample next time. */
|
|
484
|
+
readonly create_control: NullType;
|
|
485
|
+
}>;
|
|
486
|
+
/** One sizing option — a split and the head-count it needs (even split first). */
|
|
487
|
+
export declare const TrialOptionType: StructType<{
|
|
488
|
+
readonly label: StringType;
|
|
489
|
+
/** Fraction assigned to the treatment (0..1; 0.5 = even). */
|
|
490
|
+
readonly treated_share: FloatType;
|
|
491
|
+
readonly n_treated: IntegerType;
|
|
492
|
+
readonly n_control: IntegerType;
|
|
493
|
+
readonly n_total: IntegerType;
|
|
494
|
+
}>;
|
|
495
|
+
/** The "chance of detecting it" curve — total head-count → power (0..1). */
|
|
496
|
+
export declare const PowerCurveType: StructType<{
|
|
497
|
+
readonly n: VectorType<IntegerType>;
|
|
498
|
+
readonly power: VectorType<FloatType>;
|
|
499
|
+
}>;
|
|
472
500
|
/**
|
|
473
|
-
*
|
|
474
|
-
*
|
|
475
|
-
*
|
|
476
|
-
|
|
477
|
-
|
|
501
|
+
* The validation-trial recipe — a randomised controlled trial sized from the
|
|
502
|
+
* observed effect (or the materiality threshold) and the outcome spread, with the
|
|
503
|
+
* groups matched on the confounders that were most imbalanced.
|
|
504
|
+
*/
|
|
505
|
+
export declare const ExperimentDesignType: StructType<{
|
|
506
|
+
readonly verdict: VariantType<{
|
|
507
|
+
/** A real, robust, material effect. */
|
|
508
|
+
readonly causal: NullType;
|
|
509
|
+
/** A small but real effect, or no clear effect after adjustment. */
|
|
510
|
+
readonly modest: NullType;
|
|
511
|
+
/** Adjusted, but the estimate isn't trustworthy (placebo fails). */
|
|
512
|
+
readonly adjustment_insufficient: NullType;
|
|
513
|
+
/** No like-for-like comparison exists (positivity violated). */
|
|
514
|
+
readonly non_identifiable_positivity: NullType;
|
|
515
|
+
/** The estimand can't be formed (treatment barely varies). */
|
|
516
|
+
readonly not_estimable: StringType;
|
|
517
|
+
}>;
|
|
518
|
+
readonly basis: VariantType<{
|
|
519
|
+
/** Clear effect → power the trial to detect the observed effect. */
|
|
520
|
+
readonly detect_observed: NullType;
|
|
521
|
+
/** Fuzzy / maybe-nothing → power to the smallest effect worth acting on. */
|
|
522
|
+
readonly resolve_vs_null: NullType;
|
|
523
|
+
/** A trust check failed → randomise to remove the bias adjustment couldn't. */
|
|
524
|
+
readonly de_bias: NullType;
|
|
525
|
+
/** No overlap → randomise within the comparable range. */
|
|
526
|
+
readonly restrict_to_overlap: NullType;
|
|
527
|
+
/** No control group exists → hold back a random sample next time. */
|
|
528
|
+
readonly create_control: NullType;
|
|
529
|
+
}>;
|
|
530
|
+
/** Effect size the trial is powered to detect (observed, or materiality). */
|
|
531
|
+
readonly target_effect: FloatType;
|
|
532
|
+
/** Outcome spread (pooled SD) used to size it. */
|
|
533
|
+
readonly outcome_sd: FloatType;
|
|
534
|
+
readonly target_power: FloatType;
|
|
535
|
+
readonly alpha: FloatType;
|
|
536
|
+
/** Chance the CURRENT sample would already detect `target_effect`; `none` when there's no comparison group. */
|
|
537
|
+
readonly current_power: OptionType<FloatType>;
|
|
538
|
+
/** Categories both groups must be matched on (most-imbalanced confounders). */
|
|
539
|
+
readonly match_on: ArrayType<StringType>;
|
|
540
|
+
/** Ranked split options (even split first; cost-saving alternates). */
|
|
541
|
+
readonly options: ArrayType<StructType<{
|
|
542
|
+
readonly label: StringType;
|
|
543
|
+
/** Fraction assigned to the treatment (0..1; 0.5 = even). */
|
|
544
|
+
readonly treated_share: FloatType;
|
|
545
|
+
readonly n_treated: IntegerType;
|
|
546
|
+
readonly n_control: IntegerType;
|
|
547
|
+
readonly n_total: IntegerType;
|
|
548
|
+
}>>;
|
|
549
|
+
/** The detect-chance curve for the chart. */
|
|
550
|
+
readonly power_curve: StructType<{
|
|
551
|
+
readonly n: VectorType<IntegerType>;
|
|
552
|
+
readonly power: VectorType<FloatType>;
|
|
553
|
+
}>;
|
|
554
|
+
/** One generated, plain-language sentence framing the recipe. */
|
|
555
|
+
readonly rationale: StringType;
|
|
556
|
+
}>;
|
|
557
|
+
/** Optional knobs for {@link causal_design_validation} (all developer-defaulted). */
|
|
558
|
+
export declare const DesignConfigType: StructType<{
|
|
559
|
+
/** Significance level (default 0.05). */
|
|
560
|
+
readonly alpha: OptionType<FloatType>;
|
|
561
|
+
/** Target chance of detecting the effect (default 0.8). */
|
|
562
|
+
readonly target_power: OptionType<FloatType>;
|
|
563
|
+
/** Smallest effect worth acting on — sizes the trial to this when set / when there's no trustworthy observed effect. */
|
|
564
|
+
readonly materiality: OptionType<FloatType>;
|
|
565
|
+
/** Treatment shares to offer as options (default [0.5]). */
|
|
566
|
+
readonly treated_shares: OptionType<ArrayType<FloatType>>;
|
|
567
|
+
}>;
|
|
568
|
+
/**
|
|
569
|
+
* Design the real controlled trial that would validate a finished experiment.
|
|
570
|
+
* Generic over the row struct (same as {@link causal_experiment}); takes the data,
|
|
571
|
+
* the experiment config, the experiment result, and optional design knobs, and
|
|
572
|
+
* returns the trial recipe (sample size, split options, match-on categories, the
|
|
573
|
+
* power curve, and a plain-language rationale).
|
|
478
574
|
*
|
|
479
|
-
* @param data -
|
|
480
|
-
* @param config -
|
|
481
|
-
* @param
|
|
482
|
-
* @
|
|
575
|
+
* @param data - The rows the experiment ran on
|
|
576
|
+
* @param config - The experiment configuration (names treatment / outcome / confounders)
|
|
577
|
+
* @param result - The {@link causal_experiment} result whose verdict drives the recipe
|
|
578
|
+
* @param design_config - Optional alpha / power / materiality / split knobs
|
|
579
|
+
* @returns The validation-trial recipe
|
|
483
580
|
*/
|
|
484
|
-
export declare const
|
|
485
|
-
/**
|
|
486
|
-
readonly columns: ArrayType<StringType>;
|
|
487
|
-
/** Treatment column (must be 0/1 for propensity score weighting) */
|
|
581
|
+
export declare const causal_design_validation: import("@elaraai/east").GenericPlatformDefinition<readonly ["T"], readonly [ArrayType<unknown>, StructType<{
|
|
582
|
+
/** Binary (0/1) treatment column. */
|
|
488
583
|
readonly treatment: StringType;
|
|
489
|
-
/** Outcome column */
|
|
584
|
+
/** Outcome column. */
|
|
490
585
|
readonly outcome: StringType;
|
|
491
|
-
/**
|
|
586
|
+
/** Confounders to adjust for (the backdoor set). */
|
|
492
587
|
readonly common_causes: ArrayType<StringType>;
|
|
493
|
-
/**
|
|
588
|
+
/** Confounder columns holding categories (string or int codes), one-hot encoded. */
|
|
494
589
|
readonly categorical: OptionType<ArrayType<StringType>>;
|
|
495
|
-
/**
|
|
590
|
+
/** Estimator (default: linear_regression). */
|
|
496
591
|
readonly method: OptionType<VariantType<{
|
|
497
|
-
/** Linear regression of outcome on treatment + common causes */
|
|
592
|
+
/** Linear regression of outcome on treatment + common causes (default) */
|
|
498
593
|
readonly linear_regression: NullType;
|
|
499
594
|
/** Inverse propensity score weighting (binary treatment only) */
|
|
500
595
|
readonly propensity_score_weighting: StructType<{
|
|
@@ -509,8 +604,8 @@ export declare const causal_refute: import("@elaraai/east").PlatformDefinition<[
|
|
|
509
604
|
}>>;
|
|
510
605
|
}>;
|
|
511
606
|
}>>;
|
|
512
|
-
/** Target population (default: ate) */
|
|
513
|
-
readonly
|
|
607
|
+
/** Target population (default: ate). */
|
|
608
|
+
readonly estimand: OptionType<VariantType<{
|
|
514
609
|
/** Average treatment effect over all units */
|
|
515
610
|
readonly ate: NullType;
|
|
516
611
|
/** Average treatment effect on the treated */
|
|
@@ -518,244 +613,177 @@ export declare const causal_refute: import("@elaraai/east").PlatformDefinition<[
|
|
|
518
613
|
/** Average treatment effect on the controls */
|
|
519
614
|
readonly atc: NullType;
|
|
520
615
|
}>>;
|
|
521
|
-
/**
|
|
522
|
-
readonly
|
|
523
|
-
/**
|
|
524
|
-
readonly
|
|
525
|
-
/**
|
|
526
|
-
readonly
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
}>;
|
|
616
|
+
/** Which robustness checks to run. */
|
|
617
|
+
readonly refute: OptionType<StructType<{
|
|
618
|
+
/** Permuted-treatment negative control — a real effect should vanish. */
|
|
619
|
+
readonly placebo: BooleanType;
|
|
620
|
+
/** Inject an independent random common cause — the effect should hold. */
|
|
621
|
+
readonly random_common_cause: BooleanType;
|
|
622
|
+
/** Re-estimate on random subsamples — the effect should be stable. */
|
|
623
|
+
readonly data_subset: BooleanType;
|
|
624
|
+
/** Unobserved-confounder strengths to simulate → the sensitivity / tipping curve. */
|
|
625
|
+
readonly sensitivity: OptionType<ArrayType<FloatType>>;
|
|
532
626
|
}>>;
|
|
533
|
-
/**
|
|
627
|
+
/** Continuous column for the ALE dose-response curve (the "How much?" view). */
|
|
628
|
+
readonly dose_feature: OptionType<StringType>;
|
|
629
|
+
/** Positivity guard — common-support fraction below this → non_identifiable_positivity (default 0.10). */
|
|
630
|
+
readonly min_overlap: OptionType<FloatType>;
|
|
631
|
+
/** Not-estimable guard — minority-arm fraction below this → not_estimable (default 0.02). */
|
|
632
|
+
readonly min_treatment_variation: OptionType<FloatType>;
|
|
633
|
+
/** Bootstrap CI config (default: 200 reps, 0.95). */
|
|
534
634
|
readonly bootstrap: OptionType<StructType<{
|
|
535
|
-
/** Number of bootstrap replicates */
|
|
635
|
+
/** Number of bootstrap replicates (default 200) */
|
|
536
636
|
readonly reps: IntegerType;
|
|
537
637
|
/** Column whose values identify clusters to resample (default: resample rows) */
|
|
538
638
|
readonly cluster_column: OptionType<StringType>;
|
|
539
639
|
/** Confidence level for the percentile interval (default 0.95) */
|
|
540
640
|
readonly confidence_level: OptionType<FloatType>;
|
|
541
641
|
}>>;
|
|
542
|
-
/** Random seed
|
|
642
|
+
/** Random seed. */
|
|
543
643
|
readonly random_state: OptionType<IntegerType>;
|
|
544
|
-
}>,
|
|
545
|
-
/**
|
|
546
|
-
readonly
|
|
547
|
-
|
|
548
|
-
readonly
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
readonly
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
readonly
|
|
644
|
+
}>, StructType<{
|
|
645
|
+
/** The raw (unadjusted) mean difference — always computable. */
|
|
646
|
+
readonly naive: FloatType;
|
|
647
|
+
readonly naive_ci: OptionType<StructType<{
|
|
648
|
+
readonly lower: FloatType;
|
|
649
|
+
readonly upper: FloatType;
|
|
650
|
+
}>>;
|
|
651
|
+
/** The adjusted (like-for-like) effect + CI; `none` ⇒ the engine refused. */
|
|
652
|
+
readonly adjusted: OptionType<StructType<{
|
|
653
|
+
readonly effect: FloatType;
|
|
654
|
+
readonly ci: OptionType<StructType<{
|
|
655
|
+
readonly lower: FloatType;
|
|
656
|
+
readonly upper: FloatType;
|
|
657
|
+
}>>;
|
|
658
|
+
}>>;
|
|
659
|
+
readonly n_total: IntegerType;
|
|
660
|
+
readonly n_treated: IntegerType;
|
|
661
|
+
readonly n_control: IntegerType;
|
|
662
|
+
readonly n_dropped: IntegerType;
|
|
663
|
+
/** Per-confounder before-adjustment imbalance, most-imbalanced first. */
|
|
664
|
+
readonly balance: ArrayType<StructType<{
|
|
665
|
+
readonly column: StringType;
|
|
666
|
+
/** The original confounder this row belongs to — equals `column` for a numeric
|
|
667
|
+
* confounder; the base confounder for a one-hot categorical level. */
|
|
668
|
+
readonly base_column: StringType;
|
|
669
|
+
readonly treated_mean: FloatType;
|
|
670
|
+
readonly control_mean: FloatType;
|
|
671
|
+
/** Standardized mean difference, (mt-mc)/sqrt((vt+vc)/2). */
|
|
672
|
+
readonly std_diff: FloatType;
|
|
673
|
+
}>>;
|
|
674
|
+
readonly overlap: StructType<{
|
|
675
|
+
/** Propensity histogram (20 bins over [0,1]) for the treated arm. */
|
|
676
|
+
readonly treated_propensity: VectorType<FloatType>;
|
|
677
|
+
/** Propensity histogram for the control arm. */
|
|
678
|
+
readonly control_propensity: VectorType<FloatType>;
|
|
679
|
+
/** Fraction of rows inside the treated/control common support. */
|
|
680
|
+
readonly common_support_frac: FloatType;
|
|
681
|
+
/** Whether common support clears `min_overlap`. */
|
|
682
|
+
readonly positivity_ok: BooleanType;
|
|
571
683
|
}>;
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
/**
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
* @param T - Treatment vector
|
|
591
|
-
* @param X - Effect modifier matrix (CATE varies with these)
|
|
592
|
-
* @param W - Additional confounders adjusted for but not modifying the effect
|
|
593
|
-
* @param config - DML configuration
|
|
594
|
-
* @returns Model blob for use with dmlEffect / dmlAte
|
|
595
|
-
*/
|
|
596
|
-
export declare const causal_dml_train: import("@elaraai/east").PlatformDefinition<[VectorType<FloatType>, VectorType<FloatType>, MatrixType<FloatType>, OptionType<MatrixType<FloatType>>, StructType<{
|
|
597
|
-
/** Nuisance model for the outcome stage (default: random_forest) */
|
|
598
|
-
readonly model_y: OptionType<VariantType<{
|
|
599
|
-
/** Random forest (regressor, or classifier for a discrete treatment) */
|
|
600
|
-
readonly random_forest: StructType<{
|
|
601
|
-
/** Number of trees (default 100) */
|
|
602
|
-
readonly n_estimators: OptionType<IntegerType>;
|
|
603
|
-
/** Minimum samples per leaf (default 5) */
|
|
604
|
-
readonly min_samples_leaf: OptionType<IntegerType>;
|
|
605
|
-
/** Maximum tree depth (default unlimited) */
|
|
606
|
-
readonly max_depth: OptionType<IntegerType>;
|
|
607
|
-
}>;
|
|
608
|
-
/** Gradient boosting (regressor, or classifier for a discrete treatment) */
|
|
609
|
-
readonly gradient_boosting: StructType<{
|
|
610
|
-
/** Number of boosting stages (default 100) */
|
|
611
|
-
readonly n_estimators: OptionType<IntegerType>;
|
|
612
|
-
/** Learning rate (default 0.1) */
|
|
613
|
-
readonly learning_rate: OptionType<FloatType>;
|
|
614
|
-
/** Maximum tree depth (default 3) */
|
|
615
|
-
readonly max_depth: OptionType<IntegerType>;
|
|
616
|
-
}>;
|
|
617
|
-
/** Linear/logistic regression */
|
|
618
|
-
readonly linear: NullType;
|
|
684
|
+
readonly refutation: OptionType<StructType<{
|
|
685
|
+
/** Effect under a permuted (placebo) treatment — should be ≈ 0. */
|
|
686
|
+
readonly placebo_effect: OptionType<FloatType>;
|
|
687
|
+
/** Whether the placebo effect vanished. */
|
|
688
|
+
readonly placebo_passes: OptionType<BooleanType>;
|
|
689
|
+
/** Whether a decoy random common cause left the estimate inside its CI. */
|
|
690
|
+
readonly random_cc_within_ci: OptionType<BooleanType>;
|
|
691
|
+
/** Mean effect across data subsamples (stability). */
|
|
692
|
+
readonly data_subset_effect: OptionType<FloatType>;
|
|
693
|
+
/** Std of the effect across data subsamples. */
|
|
694
|
+
readonly data_subset_std: OptionType<FloatType>;
|
|
695
|
+
/** Closed-form E-value — confounder strength needed to explain the effect away. */
|
|
696
|
+
readonly robustness_value: OptionType<FloatType>;
|
|
697
|
+
/** Unobserved-confounder sensitivity (tipping) curve: effect at each simulated strength. */
|
|
698
|
+
readonly sensitivity: OptionType<StructType<{
|
|
699
|
+
readonly strengths: VectorType<FloatType>;
|
|
700
|
+
readonly effects: VectorType<FloatType>;
|
|
701
|
+
}>>;
|
|
619
702
|
}>>;
|
|
620
|
-
/**
|
|
621
|
-
readonly
|
|
622
|
-
|
|
623
|
-
readonly
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
readonly max_depth: OptionType<IntegerType>;
|
|
630
|
-
}>;
|
|
631
|
-
/** Gradient boosting (regressor, or classifier for a discrete treatment) */
|
|
632
|
-
readonly gradient_boosting: StructType<{
|
|
633
|
-
/** Number of boosting stages (default 100) */
|
|
634
|
-
readonly n_estimators: OptionType<IntegerType>;
|
|
635
|
-
/** Learning rate (default 0.1) */
|
|
636
|
-
readonly learning_rate: OptionType<FloatType>;
|
|
637
|
-
/** Maximum tree depth (default 3) */
|
|
638
|
-
readonly max_depth: OptionType<IntegerType>;
|
|
639
|
-
}>;
|
|
640
|
-
/** Linear/logistic regression */
|
|
641
|
-
readonly linear: NullType;
|
|
703
|
+
/** ALE dose-response of `dose_feature` (present when `config.dose_feature` is set). */
|
|
704
|
+
readonly dose_response: OptionType<StructType<{
|
|
705
|
+
readonly feature: StringType;
|
|
706
|
+
readonly grid: VectorType<FloatType>;
|
|
707
|
+
readonly effect: VectorType<FloatType>;
|
|
708
|
+
readonly lower: OptionType<VectorType<FloatType>>;
|
|
709
|
+
readonly upper: OptionType<VectorType<FloatType>>;
|
|
710
|
+
/** Rows per dose bin — drives the surface's "you are here" (busiest bin) marker. */
|
|
711
|
+
readonly size: VectorType<IntegerType>;
|
|
642
712
|
}>>;
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
/** Serialized estimator (cloudpickle) */
|
|
655
|
-
readonly data: BlobType;
|
|
656
|
-
/** Number of effect-modifier (X) features */
|
|
657
|
-
readonly n_features_x: IntegerType;
|
|
658
|
-
/** Confidence level used for effect/ATE intervals */
|
|
659
|
-
readonly confidence_level: FloatType;
|
|
713
|
+
readonly verdict: VariantType<{
|
|
714
|
+
/** A real, robust, material effect. */
|
|
715
|
+
readonly causal: NullType;
|
|
716
|
+
/** A small but real effect, or no clear effect after adjustment. */
|
|
717
|
+
readonly modest: NullType;
|
|
718
|
+
/** Adjusted, but the estimate isn't trustworthy (placebo fails). */
|
|
719
|
+
readonly adjustment_insufficient: NullType;
|
|
720
|
+
/** No like-for-like comparison exists (positivity violated). */
|
|
721
|
+
readonly non_identifiable_positivity: NullType;
|
|
722
|
+
/** The estimand can't be formed (treatment barely varies). */
|
|
723
|
+
readonly not_estimable: StringType;
|
|
660
724
|
}>;
|
|
661
|
-
}
|
|
662
|
-
/**
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
*/
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
readonly
|
|
672
|
-
/**
|
|
673
|
-
readonly
|
|
674
|
-
/**
|
|
675
|
-
readonly
|
|
676
|
-
/**
|
|
677
|
-
readonly
|
|
725
|
+
}>, StructType<{
|
|
726
|
+
/** Significance level (default 0.05). */
|
|
727
|
+
readonly alpha: OptionType<FloatType>;
|
|
728
|
+
/** Target chance of detecting the effect (default 0.8). */
|
|
729
|
+
readonly target_power: OptionType<FloatType>;
|
|
730
|
+
/** Smallest effect worth acting on — sizes the trial to this when set / when there's no trustworthy observed effect. */
|
|
731
|
+
readonly materiality: OptionType<FloatType>;
|
|
732
|
+
/** Treatment shares to offer as options (default [0.5]). */
|
|
733
|
+
readonly treated_shares: OptionType<ArrayType<FloatType>>;
|
|
734
|
+
}>], StructType<{
|
|
735
|
+
readonly verdict: VariantType<{
|
|
736
|
+
/** A real, robust, material effect. */
|
|
737
|
+
readonly causal: NullType;
|
|
738
|
+
/** A small but real effect, or no clear effect after adjustment. */
|
|
739
|
+
readonly modest: NullType;
|
|
740
|
+
/** Adjusted, but the estimate isn't trustworthy (placebo fails). */
|
|
741
|
+
readonly adjustment_insufficient: NullType;
|
|
742
|
+
/** No like-for-like comparison exists (positivity violated). */
|
|
743
|
+
readonly non_identifiable_positivity: NullType;
|
|
744
|
+
/** The estimand can't be formed (treatment barely varies). */
|
|
745
|
+
readonly not_estimable: StringType;
|
|
678
746
|
}>;
|
|
679
|
-
|
|
680
|
-
/**
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
*/
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
/** Serialized estimator (cloudpickle) */
|
|
691
|
-
readonly data: BlobType;
|
|
692
|
-
/** Number of effect-modifier (X) features */
|
|
693
|
-
readonly n_features_x: IntegerType;
|
|
694
|
-
/** Confidence level used for effect/ATE intervals */
|
|
695
|
-
readonly confidence_level: FloatType;
|
|
747
|
+
readonly basis: VariantType<{
|
|
748
|
+
/** Clear effect → power the trial to detect the observed effect. */
|
|
749
|
+
readonly detect_observed: NullType;
|
|
750
|
+
/** Fuzzy / maybe-nothing → power to the smallest effect worth acting on. */
|
|
751
|
+
readonly resolve_vs_null: NullType;
|
|
752
|
+
/** A trust check failed → randomise to remove the bias adjustment couldn't. */
|
|
753
|
+
readonly de_bias: NullType;
|
|
754
|
+
/** No overlap → randomise within the comparable range. */
|
|
755
|
+
readonly restrict_to_overlap: NullType;
|
|
756
|
+
/** No control group exists → hold back a random sample next time. */
|
|
757
|
+
readonly create_control: NullType;
|
|
696
758
|
}>;
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
readonly
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
/**
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
*/
|
|
716
|
-
export declare const causal_ale: import("@elaraai/east").PlatformDefinition<[MatrixType<FloatType>, StructType<{
|
|
717
|
-
/** Column names for the data matrix (one per column, in order) */
|
|
718
|
-
readonly columns: ArrayType<StringType>;
|
|
719
|
-
/** Outcome column the emulator predicts */
|
|
720
|
-
readonly outcome: StringType;
|
|
721
|
-
/** Continuous feature column to compute the ALE curve for */
|
|
722
|
-
readonly feature: StringType;
|
|
723
|
-
/** Columns holding integer category codes, one-hot encoded internally */
|
|
724
|
-
readonly categorical: OptionType<ArrayType<StringType>>;
|
|
725
|
-
/** Number of grid intervals (default 10) */
|
|
726
|
-
readonly grid_size: OptionType<IntegerType>;
|
|
727
|
-
/** Include confidence intervals (default true) */
|
|
728
|
-
readonly include_ci: OptionType<BooleanType>;
|
|
729
|
-
/** Confidence level for the CI (default 0.95) */
|
|
730
|
-
readonly confidence_level: OptionType<FloatType>;
|
|
731
|
-
/** Emulator (HistGradientBoosting) hyperparameters */
|
|
732
|
-
readonly emulator: OptionType<StructType<{
|
|
733
|
-
/** Number of boosting iterations (default 300) */
|
|
734
|
-
readonly n_estimators: OptionType<IntegerType>;
|
|
735
|
-
/** Learning rate (default 0.05) */
|
|
736
|
-
readonly learning_rate: OptionType<FloatType>;
|
|
737
|
-
/** Maximum tree depth (default unlimited) */
|
|
738
|
-
readonly max_depth: OptionType<IntegerType>;
|
|
739
|
-
/** Minimum samples per leaf (default 20; lower for small datasets) */
|
|
740
|
-
readonly min_samples_leaf: OptionType<IntegerType>;
|
|
759
|
+
/** Effect size the trial is powered to detect (observed, or materiality). */
|
|
760
|
+
readonly target_effect: FloatType;
|
|
761
|
+
/** Outcome spread (pooled SD) used to size it. */
|
|
762
|
+
readonly outcome_sd: FloatType;
|
|
763
|
+
readonly target_power: FloatType;
|
|
764
|
+
readonly alpha: FloatType;
|
|
765
|
+
/** Chance the CURRENT sample would already detect `target_effect`; `none` when there's no comparison group. */
|
|
766
|
+
readonly current_power: OptionType<FloatType>;
|
|
767
|
+
/** Categories both groups must be matched on (most-imbalanced confounders). */
|
|
768
|
+
readonly match_on: ArrayType<StringType>;
|
|
769
|
+
/** Ranked split options (even split first; cost-saving alternates). */
|
|
770
|
+
readonly options: ArrayType<StructType<{
|
|
771
|
+
readonly label: StringType;
|
|
772
|
+
/** Fraction assigned to the treatment (0..1; 0.5 = even). */
|
|
773
|
+
readonly treated_share: FloatType;
|
|
774
|
+
readonly n_treated: IntegerType;
|
|
775
|
+
readonly n_control: IntegerType;
|
|
776
|
+
readonly n_total: IntegerType;
|
|
741
777
|
}>>;
|
|
742
|
-
/**
|
|
743
|
-
readonly
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
/**
|
|
748
|
-
readonly
|
|
749
|
-
/** Lower CI at each grid value (present when include_ci) */
|
|
750
|
-
readonly lower: OptionType<VectorType<FloatType>>;
|
|
751
|
-
/** Upper CI at each grid value (present when include_ci) */
|
|
752
|
-
readonly upper: OptionType<VectorType<FloatType>>;
|
|
753
|
-
/** Number of samples in each grid interval */
|
|
754
|
-
readonly size: VectorType<IntegerType>;
|
|
778
|
+
/** The detect-chance curve for the chart. */
|
|
779
|
+
readonly power_curve: StructType<{
|
|
780
|
+
readonly n: VectorType<IntegerType>;
|
|
781
|
+
readonly power: VectorType<FloatType>;
|
|
782
|
+
}>;
|
|
783
|
+
/** One generated, plain-language sentence framing the recipe. */
|
|
784
|
+
readonly rationale: StringType;
|
|
755
785
|
}>>;
|
|
756
|
-
/**
|
|
757
|
-
* Type definitions for causal inference functions.
|
|
758
|
-
*/
|
|
786
|
+
/** Type definitions for causal inference. */
|
|
759
787
|
export declare const CausalTypes: {
|
|
760
788
|
readonly CausalWeightingSchemeType: VariantType<{
|
|
761
789
|
/** Raw inverse propensity weights */
|
|
@@ -766,7 +794,7 @@ export declare const CausalTypes: {
|
|
|
766
794
|
readonly ips_normalized_weight: NullType;
|
|
767
795
|
}>;
|
|
768
796
|
readonly CausalEstimatorType: VariantType<{
|
|
769
|
-
/** Linear regression of outcome on treatment + common causes */
|
|
797
|
+
/** Linear regression of outcome on treatment + common causes (default) */
|
|
770
798
|
readonly linear_regression: NullType;
|
|
771
799
|
/** Inverse propensity score weighting (binary treatment only) */
|
|
772
800
|
readonly propensity_score_weighting: StructType<{
|
|
@@ -789,39 +817,40 @@ export declare const CausalTypes: {
|
|
|
789
817
|
/** Average treatment effect on the controls */
|
|
790
818
|
readonly atc: NullType;
|
|
791
819
|
}>;
|
|
792
|
-
readonly PropensityTrimType: VariantType<{
|
|
793
|
-
/** Keep units inside the common-support overlap of treated and control propensities */
|
|
794
|
-
readonly overlap: NullType;
|
|
795
|
-
/** Keep units with propensity inside explicit bounds */
|
|
796
|
-
readonly bounds: StructType<{
|
|
797
|
-
/** Minimum propensity score to keep */
|
|
798
|
-
readonly lower: FloatType;
|
|
799
|
-
/** Maximum propensity score to keep */
|
|
800
|
-
readonly upper: FloatType;
|
|
801
|
-
}>;
|
|
802
|
-
}>;
|
|
803
820
|
readonly CausalBootstrapConfigType: StructType<{
|
|
804
|
-
/** Number of bootstrap replicates */
|
|
821
|
+
/** Number of bootstrap replicates (default 200) */
|
|
805
822
|
readonly reps: IntegerType;
|
|
806
823
|
/** Column whose values identify clusters to resample (default: resample rows) */
|
|
807
824
|
readonly cluster_column: OptionType<StringType>;
|
|
808
825
|
/** Confidence level for the percentile interval (default 0.95) */
|
|
809
826
|
readonly confidence_level: OptionType<FloatType>;
|
|
810
827
|
}>;
|
|
811
|
-
readonly
|
|
812
|
-
|
|
813
|
-
readonly
|
|
814
|
-
|
|
828
|
+
readonly CiType: StructType<{
|
|
829
|
+
readonly lower: FloatType;
|
|
830
|
+
readonly upper: FloatType;
|
|
831
|
+
}>;
|
|
832
|
+
readonly RefuteSpecType: StructType<{
|
|
833
|
+
/** Permuted-treatment negative control — a real effect should vanish. */
|
|
834
|
+
readonly placebo: BooleanType;
|
|
835
|
+
/** Inject an independent random common cause — the effect should hold. */
|
|
836
|
+
readonly random_common_cause: BooleanType;
|
|
837
|
+
/** Re-estimate on random subsamples — the effect should be stable. */
|
|
838
|
+
readonly data_subset: BooleanType;
|
|
839
|
+
/** Unobserved-confounder strengths to simulate → the sensitivity / tipping curve. */
|
|
840
|
+
readonly sensitivity: OptionType<ArrayType<FloatType>>;
|
|
841
|
+
}>;
|
|
842
|
+
readonly CausalExperimentConfigType: StructType<{
|
|
843
|
+
/** Binary (0/1) treatment column. */
|
|
815
844
|
readonly treatment: StringType;
|
|
816
|
-
/** Outcome column */
|
|
845
|
+
/** Outcome column. */
|
|
817
846
|
readonly outcome: StringType;
|
|
818
|
-
/**
|
|
847
|
+
/** Confounders to adjust for (the backdoor set). */
|
|
819
848
|
readonly common_causes: ArrayType<StringType>;
|
|
820
|
-
/**
|
|
849
|
+
/** Confounder columns holding categories (string or int codes), one-hot encoded. */
|
|
821
850
|
readonly categorical: OptionType<ArrayType<StringType>>;
|
|
822
|
-
/**
|
|
851
|
+
/** Estimator (default: linear_regression). */
|
|
823
852
|
readonly method: OptionType<VariantType<{
|
|
824
|
-
/** Linear regression of outcome on treatment + common causes */
|
|
853
|
+
/** Linear regression of outcome on treatment + common causes (default) */
|
|
825
854
|
readonly linear_regression: NullType;
|
|
826
855
|
/** Inverse propensity score weighting (binary treatment only) */
|
|
827
856
|
readonly propensity_score_weighting: StructType<{
|
|
@@ -836,8 +865,8 @@ export declare const CausalTypes: {
|
|
|
836
865
|
}>>;
|
|
837
866
|
}>;
|
|
838
867
|
}>>;
|
|
839
|
-
/** Target population (default: ate) */
|
|
840
|
-
readonly
|
|
868
|
+
/** Target population (default: ate). */
|
|
869
|
+
readonly estimand: OptionType<VariantType<{
|
|
841
870
|
/** Average treatment effect over all units */
|
|
842
871
|
readonly ate: NullType;
|
|
843
872
|
/** Average treatment effect on the treated */
|
|
@@ -845,313 +874,306 @@ export declare const CausalTypes: {
|
|
|
845
874
|
/** Average treatment effect on the controls */
|
|
846
875
|
readonly atc: NullType;
|
|
847
876
|
}>>;
|
|
848
|
-
/**
|
|
849
|
-
readonly
|
|
850
|
-
/**
|
|
851
|
-
readonly
|
|
852
|
-
/**
|
|
853
|
-
readonly
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
}>;
|
|
877
|
+
/** Which robustness checks to run. */
|
|
878
|
+
readonly refute: OptionType<StructType<{
|
|
879
|
+
/** Permuted-treatment negative control — a real effect should vanish. */
|
|
880
|
+
readonly placebo: BooleanType;
|
|
881
|
+
/** Inject an independent random common cause — the effect should hold. */
|
|
882
|
+
readonly random_common_cause: BooleanType;
|
|
883
|
+
/** Re-estimate on random subsamples — the effect should be stable. */
|
|
884
|
+
readonly data_subset: BooleanType;
|
|
885
|
+
/** Unobserved-confounder strengths to simulate → the sensitivity / tipping curve. */
|
|
886
|
+
readonly sensitivity: OptionType<ArrayType<FloatType>>;
|
|
859
887
|
}>>;
|
|
860
|
-
/**
|
|
888
|
+
/** Continuous column for the ALE dose-response curve (the "How much?" view). */
|
|
889
|
+
readonly dose_feature: OptionType<StringType>;
|
|
890
|
+
/** Positivity guard — common-support fraction below this → non_identifiable_positivity (default 0.10). */
|
|
891
|
+
readonly min_overlap: OptionType<FloatType>;
|
|
892
|
+
/** Not-estimable guard — minority-arm fraction below this → not_estimable (default 0.02). */
|
|
893
|
+
readonly min_treatment_variation: OptionType<FloatType>;
|
|
894
|
+
/** Bootstrap CI config (default: 200 reps, 0.95). */
|
|
861
895
|
readonly bootstrap: OptionType<StructType<{
|
|
862
|
-
/** Number of bootstrap replicates */
|
|
896
|
+
/** Number of bootstrap replicates (default 200) */
|
|
863
897
|
readonly reps: IntegerType;
|
|
864
898
|
/** Column whose values identify clusters to resample (default: resample rows) */
|
|
865
899
|
readonly cluster_column: OptionType<StringType>;
|
|
866
900
|
/** Confidence level for the percentile interval (default 0.95) */
|
|
867
901
|
readonly confidence_level: OptionType<FloatType>;
|
|
868
902
|
}>>;
|
|
869
|
-
/** Random seed
|
|
903
|
+
/** Random seed. */
|
|
870
904
|
readonly random_state: OptionType<IntegerType>;
|
|
871
905
|
}>;
|
|
872
|
-
readonly
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
readonly num_simulations: OptionType<IntegerType>;
|
|
882
|
-
}>;
|
|
883
|
-
/** Re-estimate on random data subsets - effect should be stable */
|
|
884
|
-
readonly data_subset: StructType<{
|
|
885
|
-
/** Fraction of rows kept per simulation (default 0.8) */
|
|
886
|
-
readonly subset_fraction: OptionType<FloatType>;
|
|
887
|
-
/** Number of simulations (default 100) */
|
|
888
|
-
readonly num_simulations: OptionType<IntegerType>;
|
|
889
|
-
}>;
|
|
890
|
-
/**
|
|
891
|
-
* Simulate an unobserved confounder at each given strength - a
|
|
892
|
-
* sensitivity/tipping curve. Strength acts on both treatment
|
|
893
|
-
* (flip probability for binary treatment, linear coefficient otherwise)
|
|
894
|
-
* and outcome (linear coefficient).
|
|
895
|
-
*/
|
|
896
|
-
readonly unobserved_common_cause: StructType<{
|
|
897
|
-
/** Confounder effect strengths to simulate, one new effect per entry */
|
|
898
|
-
readonly effect_strengths: ArrayType<FloatType>;
|
|
899
|
-
}>;
|
|
906
|
+
readonly BalanceRowType: StructType<{
|
|
907
|
+
readonly column: StringType;
|
|
908
|
+
/** The original confounder this row belongs to — equals `column` for a numeric
|
|
909
|
+
* confounder; the base confounder for a one-hot categorical level. */
|
|
910
|
+
readonly base_column: StringType;
|
|
911
|
+
readonly treated_mean: FloatType;
|
|
912
|
+
readonly control_mean: FloatType;
|
|
913
|
+
/** Standardized mean difference, (mt-mc)/sqrt((vt+vc)/2). */
|
|
914
|
+
readonly std_diff: FloatType;
|
|
900
915
|
}>;
|
|
901
|
-
readonly
|
|
902
|
-
/**
|
|
903
|
-
readonly
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
}>;
|
|
911
|
-
/** Gradient boosting (regressor, or classifier for a discrete treatment) */
|
|
912
|
-
readonly gradient_boosting: StructType<{
|
|
913
|
-
/** Number of boosting stages (default 100) */
|
|
914
|
-
readonly n_estimators: OptionType<IntegerType>;
|
|
915
|
-
/** Learning rate (default 0.1) */
|
|
916
|
-
readonly learning_rate: OptionType<FloatType>;
|
|
917
|
-
/** Maximum tree depth (default 3) */
|
|
918
|
-
readonly max_depth: OptionType<IntegerType>;
|
|
919
|
-
}>;
|
|
920
|
-
/** Linear/logistic regression */
|
|
921
|
-
readonly linear: NullType;
|
|
916
|
+
readonly OverlapDiagnosticType: StructType<{
|
|
917
|
+
/** Propensity histogram (20 bins over [0,1]) for the treated arm. */
|
|
918
|
+
readonly treated_propensity: VectorType<FloatType>;
|
|
919
|
+
/** Propensity histogram for the control arm. */
|
|
920
|
+
readonly control_propensity: VectorType<FloatType>;
|
|
921
|
+
/** Fraction of rows inside the treated/control common support. */
|
|
922
|
+
readonly common_support_frac: FloatType;
|
|
923
|
+
/** Whether common support clears `min_overlap`. */
|
|
924
|
+
readonly positivity_ok: BooleanType;
|
|
922
925
|
}>;
|
|
923
|
-
readonly
|
|
924
|
-
/**
|
|
925
|
-
readonly
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
readonly learning_rate: OptionType<FloatType>;
|
|
941
|
-
/** Maximum tree depth (default 3) */
|
|
942
|
-
readonly max_depth: OptionType<IntegerType>;
|
|
943
|
-
}>;
|
|
944
|
-
/** Linear/logistic regression */
|
|
945
|
-
readonly linear: NullType;
|
|
946
|
-
}>>;
|
|
947
|
-
/** Nuisance model for the treatment stage (default: random_forest) */
|
|
948
|
-
readonly model_t: OptionType<VariantType<{
|
|
949
|
-
/** Random forest (regressor, or classifier for a discrete treatment) */
|
|
950
|
-
readonly random_forest: StructType<{
|
|
951
|
-
/** Number of trees (default 100) */
|
|
952
|
-
readonly n_estimators: OptionType<IntegerType>;
|
|
953
|
-
/** Minimum samples per leaf (default 5) */
|
|
954
|
-
readonly min_samples_leaf: OptionType<IntegerType>;
|
|
955
|
-
/** Maximum tree depth (default unlimited) */
|
|
956
|
-
readonly max_depth: OptionType<IntegerType>;
|
|
957
|
-
}>;
|
|
958
|
-
/** Gradient boosting (regressor, or classifier for a discrete treatment) */
|
|
959
|
-
readonly gradient_boosting: StructType<{
|
|
960
|
-
/** Number of boosting stages (default 100) */
|
|
961
|
-
readonly n_estimators: OptionType<IntegerType>;
|
|
962
|
-
/** Learning rate (default 0.1) */
|
|
963
|
-
readonly learning_rate: OptionType<FloatType>;
|
|
964
|
-
/** Maximum tree depth (default 3) */
|
|
965
|
-
readonly max_depth: OptionType<IntegerType>;
|
|
966
|
-
}>;
|
|
967
|
-
/** Linear/logistic regression */
|
|
968
|
-
readonly linear: NullType;
|
|
926
|
+
readonly RefutationType: StructType<{
|
|
927
|
+
/** Effect under a permuted (placebo) treatment — should be ≈ 0. */
|
|
928
|
+
readonly placebo_effect: OptionType<FloatType>;
|
|
929
|
+
/** Whether the placebo effect vanished. */
|
|
930
|
+
readonly placebo_passes: OptionType<BooleanType>;
|
|
931
|
+
/** Whether a decoy random common cause left the estimate inside its CI. */
|
|
932
|
+
readonly random_cc_within_ci: OptionType<BooleanType>;
|
|
933
|
+
/** Mean effect across data subsamples (stability). */
|
|
934
|
+
readonly data_subset_effect: OptionType<FloatType>;
|
|
935
|
+
/** Std of the effect across data subsamples. */
|
|
936
|
+
readonly data_subset_std: OptionType<FloatType>;
|
|
937
|
+
/** Closed-form E-value — confounder strength needed to explain the effect away. */
|
|
938
|
+
readonly robustness_value: OptionType<FloatType>;
|
|
939
|
+
/** Unobserved-confounder sensitivity (tipping) curve: effect at each simulated strength. */
|
|
940
|
+
readonly sensitivity: OptionType<StructType<{
|
|
941
|
+
readonly strengths: VectorType<FloatType>;
|
|
942
|
+
readonly effects: VectorType<FloatType>;
|
|
969
943
|
}>>;
|
|
970
|
-
/** Treat the treatment as discrete/categorical (default false) */
|
|
971
|
-
readonly discrete_treatment: OptionType<BooleanType>;
|
|
972
|
-
/** Cross-fitting folds (default 2) */
|
|
973
|
-
readonly cv_folds: OptionType<IntegerType>;
|
|
974
|
-
/** Confidence level for effect/ATE intervals (default 0.95) */
|
|
975
|
-
readonly confidence_level: OptionType<FloatType>;
|
|
976
|
-
/** Random seed */
|
|
977
|
-
readonly random_state: OptionType<IntegerType>;
|
|
978
944
|
}>;
|
|
979
|
-
readonly
|
|
980
|
-
/** Column names for the data matrix (one per column, in order) */
|
|
981
|
-
readonly columns: ArrayType<StringType>;
|
|
982
|
-
/** Outcome column the emulator predicts */
|
|
983
|
-
readonly outcome: StringType;
|
|
984
|
-
/** Continuous feature column to compute the ALE curve for */
|
|
945
|
+
readonly DoseResponseType: StructType<{
|
|
985
946
|
readonly feature: StringType;
|
|
986
|
-
|
|
987
|
-
readonly
|
|
988
|
-
|
|
989
|
-
readonly
|
|
990
|
-
/**
|
|
991
|
-
readonly
|
|
992
|
-
/** Confidence level for the CI (default 0.95) */
|
|
993
|
-
readonly confidence_level: OptionType<FloatType>;
|
|
994
|
-
/** Emulator (HistGradientBoosting) hyperparameters */
|
|
995
|
-
readonly emulator: OptionType<StructType<{
|
|
996
|
-
/** Number of boosting iterations (default 300) */
|
|
997
|
-
readonly n_estimators: OptionType<IntegerType>;
|
|
998
|
-
/** Learning rate (default 0.05) */
|
|
999
|
-
readonly learning_rate: OptionType<FloatType>;
|
|
1000
|
-
/** Maximum tree depth (default unlimited) */
|
|
1001
|
-
readonly max_depth: OptionType<IntegerType>;
|
|
1002
|
-
/** Minimum samples per leaf (default 20; lower for small datasets) */
|
|
1003
|
-
readonly min_samples_leaf: OptionType<IntegerType>;
|
|
1004
|
-
}>>;
|
|
1005
|
-
/** Random seed for the emulator */
|
|
1006
|
-
readonly random_state: OptionType<IntegerType>;
|
|
947
|
+
readonly grid: VectorType<FloatType>;
|
|
948
|
+
readonly effect: VectorType<FloatType>;
|
|
949
|
+
readonly lower: OptionType<VectorType<FloatType>>;
|
|
950
|
+
readonly upper: OptionType<VectorType<FloatType>>;
|
|
951
|
+
/** Rows per dose bin — drives the surface's "you are here" (busiest bin) marker. */
|
|
952
|
+
readonly size: VectorType<IntegerType>;
|
|
1007
953
|
}>;
|
|
1008
|
-
readonly
|
|
1009
|
-
/**
|
|
1010
|
-
readonly
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
954
|
+
readonly ExperimentVerdictType: VariantType<{
|
|
955
|
+
/** A real, robust, material effect. */
|
|
956
|
+
readonly causal: NullType;
|
|
957
|
+
/** A small but real effect, or no clear effect after adjustment. */
|
|
958
|
+
readonly modest: NullType;
|
|
959
|
+
/** Adjusted, but the estimate isn't trustworthy (placebo fails). */
|
|
960
|
+
readonly adjustment_insufficient: NullType;
|
|
961
|
+
/** No like-for-like comparison exists (positivity violated). */
|
|
962
|
+
readonly non_identifiable_positivity: NullType;
|
|
963
|
+
/** The estimand can't be formed (treatment barely varies). */
|
|
964
|
+
readonly not_estimable: StringType;
|
|
1018
965
|
}>;
|
|
1019
|
-
readonly
|
|
1020
|
-
/**
|
|
1021
|
-
readonly
|
|
1022
|
-
|
|
1023
|
-
readonly ci: OptionType<StructType<{
|
|
1024
|
-
/** Lower bound */
|
|
966
|
+
readonly CausalExperimentResultType: StructType<{
|
|
967
|
+
/** The raw (unadjusted) mean difference — always computable. */
|
|
968
|
+
readonly naive: FloatType;
|
|
969
|
+
readonly naive_ci: OptionType<StructType<{
|
|
1025
970
|
readonly lower: FloatType;
|
|
1026
|
-
/** Upper bound */
|
|
1027
971
|
readonly upper: FloatType;
|
|
1028
972
|
}>>;
|
|
1029
|
-
/**
|
|
1030
|
-
readonly
|
|
1031
|
-
|
|
973
|
+
/** The adjusted (like-for-like) effect + CI; `none` ⇒ the engine refused. */
|
|
974
|
+
readonly adjusted: OptionType<StructType<{
|
|
975
|
+
readonly effect: FloatType;
|
|
976
|
+
readonly ci: OptionType<StructType<{
|
|
977
|
+
readonly lower: FloatType;
|
|
978
|
+
readonly upper: FloatType;
|
|
979
|
+
}>>;
|
|
980
|
+
}>>;
|
|
981
|
+
readonly n_total: IntegerType;
|
|
1032
982
|
readonly n_treated: IntegerType;
|
|
1033
|
-
/** Control rows used */
|
|
1034
983
|
readonly n_control: IntegerType;
|
|
984
|
+
readonly n_dropped: IntegerType;
|
|
985
|
+
/** Per-confounder before-adjustment imbalance, most-imbalanced first. */
|
|
986
|
+
readonly balance: ArrayType<StructType<{
|
|
987
|
+
readonly column: StringType;
|
|
988
|
+
/** The original confounder this row belongs to — equals `column` for a numeric
|
|
989
|
+
* confounder; the base confounder for a one-hot categorical level. */
|
|
990
|
+
readonly base_column: StringType;
|
|
991
|
+
readonly treated_mean: FloatType;
|
|
992
|
+
readonly control_mean: FloatType;
|
|
993
|
+
/** Standardized mean difference, (mt-mc)/sqrt((vt+vc)/2). */
|
|
994
|
+
readonly std_diff: FloatType;
|
|
995
|
+
}>>;
|
|
996
|
+
readonly overlap: StructType<{
|
|
997
|
+
/** Propensity histogram (20 bins over [0,1]) for the treated arm. */
|
|
998
|
+
readonly treated_propensity: VectorType<FloatType>;
|
|
999
|
+
/** Propensity histogram for the control arm. */
|
|
1000
|
+
readonly control_propensity: VectorType<FloatType>;
|
|
1001
|
+
/** Fraction of rows inside the treated/control common support. */
|
|
1002
|
+
readonly common_support_frac: FloatType;
|
|
1003
|
+
/** Whether common support clears `min_overlap`. */
|
|
1004
|
+
readonly positivity_ok: BooleanType;
|
|
1005
|
+
}>;
|
|
1006
|
+
readonly refutation: OptionType<StructType<{
|
|
1007
|
+
/** Effect under a permuted (placebo) treatment — should be ≈ 0. */
|
|
1008
|
+
readonly placebo_effect: OptionType<FloatType>;
|
|
1009
|
+
/** Whether the placebo effect vanished. */
|
|
1010
|
+
readonly placebo_passes: OptionType<BooleanType>;
|
|
1011
|
+
/** Whether a decoy random common cause left the estimate inside its CI. */
|
|
1012
|
+
readonly random_cc_within_ci: OptionType<BooleanType>;
|
|
1013
|
+
/** Mean effect across data subsamples (stability). */
|
|
1014
|
+
readonly data_subset_effect: OptionType<FloatType>;
|
|
1015
|
+
/** Std of the effect across data subsamples. */
|
|
1016
|
+
readonly data_subset_std: OptionType<FloatType>;
|
|
1017
|
+
/** Closed-form E-value — confounder strength needed to explain the effect away. */
|
|
1018
|
+
readonly robustness_value: OptionType<FloatType>;
|
|
1019
|
+
/** Unobserved-confounder sensitivity (tipping) curve: effect at each simulated strength. */
|
|
1020
|
+
readonly sensitivity: OptionType<StructType<{
|
|
1021
|
+
readonly strengths: VectorType<FloatType>;
|
|
1022
|
+
readonly effects: VectorType<FloatType>;
|
|
1023
|
+
}>>;
|
|
1024
|
+
}>>;
|
|
1025
|
+
/** ALE dose-response of `dose_feature` (present when `config.dose_feature` is set). */
|
|
1026
|
+
readonly dose_response: OptionType<StructType<{
|
|
1027
|
+
readonly feature: StringType;
|
|
1028
|
+
readonly grid: VectorType<FloatType>;
|
|
1029
|
+
readonly effect: VectorType<FloatType>;
|
|
1030
|
+
readonly lower: OptionType<VectorType<FloatType>>;
|
|
1031
|
+
readonly upper: OptionType<VectorType<FloatType>>;
|
|
1032
|
+
/** Rows per dose bin — drives the surface's "you are here" (busiest bin) marker. */
|
|
1033
|
+
readonly size: VectorType<IntegerType>;
|
|
1034
|
+
}>>;
|
|
1035
|
+
readonly verdict: VariantType<{
|
|
1036
|
+
/** A real, robust, material effect. */
|
|
1037
|
+
readonly causal: NullType;
|
|
1038
|
+
/** A small but real effect, or no clear effect after adjustment. */
|
|
1039
|
+
readonly modest: NullType;
|
|
1040
|
+
/** Adjusted, but the estimate isn't trustworthy (placebo fails). */
|
|
1041
|
+
readonly adjustment_insufficient: NullType;
|
|
1042
|
+
/** No like-for-like comparison exists (positivity violated). */
|
|
1043
|
+
readonly non_identifiable_positivity: NullType;
|
|
1044
|
+
/** The estimand can't be formed (treatment barely varies). */
|
|
1045
|
+
readonly not_estimable: StringType;
|
|
1046
|
+
}>;
|
|
1035
1047
|
}>;
|
|
1036
|
-
readonly
|
|
1037
|
-
/**
|
|
1038
|
-
readonly
|
|
1039
|
-
/**
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1048
|
+
readonly DesignBasisType: VariantType<{
|
|
1049
|
+
/** Clear effect → power the trial to detect the observed effect. */
|
|
1050
|
+
readonly detect_observed: NullType;
|
|
1051
|
+
/** Fuzzy / maybe-nothing → power to the smallest effect worth acting on. */
|
|
1052
|
+
readonly resolve_vs_null: NullType;
|
|
1053
|
+
/** A trust check failed → randomise to remove the bias adjustment couldn't. */
|
|
1054
|
+
readonly de_bias: NullType;
|
|
1055
|
+
/** No overlap → randomise within the comparable range. */
|
|
1056
|
+
readonly restrict_to_overlap: NullType;
|
|
1057
|
+
/** No control group exists → hold back a random sample next time. */
|
|
1058
|
+
readonly create_control: NullType;
|
|
1046
1059
|
}>;
|
|
1047
|
-
readonly
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
readonly
|
|
1052
|
-
|
|
1053
|
-
readonly
|
|
1060
|
+
readonly TrialOptionType: StructType<{
|
|
1061
|
+
readonly label: StringType;
|
|
1062
|
+
/** Fraction assigned to the treatment (0..1; 0.5 = even). */
|
|
1063
|
+
readonly treated_share: FloatType;
|
|
1064
|
+
readonly n_treated: IntegerType;
|
|
1065
|
+
readonly n_control: IntegerType;
|
|
1066
|
+
readonly n_total: IntegerType;
|
|
1054
1067
|
}>;
|
|
1055
|
-
readonly
|
|
1056
|
-
|
|
1057
|
-
readonly
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1068
|
+
readonly PowerCurveType: StructType<{
|
|
1069
|
+
readonly n: VectorType<IntegerType>;
|
|
1070
|
+
readonly power: VectorType<FloatType>;
|
|
1071
|
+
}>;
|
|
1072
|
+
readonly ExperimentDesignType: StructType<{
|
|
1073
|
+
readonly verdict: VariantType<{
|
|
1074
|
+
/** A real, robust, material effect. */
|
|
1075
|
+
readonly causal: NullType;
|
|
1076
|
+
/** A small but real effect, or no clear effect after adjustment. */
|
|
1077
|
+
readonly modest: NullType;
|
|
1078
|
+
/** Adjusted, but the estimate isn't trustworthy (placebo fails). */
|
|
1079
|
+
readonly adjustment_insufficient: NullType;
|
|
1080
|
+
/** No like-for-like comparison exists (positivity violated). */
|
|
1081
|
+
readonly non_identifiable_positivity: NullType;
|
|
1082
|
+
/** The estimand can't be formed (treatment barely varies). */
|
|
1083
|
+
readonly not_estimable: StringType;
|
|
1084
|
+
}>;
|
|
1085
|
+
readonly basis: VariantType<{
|
|
1086
|
+
/** Clear effect → power the trial to detect the observed effect. */
|
|
1087
|
+
readonly detect_observed: NullType;
|
|
1088
|
+
/** Fuzzy / maybe-nothing → power to the smallest effect worth acting on. */
|
|
1089
|
+
readonly resolve_vs_null: NullType;
|
|
1090
|
+
/** A trust check failed → randomise to remove the bias adjustment couldn't. */
|
|
1091
|
+
readonly de_bias: NullType;
|
|
1092
|
+
/** No overlap → randomise within the comparable range. */
|
|
1093
|
+
readonly restrict_to_overlap: NullType;
|
|
1094
|
+
/** No control group exists → hold back a random sample next time. */
|
|
1095
|
+
readonly create_control: NullType;
|
|
1096
|
+
}>;
|
|
1097
|
+
/** Effect size the trial is powered to detect (observed, or materiality). */
|
|
1098
|
+
readonly target_effect: FloatType;
|
|
1099
|
+
/** Outcome spread (pooled SD) used to size it. */
|
|
1100
|
+
readonly outcome_sd: FloatType;
|
|
1101
|
+
readonly target_power: FloatType;
|
|
1102
|
+
readonly alpha: FloatType;
|
|
1103
|
+
/** Chance the CURRENT sample would already detect `target_effect`; `none` when there's no comparison group. */
|
|
1104
|
+
readonly current_power: OptionType<FloatType>;
|
|
1105
|
+
/** Categories both groups must be matched on (most-imbalanced confounders). */
|
|
1106
|
+
readonly match_on: ArrayType<StringType>;
|
|
1107
|
+
/** Ranked split options (even split first; cost-saving alternates). */
|
|
1108
|
+
readonly options: ArrayType<StructType<{
|
|
1109
|
+
readonly label: StringType;
|
|
1110
|
+
/** Fraction assigned to the treatment (0..1; 0.5 = even). */
|
|
1111
|
+
readonly treated_share: FloatType;
|
|
1112
|
+
readonly n_treated: IntegerType;
|
|
1113
|
+
readonly n_control: IntegerType;
|
|
1114
|
+
readonly n_total: IntegerType;
|
|
1115
|
+
}>>;
|
|
1116
|
+
/** The detect-chance curve for the chart. */
|
|
1117
|
+
readonly power_curve: StructType<{
|
|
1118
|
+
readonly n: VectorType<IntegerType>;
|
|
1119
|
+
readonly power: VectorType<FloatType>;
|
|
1120
|
+
}>;
|
|
1121
|
+
/** One generated, plain-language sentence framing the recipe. */
|
|
1122
|
+
readonly rationale: StringType;
|
|
1123
|
+
}>;
|
|
1124
|
+
readonly DesignConfigType: StructType<{
|
|
1125
|
+
/** Significance level (default 0.05). */
|
|
1126
|
+
readonly alpha: OptionType<FloatType>;
|
|
1127
|
+
/** Target chance of detecting the effect (default 0.8). */
|
|
1128
|
+
readonly target_power: OptionType<FloatType>;
|
|
1129
|
+
/** Smallest effect worth acting on — sizes the trial to this when set / when there's no trustworthy observed effect. */
|
|
1130
|
+
readonly materiality: OptionType<FloatType>;
|
|
1131
|
+
/** Treatment shares to offer as options (default [0.5]). */
|
|
1132
|
+
readonly treated_shares: OptionType<ArrayType<FloatType>>;
|
|
1066
1133
|
}>;
|
|
1067
1134
|
};
|
|
1068
1135
|
/**
|
|
1069
|
-
* Causal inference.
|
|
1136
|
+
* Causal inference — one declarative entry point.
|
|
1070
1137
|
*
|
|
1071
|
-
*
|
|
1072
|
-
*
|
|
1073
|
-
*
|
|
1074
|
-
*
|
|
1138
|
+
* `Causal.experiment(data, config)` runs a complete, honest causal experiment
|
|
1139
|
+
* for a binary treatment and returns the naive vs adjusted effect, confounder
|
|
1140
|
+
* balance, propensity overlap, a robustness check, and a verdict
|
|
1141
|
+
* (`causal` / `modest` / `adjustment_insufficient` / `non_identifiable_positivity`
|
|
1142
|
+
* / `not_estimable`). It refuses (`adjusted = none`) when the data can't support
|
|
1143
|
+
* an estimate. DoWhy / EconML / PyALE are internal implementation it composes.
|
|
1075
1144
|
*
|
|
1076
1145
|
* @example
|
|
1077
1146
|
* ```ts
|
|
1078
|
-
* import { East, FloatType, variant } from "@elaraai/east";
|
|
1079
|
-
* import { Causal
|
|
1147
|
+
* import { East, ArrayType, StructType, FloatType, BooleanType, variant } from "@elaraai/east";
|
|
1148
|
+
* import { Causal } from "@elaraai/east-py-datascience";
|
|
1080
1149
|
*
|
|
1081
|
-
* const
|
|
1082
|
-
*
|
|
1083
|
-
*
|
|
1084
|
-
*
|
|
1085
|
-
*
|
|
1086
|
-
*
|
|
1087
|
-
*
|
|
1088
|
-
*
|
|
1089
|
-
*
|
|
1090
|
-
*
|
|
1091
|
-
*
|
|
1092
|
-
*
|
|
1093
|
-
* trim: variant('none', null),
|
|
1094
|
-
* bootstrap: variant('none', null),
|
|
1095
|
-
* random_state: variant('some', 42n),
|
|
1096
|
-
* }, Causal.Types.CausalEffectConfigType);
|
|
1097
|
-
* return $.return(Causal.effect(data, config));
|
|
1098
|
-
* }
|
|
1099
|
-
* );
|
|
1150
|
+
* const Row = StructType({ treated: BooleanType, outcome: FloatType, z: FloatType });
|
|
1151
|
+
* const run = East.function([ArrayType(Row)], Causal.Types.CausalExperimentResultType, ($, data) => {
|
|
1152
|
+
* const config = $.let({
|
|
1153
|
+
* treatment: "treated", outcome: "outcome", common_causes: ["z"],
|
|
1154
|
+
* categorical: variant('none', null),
|
|
1155
|
+
* method: variant('none', null), estimand: variant('none', null),
|
|
1156
|
+
* refute: variant('some', { placebo: true, random_common_cause: false }),
|
|
1157
|
+
* min_overlap: variant('some', 0.1), min_treatment_variation: variant('some', 0.02),
|
|
1158
|
+
* bootstrap: variant('none', null), random_state: variant('some', 42n),
|
|
1159
|
+
* }, Causal.Types.CausalExperimentConfigType);
|
|
1160
|
+
* return $.return(Causal.experiment([Row], data, config));
|
|
1161
|
+
* });
|
|
1100
1162
|
* ```
|
|
1101
1163
|
*/
|
|
1102
1164
|
export declare const Causal: {
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
*
|
|
1106
|
-
* Linear regression or inverse propensity score weighting (with
|
|
1107
|
-
* optional propensity trimming), plus optional cluster bootstrap CI.
|
|
1108
|
-
*
|
|
1109
|
-
* @example
|
|
1110
|
-
* ```ts
|
|
1111
|
-
* import { East, FloatType, variant } from "@elaraai/east";
|
|
1112
|
-
* import { Causal, CausalEffectConfigType, MatrixType } from "@elaraai/east-py-datascience";
|
|
1113
|
-
*
|
|
1114
|
-
* const attEstimate = East.function(
|
|
1115
|
-
* [MatrixType(FloatType)],
|
|
1116
|
-
* Causal.Types.CausalEffectResultType,
|
|
1117
|
-
* ($, data) => {
|
|
1118
|
-
* const config = $.let({
|
|
1119
|
-
* columns: ["treated", "outcome", "z1", "z2", "batch"],
|
|
1120
|
-
* treatment: "treated",
|
|
1121
|
-
* outcome: "outcome",
|
|
1122
|
-
* common_causes: ["z1", "z2"],
|
|
1123
|
-
* categorical: variant('none', null),
|
|
1124
|
-
* method: variant('some', variant('propensity_score_weighting', {
|
|
1125
|
-
* weighting_scheme: variant('some', variant('ips_stabilized_weight', null)),
|
|
1126
|
-
* })),
|
|
1127
|
-
* target_units: variant('some', variant('att', null)),
|
|
1128
|
-
* trim: variant('some', variant('overlap', null)),
|
|
1129
|
-
* bootstrap: variant('some', {
|
|
1130
|
-
* reps: 200n,
|
|
1131
|
-
* cluster_column: variant('some', "batch"),
|
|
1132
|
-
* confidence_level: variant('some', 0.95),
|
|
1133
|
-
* }),
|
|
1134
|
-
* random_state: variant('some', 42n),
|
|
1135
|
-
* }, CausalEffectConfigType);
|
|
1136
|
-
* return $.return(Causal.effect(data, config));
|
|
1137
|
-
* }
|
|
1138
|
-
* );
|
|
1139
|
-
* ```
|
|
1140
|
-
*/
|
|
1141
|
-
readonly effect: import("@elaraai/east").PlatformDefinition<[MatrixType<FloatType>, StructType<{
|
|
1142
|
-
/** Column names for the data matrix (one per column, in order) */
|
|
1143
|
-
readonly columns: ArrayType<StringType>;
|
|
1144
|
-
/** Treatment column (must be 0/1 for propensity score weighting) */
|
|
1165
|
+
readonly experiment: import("@elaraai/east").GenericPlatformDefinition<readonly ["T"], readonly [ArrayType<unknown>, StructType<{
|
|
1166
|
+
/** Binary (0/1) treatment column. */
|
|
1145
1167
|
readonly treatment: StringType;
|
|
1146
|
-
/** Outcome column */
|
|
1168
|
+
/** Outcome column. */
|
|
1147
1169
|
readonly outcome: StringType;
|
|
1148
|
-
/**
|
|
1170
|
+
/** Confounders to adjust for (the backdoor set). */
|
|
1149
1171
|
readonly common_causes: ArrayType<StringType>;
|
|
1150
|
-
/**
|
|
1172
|
+
/** Confounder columns holding categories (string or int codes), one-hot encoded. */
|
|
1151
1173
|
readonly categorical: OptionType<ArrayType<StringType>>;
|
|
1152
|
-
/**
|
|
1174
|
+
/** Estimator (default: linear_regression). */
|
|
1153
1175
|
readonly method: OptionType<VariantType<{
|
|
1154
|
-
/** Linear regression of outcome on treatment + common causes */
|
|
1176
|
+
/** Linear regression of outcome on treatment + common causes (default) */
|
|
1155
1177
|
readonly linear_regression: NullType;
|
|
1156
1178
|
/** Inverse propensity score weighting (binary treatment only) */
|
|
1157
1179
|
readonly propensity_score_weighting: StructType<{
|
|
@@ -1166,8 +1188,8 @@ export declare const Causal: {
|
|
|
1166
1188
|
}>>;
|
|
1167
1189
|
}>;
|
|
1168
1190
|
}>>;
|
|
1169
|
-
/** Target population (default: ate) */
|
|
1170
|
-
readonly
|
|
1191
|
+
/** Target population (default: ate). */
|
|
1192
|
+
readonly estimand: OptionType<VariantType<{
|
|
1171
1193
|
/** Average treatment effect over all units */
|
|
1172
1194
|
readonly ate: NullType;
|
|
1173
1195
|
/** Average treatment effect on the treated */
|
|
@@ -1175,82 +1197,129 @@ export declare const Causal: {
|
|
|
1175
1197
|
/** Average treatment effect on the controls */
|
|
1176
1198
|
readonly atc: NullType;
|
|
1177
1199
|
}>>;
|
|
1178
|
-
/**
|
|
1179
|
-
readonly
|
|
1180
|
-
/**
|
|
1181
|
-
readonly
|
|
1182
|
-
/**
|
|
1183
|
-
readonly
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
}>;
|
|
1200
|
+
/** Which robustness checks to run. */
|
|
1201
|
+
readonly refute: OptionType<StructType<{
|
|
1202
|
+
/** Permuted-treatment negative control — a real effect should vanish. */
|
|
1203
|
+
readonly placebo: BooleanType;
|
|
1204
|
+
/** Inject an independent random common cause — the effect should hold. */
|
|
1205
|
+
readonly random_common_cause: BooleanType;
|
|
1206
|
+
/** Re-estimate on random subsamples — the effect should be stable. */
|
|
1207
|
+
readonly data_subset: BooleanType;
|
|
1208
|
+
/** Unobserved-confounder strengths to simulate → the sensitivity / tipping curve. */
|
|
1209
|
+
readonly sensitivity: OptionType<ArrayType<FloatType>>;
|
|
1189
1210
|
}>>;
|
|
1190
|
-
/**
|
|
1211
|
+
/** Continuous column for the ALE dose-response curve (the "How much?" view). */
|
|
1212
|
+
readonly dose_feature: OptionType<StringType>;
|
|
1213
|
+
/** Positivity guard — common-support fraction below this → non_identifiable_positivity (default 0.10). */
|
|
1214
|
+
readonly min_overlap: OptionType<FloatType>;
|
|
1215
|
+
/** Not-estimable guard — minority-arm fraction below this → not_estimable (default 0.02). */
|
|
1216
|
+
readonly min_treatment_variation: OptionType<FloatType>;
|
|
1217
|
+
/** Bootstrap CI config (default: 200 reps, 0.95). */
|
|
1191
1218
|
readonly bootstrap: OptionType<StructType<{
|
|
1192
|
-
/** Number of bootstrap replicates */
|
|
1219
|
+
/** Number of bootstrap replicates (default 200) */
|
|
1193
1220
|
readonly reps: IntegerType;
|
|
1194
1221
|
/** Column whose values identify clusters to resample (default: resample rows) */
|
|
1195
1222
|
readonly cluster_column: OptionType<StringType>;
|
|
1196
1223
|
/** Confidence level for the percentile interval (default 0.95) */
|
|
1197
1224
|
readonly confidence_level: OptionType<FloatType>;
|
|
1198
1225
|
}>>;
|
|
1199
|
-
/** Random seed
|
|
1226
|
+
/** Random seed. */
|
|
1200
1227
|
readonly random_state: OptionType<IntegerType>;
|
|
1201
1228
|
}>], StructType<{
|
|
1202
|
-
/**
|
|
1203
|
-
readonly
|
|
1204
|
-
|
|
1205
|
-
readonly ci: OptionType<StructType<{
|
|
1206
|
-
/** Lower bound */
|
|
1229
|
+
/** The raw (unadjusted) mean difference — always computable. */
|
|
1230
|
+
readonly naive: FloatType;
|
|
1231
|
+
readonly naive_ci: OptionType<StructType<{
|
|
1207
1232
|
readonly lower: FloatType;
|
|
1208
|
-
/** Upper bound */
|
|
1209
1233
|
readonly upper: FloatType;
|
|
1210
1234
|
}>>;
|
|
1211
|
-
/**
|
|
1212
|
-
readonly
|
|
1213
|
-
|
|
1235
|
+
/** The adjusted (like-for-like) effect + CI; `none` ⇒ the engine refused. */
|
|
1236
|
+
readonly adjusted: OptionType<StructType<{
|
|
1237
|
+
readonly effect: FloatType;
|
|
1238
|
+
readonly ci: OptionType<StructType<{
|
|
1239
|
+
readonly lower: FloatType;
|
|
1240
|
+
readonly upper: FloatType;
|
|
1241
|
+
}>>;
|
|
1242
|
+
}>>;
|
|
1243
|
+
readonly n_total: IntegerType;
|
|
1214
1244
|
readonly n_treated: IntegerType;
|
|
1215
|
-
/** Control rows used */
|
|
1216
1245
|
readonly n_control: IntegerType;
|
|
1246
|
+
readonly n_dropped: IntegerType;
|
|
1247
|
+
/** Per-confounder before-adjustment imbalance, most-imbalanced first. */
|
|
1248
|
+
readonly balance: ArrayType<StructType<{
|
|
1249
|
+
readonly column: StringType;
|
|
1250
|
+
/** The original confounder this row belongs to — equals `column` for a numeric
|
|
1251
|
+
* confounder; the base confounder for a one-hot categorical level. */
|
|
1252
|
+
readonly base_column: StringType;
|
|
1253
|
+
readonly treated_mean: FloatType;
|
|
1254
|
+
readonly control_mean: FloatType;
|
|
1255
|
+
/** Standardized mean difference, (mt-mc)/sqrt((vt+vc)/2). */
|
|
1256
|
+
readonly std_diff: FloatType;
|
|
1257
|
+
}>>;
|
|
1258
|
+
readonly overlap: StructType<{
|
|
1259
|
+
/** Propensity histogram (20 bins over [0,1]) for the treated arm. */
|
|
1260
|
+
readonly treated_propensity: VectorType<FloatType>;
|
|
1261
|
+
/** Propensity histogram for the control arm. */
|
|
1262
|
+
readonly control_propensity: VectorType<FloatType>;
|
|
1263
|
+
/** Fraction of rows inside the treated/control common support. */
|
|
1264
|
+
readonly common_support_frac: FloatType;
|
|
1265
|
+
/** Whether common support clears `min_overlap`. */
|
|
1266
|
+
readonly positivity_ok: BooleanType;
|
|
1267
|
+
}>;
|
|
1268
|
+
readonly refutation: OptionType<StructType<{
|
|
1269
|
+
/** Effect under a permuted (placebo) treatment — should be ≈ 0. */
|
|
1270
|
+
readonly placebo_effect: OptionType<FloatType>;
|
|
1271
|
+
/** Whether the placebo effect vanished. */
|
|
1272
|
+
readonly placebo_passes: OptionType<BooleanType>;
|
|
1273
|
+
/** Whether a decoy random common cause left the estimate inside its CI. */
|
|
1274
|
+
readonly random_cc_within_ci: OptionType<BooleanType>;
|
|
1275
|
+
/** Mean effect across data subsamples (stability). */
|
|
1276
|
+
readonly data_subset_effect: OptionType<FloatType>;
|
|
1277
|
+
/** Std of the effect across data subsamples. */
|
|
1278
|
+
readonly data_subset_std: OptionType<FloatType>;
|
|
1279
|
+
/** Closed-form E-value — confounder strength needed to explain the effect away. */
|
|
1280
|
+
readonly robustness_value: OptionType<FloatType>;
|
|
1281
|
+
/** Unobserved-confounder sensitivity (tipping) curve: effect at each simulated strength. */
|
|
1282
|
+
readonly sensitivity: OptionType<StructType<{
|
|
1283
|
+
readonly strengths: VectorType<FloatType>;
|
|
1284
|
+
readonly effects: VectorType<FloatType>;
|
|
1285
|
+
}>>;
|
|
1286
|
+
}>>;
|
|
1287
|
+
/** ALE dose-response of `dose_feature` (present when `config.dose_feature` is set). */
|
|
1288
|
+
readonly dose_response: OptionType<StructType<{
|
|
1289
|
+
readonly feature: StringType;
|
|
1290
|
+
readonly grid: VectorType<FloatType>;
|
|
1291
|
+
readonly effect: VectorType<FloatType>;
|
|
1292
|
+
readonly lower: OptionType<VectorType<FloatType>>;
|
|
1293
|
+
readonly upper: OptionType<VectorType<FloatType>>;
|
|
1294
|
+
/** Rows per dose bin — drives the surface's "you are here" (busiest bin) marker. */
|
|
1295
|
+
readonly size: VectorType<IntegerType>;
|
|
1296
|
+
}>>;
|
|
1297
|
+
readonly verdict: VariantType<{
|
|
1298
|
+
/** A real, robust, material effect. */
|
|
1299
|
+
readonly causal: NullType;
|
|
1300
|
+
/** A small but real effect, or no clear effect after adjustment. */
|
|
1301
|
+
readonly modest: NullType;
|
|
1302
|
+
/** Adjusted, but the estimate isn't trustworthy (placebo fails). */
|
|
1303
|
+
readonly adjustment_insufficient: NullType;
|
|
1304
|
+
/** No like-for-like comparison exists (positivity violated). */
|
|
1305
|
+
readonly non_identifiable_positivity: NullType;
|
|
1306
|
+
/** The estimand can't be formed (treatment barely varies). */
|
|
1307
|
+
readonly not_estimable: StringType;
|
|
1308
|
+
}>;
|
|
1217
1309
|
}>>;
|
|
1218
|
-
/**
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
*
|
|
1222
|
-
* @example
|
|
1223
|
-
* ```ts
|
|
1224
|
-
* import { East, FloatType, variant } from "@elaraai/east";
|
|
1225
|
-
* import { Causal, MatrixType } from "@elaraai/east-py-datascience";
|
|
1226
|
-
*
|
|
1227
|
-
* const placebo = East.function(
|
|
1228
|
-
* [MatrixType(FloatType), Causal.Types.CausalEffectConfigType],
|
|
1229
|
-
* Causal.Types.CausalRefuteResultType,
|
|
1230
|
-
* ($, data, config) => {
|
|
1231
|
-
* const refuter = $.let(variant('placebo_treatment', {
|
|
1232
|
-
* num_simulations: variant('some', 50n),
|
|
1233
|
-
* }), Causal.Types.CausalRefuterType);
|
|
1234
|
-
* // new_effects should be near zero if the estimate is causal
|
|
1235
|
-
* return $.return(Causal.refute(data, config, refuter));
|
|
1236
|
-
* }
|
|
1237
|
-
* );
|
|
1238
|
-
* ```
|
|
1239
|
-
*/
|
|
1240
|
-
readonly refute: import("@elaraai/east").PlatformDefinition<[MatrixType<FloatType>, StructType<{
|
|
1241
|
-
/** Column names for the data matrix (one per column, in order) */
|
|
1242
|
-
readonly columns: ArrayType<StringType>;
|
|
1243
|
-
/** Treatment column (must be 0/1 for propensity score weighting) */
|
|
1310
|
+
/** Design the real controlled trial that would validate an experiment result. */
|
|
1311
|
+
readonly designValidation: import("@elaraai/east").GenericPlatformDefinition<readonly ["T"], readonly [ArrayType<unknown>, StructType<{
|
|
1312
|
+
/** Binary (0/1) treatment column. */
|
|
1244
1313
|
readonly treatment: StringType;
|
|
1245
|
-
/** Outcome column */
|
|
1314
|
+
/** Outcome column. */
|
|
1246
1315
|
readonly outcome: StringType;
|
|
1247
|
-
/**
|
|
1316
|
+
/** Confounders to adjust for (the backdoor set). */
|
|
1248
1317
|
readonly common_causes: ArrayType<StringType>;
|
|
1249
|
-
/**
|
|
1318
|
+
/** Confounder columns holding categories (string or int codes), one-hot encoded. */
|
|
1250
1319
|
readonly categorical: OptionType<ArrayType<StringType>>;
|
|
1251
|
-
/**
|
|
1320
|
+
/** Estimator (default: linear_regression). */
|
|
1252
1321
|
readonly method: OptionType<VariantType<{
|
|
1253
|
-
/** Linear regression of outcome on treatment + common causes */
|
|
1322
|
+
/** Linear regression of outcome on treatment + common causes (default) */
|
|
1254
1323
|
readonly linear_regression: NullType;
|
|
1255
1324
|
/** Inverse propensity score weighting (binary treatment only) */
|
|
1256
1325
|
readonly propensity_score_weighting: StructType<{
|
|
@@ -1265,8 +1334,8 @@ export declare const Causal: {
|
|
|
1265
1334
|
}>>;
|
|
1266
1335
|
}>;
|
|
1267
1336
|
}>>;
|
|
1268
|
-
/** Target population (default: ate) */
|
|
1269
|
-
readonly
|
|
1337
|
+
/** Target population (default: ate). */
|
|
1338
|
+
readonly estimand: OptionType<VariantType<{
|
|
1270
1339
|
/** Average treatment effect over all units */
|
|
1271
1340
|
readonly ate: NullType;
|
|
1272
1341
|
/** Average treatment effect on the treated */
|
|
@@ -1274,289 +1343,175 @@ export declare const Causal: {
|
|
|
1274
1343
|
/** Average treatment effect on the controls */
|
|
1275
1344
|
readonly atc: NullType;
|
|
1276
1345
|
}>>;
|
|
1277
|
-
/**
|
|
1278
|
-
readonly
|
|
1279
|
-
/**
|
|
1280
|
-
readonly
|
|
1281
|
-
/**
|
|
1282
|
-
readonly
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
}>;
|
|
1346
|
+
/** Which robustness checks to run. */
|
|
1347
|
+
readonly refute: OptionType<StructType<{
|
|
1348
|
+
/** Permuted-treatment negative control — a real effect should vanish. */
|
|
1349
|
+
readonly placebo: BooleanType;
|
|
1350
|
+
/** Inject an independent random common cause — the effect should hold. */
|
|
1351
|
+
readonly random_common_cause: BooleanType;
|
|
1352
|
+
/** Re-estimate on random subsamples — the effect should be stable. */
|
|
1353
|
+
readonly data_subset: BooleanType;
|
|
1354
|
+
/** Unobserved-confounder strengths to simulate → the sensitivity / tipping curve. */
|
|
1355
|
+
readonly sensitivity: OptionType<ArrayType<FloatType>>;
|
|
1288
1356
|
}>>;
|
|
1289
|
-
/**
|
|
1357
|
+
/** Continuous column for the ALE dose-response curve (the "How much?" view). */
|
|
1358
|
+
readonly dose_feature: OptionType<StringType>;
|
|
1359
|
+
/** Positivity guard — common-support fraction below this → non_identifiable_positivity (default 0.10). */
|
|
1360
|
+
readonly min_overlap: OptionType<FloatType>;
|
|
1361
|
+
/** Not-estimable guard — minority-arm fraction below this → not_estimable (default 0.02). */
|
|
1362
|
+
readonly min_treatment_variation: OptionType<FloatType>;
|
|
1363
|
+
/** Bootstrap CI config (default: 200 reps, 0.95). */
|
|
1290
1364
|
readonly bootstrap: OptionType<StructType<{
|
|
1291
|
-
/** Number of bootstrap replicates */
|
|
1365
|
+
/** Number of bootstrap replicates (default 200) */
|
|
1292
1366
|
readonly reps: IntegerType;
|
|
1293
1367
|
/** Column whose values identify clusters to resample (default: resample rows) */
|
|
1294
1368
|
readonly cluster_column: OptionType<StringType>;
|
|
1295
1369
|
/** Confidence level for the percentile interval (default 0.95) */
|
|
1296
1370
|
readonly confidence_level: OptionType<FloatType>;
|
|
1297
1371
|
}>>;
|
|
1298
|
-
/** Random seed
|
|
1372
|
+
/** Random seed. */
|
|
1299
1373
|
readonly random_state: OptionType<IntegerType>;
|
|
1300
|
-
}>,
|
|
1301
|
-
/**
|
|
1302
|
-
readonly
|
|
1303
|
-
|
|
1304
|
-
readonly
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
readonly
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
readonly
|
|
1374
|
+
}>, StructType<{
|
|
1375
|
+
/** The raw (unadjusted) mean difference — always computable. */
|
|
1376
|
+
readonly naive: FloatType;
|
|
1377
|
+
readonly naive_ci: OptionType<StructType<{
|
|
1378
|
+
readonly lower: FloatType;
|
|
1379
|
+
readonly upper: FloatType;
|
|
1380
|
+
}>>;
|
|
1381
|
+
/** The adjusted (like-for-like) effect + CI; `none` ⇒ the engine refused. */
|
|
1382
|
+
readonly adjusted: OptionType<StructType<{
|
|
1383
|
+
readonly effect: FloatType;
|
|
1384
|
+
readonly ci: OptionType<StructType<{
|
|
1385
|
+
readonly lower: FloatType;
|
|
1386
|
+
readonly upper: FloatType;
|
|
1387
|
+
}>>;
|
|
1388
|
+
}>>;
|
|
1389
|
+
readonly n_total: IntegerType;
|
|
1390
|
+
readonly n_treated: IntegerType;
|
|
1391
|
+
readonly n_control: IntegerType;
|
|
1392
|
+
readonly n_dropped: IntegerType;
|
|
1393
|
+
/** Per-confounder before-adjustment imbalance, most-imbalanced first. */
|
|
1394
|
+
readonly balance: ArrayType<StructType<{
|
|
1395
|
+
readonly column: StringType;
|
|
1396
|
+
/** The original confounder this row belongs to — equals `column` for a numeric
|
|
1397
|
+
* confounder; the base confounder for a one-hot categorical level. */
|
|
1398
|
+
readonly base_column: StringType;
|
|
1399
|
+
readonly treated_mean: FloatType;
|
|
1400
|
+
readonly control_mean: FloatType;
|
|
1401
|
+
/** Standardized mean difference, (mt-mc)/sqrt((vt+vc)/2). */
|
|
1402
|
+
readonly std_diff: FloatType;
|
|
1403
|
+
}>>;
|
|
1404
|
+
readonly overlap: StructType<{
|
|
1405
|
+
/** Propensity histogram (20 bins over [0,1]) for the treated arm. */
|
|
1406
|
+
readonly treated_propensity: VectorType<FloatType>;
|
|
1407
|
+
/** Propensity histogram for the control arm. */
|
|
1408
|
+
readonly control_propensity: VectorType<FloatType>;
|
|
1409
|
+
/** Fraction of rows inside the treated/control common support. */
|
|
1410
|
+
readonly common_support_frac: FloatType;
|
|
1411
|
+
/** Whether common support clears `min_overlap`. */
|
|
1412
|
+
readonly positivity_ok: BooleanType;
|
|
1327
1413
|
}>;
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
*
|
|
1347
|
-
* const train = East.function(
|
|
1348
|
-
* [VectorType(FloatType), VectorType(FloatType), MatrixType(FloatType), MatrixType(FloatType)],
|
|
1349
|
-
* Causal.Types.CausalDMLModelBlobType,
|
|
1350
|
-
* ($, Y, T, X, W) => {
|
|
1351
|
-
* const config = $.let({
|
|
1352
|
-
* model_y: variant('some', variant('random_forest', {
|
|
1353
|
-
* n_estimators: variant('some', 100n),
|
|
1354
|
-
* min_samples_leaf: variant('some', 5n),
|
|
1355
|
-
* max_depth: variant('none', null),
|
|
1356
|
-
* })),
|
|
1357
|
-
* model_t: variant('none', null),
|
|
1358
|
-
* discrete_treatment: variant('none', null),
|
|
1359
|
-
* cv_folds: variant('some', 2n),
|
|
1360
|
-
* confidence_level: variant('some', 0.95),
|
|
1361
|
-
* random_state: variant('some', 42n),
|
|
1362
|
-
* }, CausalDMLConfigType);
|
|
1363
|
-
* return $.return(Causal.dmlTrain(Y, T, X, variant('some', W), config));
|
|
1364
|
-
* }
|
|
1365
|
-
* );
|
|
1366
|
-
* ```
|
|
1367
|
-
*/
|
|
1368
|
-
readonly dmlTrain: import("@elaraai/east").PlatformDefinition<[VectorType<FloatType>, VectorType<FloatType>, MatrixType<FloatType>, OptionType<MatrixType<FloatType>>, StructType<{
|
|
1369
|
-
/** Nuisance model for the outcome stage (default: random_forest) */
|
|
1370
|
-
readonly model_y: OptionType<VariantType<{
|
|
1371
|
-
/** Random forest (regressor, or classifier for a discrete treatment) */
|
|
1372
|
-
readonly random_forest: StructType<{
|
|
1373
|
-
/** Number of trees (default 100) */
|
|
1374
|
-
readonly n_estimators: OptionType<IntegerType>;
|
|
1375
|
-
/** Minimum samples per leaf (default 5) */
|
|
1376
|
-
readonly min_samples_leaf: OptionType<IntegerType>;
|
|
1377
|
-
/** Maximum tree depth (default unlimited) */
|
|
1378
|
-
readonly max_depth: OptionType<IntegerType>;
|
|
1379
|
-
}>;
|
|
1380
|
-
/** Gradient boosting (regressor, or classifier for a discrete treatment) */
|
|
1381
|
-
readonly gradient_boosting: StructType<{
|
|
1382
|
-
/** Number of boosting stages (default 100) */
|
|
1383
|
-
readonly n_estimators: OptionType<IntegerType>;
|
|
1384
|
-
/** Learning rate (default 0.1) */
|
|
1385
|
-
readonly learning_rate: OptionType<FloatType>;
|
|
1386
|
-
/** Maximum tree depth (default 3) */
|
|
1387
|
-
readonly max_depth: OptionType<IntegerType>;
|
|
1388
|
-
}>;
|
|
1389
|
-
/** Linear/logistic regression */
|
|
1390
|
-
readonly linear: NullType;
|
|
1414
|
+
readonly refutation: OptionType<StructType<{
|
|
1415
|
+
/** Effect under a permuted (placebo) treatment — should be ≈ 0. */
|
|
1416
|
+
readonly placebo_effect: OptionType<FloatType>;
|
|
1417
|
+
/** Whether the placebo effect vanished. */
|
|
1418
|
+
readonly placebo_passes: OptionType<BooleanType>;
|
|
1419
|
+
/** Whether a decoy random common cause left the estimate inside its CI. */
|
|
1420
|
+
readonly random_cc_within_ci: OptionType<BooleanType>;
|
|
1421
|
+
/** Mean effect across data subsamples (stability). */
|
|
1422
|
+
readonly data_subset_effect: OptionType<FloatType>;
|
|
1423
|
+
/** Std of the effect across data subsamples. */
|
|
1424
|
+
readonly data_subset_std: OptionType<FloatType>;
|
|
1425
|
+
/** Closed-form E-value — confounder strength needed to explain the effect away. */
|
|
1426
|
+
readonly robustness_value: OptionType<FloatType>;
|
|
1427
|
+
/** Unobserved-confounder sensitivity (tipping) curve: effect at each simulated strength. */
|
|
1428
|
+
readonly sensitivity: OptionType<StructType<{
|
|
1429
|
+
readonly strengths: VectorType<FloatType>;
|
|
1430
|
+
readonly effects: VectorType<FloatType>;
|
|
1431
|
+
}>>;
|
|
1391
1432
|
}>>;
|
|
1392
|
-
/**
|
|
1393
|
-
readonly
|
|
1394
|
-
|
|
1395
|
-
readonly
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
readonly max_depth: OptionType<IntegerType>;
|
|
1402
|
-
}>;
|
|
1403
|
-
/** Gradient boosting (regressor, or classifier for a discrete treatment) */
|
|
1404
|
-
readonly gradient_boosting: StructType<{
|
|
1405
|
-
/** Number of boosting stages (default 100) */
|
|
1406
|
-
readonly n_estimators: OptionType<IntegerType>;
|
|
1407
|
-
/** Learning rate (default 0.1) */
|
|
1408
|
-
readonly learning_rate: OptionType<FloatType>;
|
|
1409
|
-
/** Maximum tree depth (default 3) */
|
|
1410
|
-
readonly max_depth: OptionType<IntegerType>;
|
|
1411
|
-
}>;
|
|
1412
|
-
/** Linear/logistic regression */
|
|
1413
|
-
readonly linear: NullType;
|
|
1433
|
+
/** ALE dose-response of `dose_feature` (present when `config.dose_feature` is set). */
|
|
1434
|
+
readonly dose_response: OptionType<StructType<{
|
|
1435
|
+
readonly feature: StringType;
|
|
1436
|
+
readonly grid: VectorType<FloatType>;
|
|
1437
|
+
readonly effect: VectorType<FloatType>;
|
|
1438
|
+
readonly lower: OptionType<VectorType<FloatType>>;
|
|
1439
|
+
readonly upper: OptionType<VectorType<FloatType>>;
|
|
1440
|
+
/** Rows per dose bin — drives the surface's "you are here" (busiest bin) marker. */
|
|
1441
|
+
readonly size: VectorType<IntegerType>;
|
|
1414
1442
|
}>>;
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
/** Serialized estimator (cloudpickle) */
|
|
1427
|
-
readonly data: BlobType;
|
|
1428
|
-
/** Number of effect-modifier (X) features */
|
|
1429
|
-
readonly n_features_x: IntegerType;
|
|
1430
|
-
/** Confidence level used for effect/ATE intervals */
|
|
1431
|
-
readonly confidence_level: FloatType;
|
|
1443
|
+
readonly verdict: VariantType<{
|
|
1444
|
+
/** A real, robust, material effect. */
|
|
1445
|
+
readonly causal: NullType;
|
|
1446
|
+
/** A small but real effect, or no clear effect after adjustment. */
|
|
1447
|
+
readonly modest: NullType;
|
|
1448
|
+
/** Adjusted, but the estimate isn't trustworthy (placebo fails). */
|
|
1449
|
+
readonly adjustment_insufficient: NullType;
|
|
1450
|
+
/** No like-for-like comparison exists (positivity violated). */
|
|
1451
|
+
readonly non_identifiable_positivity: NullType;
|
|
1452
|
+
/** The estimand can't be formed (treatment barely varies). */
|
|
1453
|
+
readonly not_estimable: StringType;
|
|
1432
1454
|
}>;
|
|
1433
|
-
}
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
/**
|
|
1453
|
-
readonly
|
|
1454
|
-
/** Number of effect-modifier (X) features */
|
|
1455
|
-
readonly n_features_x: IntegerType;
|
|
1456
|
-
/** Confidence level used for effect/ATE intervals */
|
|
1457
|
-
readonly confidence_level: FloatType;
|
|
1455
|
+
}>, StructType<{
|
|
1456
|
+
/** Significance level (default 0.05). */
|
|
1457
|
+
readonly alpha: OptionType<FloatType>;
|
|
1458
|
+
/** Target chance of detecting the effect (default 0.8). */
|
|
1459
|
+
readonly target_power: OptionType<FloatType>;
|
|
1460
|
+
/** Smallest effect worth acting on — sizes the trial to this when set / when there's no trustworthy observed effect. */
|
|
1461
|
+
readonly materiality: OptionType<FloatType>;
|
|
1462
|
+
/** Treatment shares to offer as options (default [0.5]). */
|
|
1463
|
+
readonly treated_shares: OptionType<ArrayType<FloatType>>;
|
|
1464
|
+
}>], StructType<{
|
|
1465
|
+
readonly verdict: VariantType<{
|
|
1466
|
+
/** A real, robust, material effect. */
|
|
1467
|
+
readonly causal: NullType;
|
|
1468
|
+
/** A small but real effect, or no clear effect after adjustment. */
|
|
1469
|
+
readonly modest: NullType;
|
|
1470
|
+
/** Adjusted, but the estimate isn't trustworthy (placebo fails). */
|
|
1471
|
+
readonly adjustment_insufficient: NullType;
|
|
1472
|
+
/** No like-for-like comparison exists (positivity violated). */
|
|
1473
|
+
readonly non_identifiable_positivity: NullType;
|
|
1474
|
+
/** The estimand can't be formed (treatment barely varies). */
|
|
1475
|
+
readonly not_estimable: StringType;
|
|
1458
1476
|
}>;
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
* Causal.Types.CausalATEResultType,
|
|
1471
|
-
* ($, model, X) => $.return(Causal.dmlAte(model, X))
|
|
1472
|
-
* );
|
|
1473
|
-
* ```
|
|
1474
|
-
*/
|
|
1475
|
-
readonly dmlAte: import("@elaraai/east").PlatformDefinition<[VariantType<{
|
|
1476
|
-
/** Fitted EconML LinearDML estimator */
|
|
1477
|
-
readonly causal_dml: StructType<{
|
|
1478
|
-
/** Serialized estimator (cloudpickle) */
|
|
1479
|
-
readonly data: BlobType;
|
|
1480
|
-
/** Number of effect-modifier (X) features */
|
|
1481
|
-
readonly n_features_x: IntegerType;
|
|
1482
|
-
/** Confidence level used for effect/ATE intervals */
|
|
1483
|
-
readonly confidence_level: FloatType;
|
|
1477
|
+
readonly basis: VariantType<{
|
|
1478
|
+
/** Clear effect → power the trial to detect the observed effect. */
|
|
1479
|
+
readonly detect_observed: NullType;
|
|
1480
|
+
/** Fuzzy / maybe-nothing → power to the smallest effect worth acting on. */
|
|
1481
|
+
readonly resolve_vs_null: NullType;
|
|
1482
|
+
/** A trust check failed → randomise to remove the bias adjustment couldn't. */
|
|
1483
|
+
readonly de_bias: NullType;
|
|
1484
|
+
/** No overlap → randomise within the comparable range. */
|
|
1485
|
+
readonly restrict_to_overlap: NullType;
|
|
1486
|
+
/** No control group exists → hold back a random sample next time. */
|
|
1487
|
+
readonly create_control: NullType;
|
|
1484
1488
|
}>;
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
readonly
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
* Causal.Types.ALEResultType,
|
|
1504
|
-
* ($, data) => {
|
|
1505
|
-
* const config = $.let({
|
|
1506
|
-
* columns: ["dose", "z", "response"],
|
|
1507
|
-
* outcome: "response",
|
|
1508
|
-
* feature: "dose",
|
|
1509
|
-
* categorical: variant('none', null),
|
|
1510
|
-
* grid_size: variant('some', 10n),
|
|
1511
|
-
* include_ci: variant('some', true),
|
|
1512
|
-
* confidence_level: variant('some', 0.95),
|
|
1513
|
-
* emulator: variant('none', null),
|
|
1514
|
-
* random_state: variant('some', 42n),
|
|
1515
|
-
* }, CausalALEConfigType);
|
|
1516
|
-
* return $.return(Causal.ale(data, config));
|
|
1517
|
-
* }
|
|
1518
|
-
* );
|
|
1519
|
-
* ```
|
|
1520
|
-
*/
|
|
1521
|
-
readonly ale: import("@elaraai/east").PlatformDefinition<[MatrixType<FloatType>, StructType<{
|
|
1522
|
-
/** Column names for the data matrix (one per column, in order) */
|
|
1523
|
-
readonly columns: ArrayType<StringType>;
|
|
1524
|
-
/** Outcome column the emulator predicts */
|
|
1525
|
-
readonly outcome: StringType;
|
|
1526
|
-
/** Continuous feature column to compute the ALE curve for */
|
|
1527
|
-
readonly feature: StringType;
|
|
1528
|
-
/** Columns holding integer category codes, one-hot encoded internally */
|
|
1529
|
-
readonly categorical: OptionType<ArrayType<StringType>>;
|
|
1530
|
-
/** Number of grid intervals (default 10) */
|
|
1531
|
-
readonly grid_size: OptionType<IntegerType>;
|
|
1532
|
-
/** Include confidence intervals (default true) */
|
|
1533
|
-
readonly include_ci: OptionType<BooleanType>;
|
|
1534
|
-
/** Confidence level for the CI (default 0.95) */
|
|
1535
|
-
readonly confidence_level: OptionType<FloatType>;
|
|
1536
|
-
/** Emulator (HistGradientBoosting) hyperparameters */
|
|
1537
|
-
readonly emulator: OptionType<StructType<{
|
|
1538
|
-
/** Number of boosting iterations (default 300) */
|
|
1539
|
-
readonly n_estimators: OptionType<IntegerType>;
|
|
1540
|
-
/** Learning rate (default 0.05) */
|
|
1541
|
-
readonly learning_rate: OptionType<FloatType>;
|
|
1542
|
-
/** Maximum tree depth (default unlimited) */
|
|
1543
|
-
readonly max_depth: OptionType<IntegerType>;
|
|
1544
|
-
/** Minimum samples per leaf (default 20; lower for small datasets) */
|
|
1545
|
-
readonly min_samples_leaf: OptionType<IntegerType>;
|
|
1489
|
+
/** Effect size the trial is powered to detect (observed, or materiality). */
|
|
1490
|
+
readonly target_effect: FloatType;
|
|
1491
|
+
/** Outcome spread (pooled SD) used to size it. */
|
|
1492
|
+
readonly outcome_sd: FloatType;
|
|
1493
|
+
readonly target_power: FloatType;
|
|
1494
|
+
readonly alpha: FloatType;
|
|
1495
|
+
/** Chance the CURRENT sample would already detect `target_effect`; `none` when there's no comparison group. */
|
|
1496
|
+
readonly current_power: OptionType<FloatType>;
|
|
1497
|
+
/** Categories both groups must be matched on (most-imbalanced confounders). */
|
|
1498
|
+
readonly match_on: ArrayType<StringType>;
|
|
1499
|
+
/** Ranked split options (even split first; cost-saving alternates). */
|
|
1500
|
+
readonly options: ArrayType<StructType<{
|
|
1501
|
+
readonly label: StringType;
|
|
1502
|
+
/** Fraction assigned to the treatment (0..1; 0.5 = even). */
|
|
1503
|
+
readonly treated_share: FloatType;
|
|
1504
|
+
readonly n_treated: IntegerType;
|
|
1505
|
+
readonly n_control: IntegerType;
|
|
1506
|
+
readonly n_total: IntegerType;
|
|
1546
1507
|
}>>;
|
|
1547
|
-
/**
|
|
1548
|
-
readonly
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
/**
|
|
1553
|
-
readonly
|
|
1554
|
-
/** Lower CI at each grid value (present when include_ci) */
|
|
1555
|
-
readonly lower: OptionType<VectorType<FloatType>>;
|
|
1556
|
-
/** Upper CI at each grid value (present when include_ci) */
|
|
1557
|
-
readonly upper: OptionType<VectorType<FloatType>>;
|
|
1558
|
-
/** Number of samples in each grid interval */
|
|
1559
|
-
readonly size: VectorType<IntegerType>;
|
|
1508
|
+
/** The detect-chance curve for the chart. */
|
|
1509
|
+
readonly power_curve: StructType<{
|
|
1510
|
+
readonly n: VectorType<IntegerType>;
|
|
1511
|
+
readonly power: VectorType<FloatType>;
|
|
1512
|
+
}>;
|
|
1513
|
+
/** One generated, plain-language sentence framing the recipe. */
|
|
1514
|
+
readonly rationale: StringType;
|
|
1560
1515
|
}>>;
|
|
1561
1516
|
/** Type definitions */
|
|
1562
1517
|
readonly Types: {
|
|
@@ -1569,7 +1524,7 @@ export declare const Causal: {
|
|
|
1569
1524
|
readonly ips_normalized_weight: NullType;
|
|
1570
1525
|
}>;
|
|
1571
1526
|
readonly CausalEstimatorType: VariantType<{
|
|
1572
|
-
/** Linear regression of outcome on treatment + common causes */
|
|
1527
|
+
/** Linear regression of outcome on treatment + common causes (default) */
|
|
1573
1528
|
readonly linear_regression: NullType;
|
|
1574
1529
|
/** Inverse propensity score weighting (binary treatment only) */
|
|
1575
1530
|
readonly propensity_score_weighting: StructType<{
|
|
@@ -1592,39 +1547,40 @@ export declare const Causal: {
|
|
|
1592
1547
|
/** Average treatment effect on the controls */
|
|
1593
1548
|
readonly atc: NullType;
|
|
1594
1549
|
}>;
|
|
1595
|
-
readonly PropensityTrimType: VariantType<{
|
|
1596
|
-
/** Keep units inside the common-support overlap of treated and control propensities */
|
|
1597
|
-
readonly overlap: NullType;
|
|
1598
|
-
/** Keep units with propensity inside explicit bounds */
|
|
1599
|
-
readonly bounds: StructType<{
|
|
1600
|
-
/** Minimum propensity score to keep */
|
|
1601
|
-
readonly lower: FloatType;
|
|
1602
|
-
/** Maximum propensity score to keep */
|
|
1603
|
-
readonly upper: FloatType;
|
|
1604
|
-
}>;
|
|
1605
|
-
}>;
|
|
1606
1550
|
readonly CausalBootstrapConfigType: StructType<{
|
|
1607
|
-
/** Number of bootstrap replicates */
|
|
1551
|
+
/** Number of bootstrap replicates (default 200) */
|
|
1608
1552
|
readonly reps: IntegerType;
|
|
1609
1553
|
/** Column whose values identify clusters to resample (default: resample rows) */
|
|
1610
1554
|
readonly cluster_column: OptionType<StringType>;
|
|
1611
1555
|
/** Confidence level for the percentile interval (default 0.95) */
|
|
1612
1556
|
readonly confidence_level: OptionType<FloatType>;
|
|
1613
1557
|
}>;
|
|
1614
|
-
readonly
|
|
1615
|
-
|
|
1616
|
-
readonly
|
|
1617
|
-
|
|
1558
|
+
readonly CiType: StructType<{
|
|
1559
|
+
readonly lower: FloatType;
|
|
1560
|
+
readonly upper: FloatType;
|
|
1561
|
+
}>;
|
|
1562
|
+
readonly RefuteSpecType: StructType<{
|
|
1563
|
+
/** Permuted-treatment negative control — a real effect should vanish. */
|
|
1564
|
+
readonly placebo: BooleanType;
|
|
1565
|
+
/** Inject an independent random common cause — the effect should hold. */
|
|
1566
|
+
readonly random_common_cause: BooleanType;
|
|
1567
|
+
/** Re-estimate on random subsamples — the effect should be stable. */
|
|
1568
|
+
readonly data_subset: BooleanType;
|
|
1569
|
+
/** Unobserved-confounder strengths to simulate → the sensitivity / tipping curve. */
|
|
1570
|
+
readonly sensitivity: OptionType<ArrayType<FloatType>>;
|
|
1571
|
+
}>;
|
|
1572
|
+
readonly CausalExperimentConfigType: StructType<{
|
|
1573
|
+
/** Binary (0/1) treatment column. */
|
|
1618
1574
|
readonly treatment: StringType;
|
|
1619
|
-
/** Outcome column */
|
|
1575
|
+
/** Outcome column. */
|
|
1620
1576
|
readonly outcome: StringType;
|
|
1621
|
-
/**
|
|
1577
|
+
/** Confounders to adjust for (the backdoor set). */
|
|
1622
1578
|
readonly common_causes: ArrayType<StringType>;
|
|
1623
|
-
/**
|
|
1579
|
+
/** Confounder columns holding categories (string or int codes), one-hot encoded. */
|
|
1624
1580
|
readonly categorical: OptionType<ArrayType<StringType>>;
|
|
1625
|
-
/**
|
|
1581
|
+
/** Estimator (default: linear_regression). */
|
|
1626
1582
|
readonly method: OptionType<VariantType<{
|
|
1627
|
-
/** Linear regression of outcome on treatment + common causes */
|
|
1583
|
+
/** Linear regression of outcome on treatment + common causes (default) */
|
|
1628
1584
|
readonly linear_regression: NullType;
|
|
1629
1585
|
/** Inverse propensity score weighting (binary treatment only) */
|
|
1630
1586
|
readonly propensity_score_weighting: StructType<{
|
|
@@ -1639,8 +1595,8 @@ export declare const Causal: {
|
|
|
1639
1595
|
}>>;
|
|
1640
1596
|
}>;
|
|
1641
1597
|
}>>;
|
|
1642
|
-
/** Target population (default: ate) */
|
|
1643
|
-
readonly
|
|
1598
|
+
/** Target population (default: ate). */
|
|
1599
|
+
readonly estimand: OptionType<VariantType<{
|
|
1644
1600
|
/** Average treatment effect over all units */
|
|
1645
1601
|
readonly ate: NullType;
|
|
1646
1602
|
/** Average treatment effect on the treated */
|
|
@@ -1648,224 +1604,262 @@ export declare const Causal: {
|
|
|
1648
1604
|
/** Average treatment effect on the controls */
|
|
1649
1605
|
readonly atc: NullType;
|
|
1650
1606
|
}>>;
|
|
1651
|
-
/**
|
|
1652
|
-
readonly
|
|
1653
|
-
/**
|
|
1654
|
-
readonly
|
|
1655
|
-
/**
|
|
1656
|
-
readonly
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
}>;
|
|
1607
|
+
/** Which robustness checks to run. */
|
|
1608
|
+
readonly refute: OptionType<StructType<{
|
|
1609
|
+
/** Permuted-treatment negative control — a real effect should vanish. */
|
|
1610
|
+
readonly placebo: BooleanType;
|
|
1611
|
+
/** Inject an independent random common cause — the effect should hold. */
|
|
1612
|
+
readonly random_common_cause: BooleanType;
|
|
1613
|
+
/** Re-estimate on random subsamples — the effect should be stable. */
|
|
1614
|
+
readonly data_subset: BooleanType;
|
|
1615
|
+
/** Unobserved-confounder strengths to simulate → the sensitivity / tipping curve. */
|
|
1616
|
+
readonly sensitivity: OptionType<ArrayType<FloatType>>;
|
|
1662
1617
|
}>>;
|
|
1663
|
-
/**
|
|
1618
|
+
/** Continuous column for the ALE dose-response curve (the "How much?" view). */
|
|
1619
|
+
readonly dose_feature: OptionType<StringType>;
|
|
1620
|
+
/** Positivity guard — common-support fraction below this → non_identifiable_positivity (default 0.10). */
|
|
1621
|
+
readonly min_overlap: OptionType<FloatType>;
|
|
1622
|
+
/** Not-estimable guard — minority-arm fraction below this → not_estimable (default 0.02). */
|
|
1623
|
+
readonly min_treatment_variation: OptionType<FloatType>;
|
|
1624
|
+
/** Bootstrap CI config (default: 200 reps, 0.95). */
|
|
1664
1625
|
readonly bootstrap: OptionType<StructType<{
|
|
1665
|
-
/** Number of bootstrap replicates */
|
|
1626
|
+
/** Number of bootstrap replicates (default 200) */
|
|
1666
1627
|
readonly reps: IntegerType;
|
|
1667
1628
|
/** Column whose values identify clusters to resample (default: resample rows) */
|
|
1668
1629
|
readonly cluster_column: OptionType<StringType>;
|
|
1669
1630
|
/** Confidence level for the percentile interval (default 0.95) */
|
|
1670
1631
|
readonly confidence_level: OptionType<FloatType>;
|
|
1671
1632
|
}>>;
|
|
1672
|
-
/** Random seed
|
|
1633
|
+
/** Random seed. */
|
|
1673
1634
|
readonly random_state: OptionType<IntegerType>;
|
|
1674
1635
|
}>;
|
|
1675
|
-
readonly
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
readonly num_simulations: OptionType<IntegerType>;
|
|
1685
|
-
}>;
|
|
1686
|
-
/** Re-estimate on random data subsets - effect should be stable */
|
|
1687
|
-
readonly data_subset: StructType<{
|
|
1688
|
-
/** Fraction of rows kept per simulation (default 0.8) */
|
|
1689
|
-
readonly subset_fraction: OptionType<FloatType>;
|
|
1690
|
-
/** Number of simulations (default 100) */
|
|
1691
|
-
readonly num_simulations: OptionType<IntegerType>;
|
|
1692
|
-
}>;
|
|
1693
|
-
/**
|
|
1694
|
-
* Simulate an unobserved confounder at each given strength - a
|
|
1695
|
-
* sensitivity/tipping curve. Strength acts on both treatment
|
|
1696
|
-
* (flip probability for binary treatment, linear coefficient otherwise)
|
|
1697
|
-
* and outcome (linear coefficient).
|
|
1698
|
-
*/
|
|
1699
|
-
readonly unobserved_common_cause: StructType<{
|
|
1700
|
-
/** Confounder effect strengths to simulate, one new effect per entry */
|
|
1701
|
-
readonly effect_strengths: ArrayType<FloatType>;
|
|
1702
|
-
}>;
|
|
1636
|
+
readonly BalanceRowType: StructType<{
|
|
1637
|
+
readonly column: StringType;
|
|
1638
|
+
/** The original confounder this row belongs to — equals `column` for a numeric
|
|
1639
|
+
* confounder; the base confounder for a one-hot categorical level. */
|
|
1640
|
+
readonly base_column: StringType;
|
|
1641
|
+
readonly treated_mean: FloatType;
|
|
1642
|
+
readonly control_mean: FloatType;
|
|
1643
|
+
/** Standardized mean difference, (mt-mc)/sqrt((vt+vc)/2). */
|
|
1644
|
+
readonly std_diff: FloatType;
|
|
1703
1645
|
}>;
|
|
1704
|
-
readonly
|
|
1705
|
-
/**
|
|
1706
|
-
readonly
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
}>;
|
|
1714
|
-
/** Gradient boosting (regressor, or classifier for a discrete treatment) */
|
|
1715
|
-
readonly gradient_boosting: StructType<{
|
|
1716
|
-
/** Number of boosting stages (default 100) */
|
|
1717
|
-
readonly n_estimators: OptionType<IntegerType>;
|
|
1718
|
-
/** Learning rate (default 0.1) */
|
|
1719
|
-
readonly learning_rate: OptionType<FloatType>;
|
|
1720
|
-
/** Maximum tree depth (default 3) */
|
|
1721
|
-
readonly max_depth: OptionType<IntegerType>;
|
|
1722
|
-
}>;
|
|
1723
|
-
/** Linear/logistic regression */
|
|
1724
|
-
readonly linear: NullType;
|
|
1646
|
+
readonly OverlapDiagnosticType: StructType<{
|
|
1647
|
+
/** Propensity histogram (20 bins over [0,1]) for the treated arm. */
|
|
1648
|
+
readonly treated_propensity: VectorType<FloatType>;
|
|
1649
|
+
/** Propensity histogram for the control arm. */
|
|
1650
|
+
readonly control_propensity: VectorType<FloatType>;
|
|
1651
|
+
/** Fraction of rows inside the treated/control common support. */
|
|
1652
|
+
readonly common_support_frac: FloatType;
|
|
1653
|
+
/** Whether common support clears `min_overlap`. */
|
|
1654
|
+
readonly positivity_ok: BooleanType;
|
|
1725
1655
|
}>;
|
|
1726
|
-
readonly
|
|
1727
|
-
/**
|
|
1728
|
-
readonly
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
readonly learning_rate: OptionType<FloatType>;
|
|
1744
|
-
/** Maximum tree depth (default 3) */
|
|
1745
|
-
readonly max_depth: OptionType<IntegerType>;
|
|
1746
|
-
}>;
|
|
1747
|
-
/** Linear/logistic regression */
|
|
1748
|
-
readonly linear: NullType;
|
|
1656
|
+
readonly RefutationType: StructType<{
|
|
1657
|
+
/** Effect under a permuted (placebo) treatment — should be ≈ 0. */
|
|
1658
|
+
readonly placebo_effect: OptionType<FloatType>;
|
|
1659
|
+
/** Whether the placebo effect vanished. */
|
|
1660
|
+
readonly placebo_passes: OptionType<BooleanType>;
|
|
1661
|
+
/** Whether a decoy random common cause left the estimate inside its CI. */
|
|
1662
|
+
readonly random_cc_within_ci: OptionType<BooleanType>;
|
|
1663
|
+
/** Mean effect across data subsamples (stability). */
|
|
1664
|
+
readonly data_subset_effect: OptionType<FloatType>;
|
|
1665
|
+
/** Std of the effect across data subsamples. */
|
|
1666
|
+
readonly data_subset_std: OptionType<FloatType>;
|
|
1667
|
+
/** Closed-form E-value — confounder strength needed to explain the effect away. */
|
|
1668
|
+
readonly robustness_value: OptionType<FloatType>;
|
|
1669
|
+
/** Unobserved-confounder sensitivity (tipping) curve: effect at each simulated strength. */
|
|
1670
|
+
readonly sensitivity: OptionType<StructType<{
|
|
1671
|
+
readonly strengths: VectorType<FloatType>;
|
|
1672
|
+
readonly effects: VectorType<FloatType>;
|
|
1749
1673
|
}>>;
|
|
1750
|
-
/** Nuisance model for the treatment stage (default: random_forest) */
|
|
1751
|
-
readonly model_t: OptionType<VariantType<{
|
|
1752
|
-
/** Random forest (regressor, or classifier for a discrete treatment) */
|
|
1753
|
-
readonly random_forest: StructType<{
|
|
1754
|
-
/** Number of trees (default 100) */
|
|
1755
|
-
readonly n_estimators: OptionType<IntegerType>;
|
|
1756
|
-
/** Minimum samples per leaf (default 5) */
|
|
1757
|
-
readonly min_samples_leaf: OptionType<IntegerType>;
|
|
1758
|
-
/** Maximum tree depth (default unlimited) */
|
|
1759
|
-
readonly max_depth: OptionType<IntegerType>;
|
|
1760
|
-
}>;
|
|
1761
|
-
/** Gradient boosting (regressor, or classifier for a discrete treatment) */
|
|
1762
|
-
readonly gradient_boosting: StructType<{
|
|
1763
|
-
/** Number of boosting stages (default 100) */
|
|
1764
|
-
readonly n_estimators: OptionType<IntegerType>;
|
|
1765
|
-
/** Learning rate (default 0.1) */
|
|
1766
|
-
readonly learning_rate: OptionType<FloatType>;
|
|
1767
|
-
/** Maximum tree depth (default 3) */
|
|
1768
|
-
readonly max_depth: OptionType<IntegerType>;
|
|
1769
|
-
}>;
|
|
1770
|
-
/** Linear/logistic regression */
|
|
1771
|
-
readonly linear: NullType;
|
|
1772
|
-
}>>;
|
|
1773
|
-
/** Treat the treatment as discrete/categorical (default false) */
|
|
1774
|
-
readonly discrete_treatment: OptionType<BooleanType>;
|
|
1775
|
-
/** Cross-fitting folds (default 2) */
|
|
1776
|
-
readonly cv_folds: OptionType<IntegerType>;
|
|
1777
|
-
/** Confidence level for effect/ATE intervals (default 0.95) */
|
|
1778
|
-
readonly confidence_level: OptionType<FloatType>;
|
|
1779
|
-
/** Random seed */
|
|
1780
|
-
readonly random_state: OptionType<IntegerType>;
|
|
1781
1674
|
}>;
|
|
1782
|
-
readonly
|
|
1783
|
-
/** Column names for the data matrix (one per column, in order) */
|
|
1784
|
-
readonly columns: ArrayType<StringType>;
|
|
1785
|
-
/** Outcome column the emulator predicts */
|
|
1786
|
-
readonly outcome: StringType;
|
|
1787
|
-
/** Continuous feature column to compute the ALE curve for */
|
|
1675
|
+
readonly DoseResponseType: StructType<{
|
|
1788
1676
|
readonly feature: StringType;
|
|
1789
|
-
|
|
1790
|
-
readonly
|
|
1791
|
-
|
|
1792
|
-
readonly
|
|
1793
|
-
/**
|
|
1794
|
-
readonly
|
|
1795
|
-
/** Confidence level for the CI (default 0.95) */
|
|
1796
|
-
readonly confidence_level: OptionType<FloatType>;
|
|
1797
|
-
/** Emulator (HistGradientBoosting) hyperparameters */
|
|
1798
|
-
readonly emulator: OptionType<StructType<{
|
|
1799
|
-
/** Number of boosting iterations (default 300) */
|
|
1800
|
-
readonly n_estimators: OptionType<IntegerType>;
|
|
1801
|
-
/** Learning rate (default 0.05) */
|
|
1802
|
-
readonly learning_rate: OptionType<FloatType>;
|
|
1803
|
-
/** Maximum tree depth (default unlimited) */
|
|
1804
|
-
readonly max_depth: OptionType<IntegerType>;
|
|
1805
|
-
/** Minimum samples per leaf (default 20; lower for small datasets) */
|
|
1806
|
-
readonly min_samples_leaf: OptionType<IntegerType>;
|
|
1807
|
-
}>>;
|
|
1808
|
-
/** Random seed for the emulator */
|
|
1809
|
-
readonly random_state: OptionType<IntegerType>;
|
|
1677
|
+
readonly grid: VectorType<FloatType>;
|
|
1678
|
+
readonly effect: VectorType<FloatType>;
|
|
1679
|
+
readonly lower: OptionType<VectorType<FloatType>>;
|
|
1680
|
+
readonly upper: OptionType<VectorType<FloatType>>;
|
|
1681
|
+
/** Rows per dose bin — drives the surface's "you are here" (busiest bin) marker. */
|
|
1682
|
+
readonly size: VectorType<IntegerType>;
|
|
1810
1683
|
}>;
|
|
1811
|
-
readonly
|
|
1812
|
-
/**
|
|
1813
|
-
readonly
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1684
|
+
readonly ExperimentVerdictType: VariantType<{
|
|
1685
|
+
/** A real, robust, material effect. */
|
|
1686
|
+
readonly causal: NullType;
|
|
1687
|
+
/** A small but real effect, or no clear effect after adjustment. */
|
|
1688
|
+
readonly modest: NullType;
|
|
1689
|
+
/** Adjusted, but the estimate isn't trustworthy (placebo fails). */
|
|
1690
|
+
readonly adjustment_insufficient: NullType;
|
|
1691
|
+
/** No like-for-like comparison exists (positivity violated). */
|
|
1692
|
+
readonly non_identifiable_positivity: NullType;
|
|
1693
|
+
/** The estimand can't be formed (treatment barely varies). */
|
|
1694
|
+
readonly not_estimable: StringType;
|
|
1821
1695
|
}>;
|
|
1822
|
-
readonly
|
|
1823
|
-
/**
|
|
1824
|
-
readonly
|
|
1825
|
-
|
|
1826
|
-
readonly ci: OptionType<StructType<{
|
|
1827
|
-
/** Lower bound */
|
|
1696
|
+
readonly CausalExperimentResultType: StructType<{
|
|
1697
|
+
/** The raw (unadjusted) mean difference — always computable. */
|
|
1698
|
+
readonly naive: FloatType;
|
|
1699
|
+
readonly naive_ci: OptionType<StructType<{
|
|
1828
1700
|
readonly lower: FloatType;
|
|
1829
|
-
/** Upper bound */
|
|
1830
1701
|
readonly upper: FloatType;
|
|
1831
1702
|
}>>;
|
|
1832
|
-
/**
|
|
1833
|
-
readonly
|
|
1834
|
-
|
|
1703
|
+
/** The adjusted (like-for-like) effect + CI; `none` ⇒ the engine refused. */
|
|
1704
|
+
readonly adjusted: OptionType<StructType<{
|
|
1705
|
+
readonly effect: FloatType;
|
|
1706
|
+
readonly ci: OptionType<StructType<{
|
|
1707
|
+
readonly lower: FloatType;
|
|
1708
|
+
readonly upper: FloatType;
|
|
1709
|
+
}>>;
|
|
1710
|
+
}>>;
|
|
1711
|
+
readonly n_total: IntegerType;
|
|
1835
1712
|
readonly n_treated: IntegerType;
|
|
1836
|
-
/** Control rows used */
|
|
1837
1713
|
readonly n_control: IntegerType;
|
|
1714
|
+
readonly n_dropped: IntegerType;
|
|
1715
|
+
/** Per-confounder before-adjustment imbalance, most-imbalanced first. */
|
|
1716
|
+
readonly balance: ArrayType<StructType<{
|
|
1717
|
+
readonly column: StringType;
|
|
1718
|
+
/** The original confounder this row belongs to — equals `column` for a numeric
|
|
1719
|
+
* confounder; the base confounder for a one-hot categorical level. */
|
|
1720
|
+
readonly base_column: StringType;
|
|
1721
|
+
readonly treated_mean: FloatType;
|
|
1722
|
+
readonly control_mean: FloatType;
|
|
1723
|
+
/** Standardized mean difference, (mt-mc)/sqrt((vt+vc)/2). */
|
|
1724
|
+
readonly std_diff: FloatType;
|
|
1725
|
+
}>>;
|
|
1726
|
+
readonly overlap: StructType<{
|
|
1727
|
+
/** Propensity histogram (20 bins over [0,1]) for the treated arm. */
|
|
1728
|
+
readonly treated_propensity: VectorType<FloatType>;
|
|
1729
|
+
/** Propensity histogram for the control arm. */
|
|
1730
|
+
readonly control_propensity: VectorType<FloatType>;
|
|
1731
|
+
/** Fraction of rows inside the treated/control common support. */
|
|
1732
|
+
readonly common_support_frac: FloatType;
|
|
1733
|
+
/** Whether common support clears `min_overlap`. */
|
|
1734
|
+
readonly positivity_ok: BooleanType;
|
|
1735
|
+
}>;
|
|
1736
|
+
readonly refutation: OptionType<StructType<{
|
|
1737
|
+
/** Effect under a permuted (placebo) treatment — should be ≈ 0. */
|
|
1738
|
+
readonly placebo_effect: OptionType<FloatType>;
|
|
1739
|
+
/** Whether the placebo effect vanished. */
|
|
1740
|
+
readonly placebo_passes: OptionType<BooleanType>;
|
|
1741
|
+
/** Whether a decoy random common cause left the estimate inside its CI. */
|
|
1742
|
+
readonly random_cc_within_ci: OptionType<BooleanType>;
|
|
1743
|
+
/** Mean effect across data subsamples (stability). */
|
|
1744
|
+
readonly data_subset_effect: OptionType<FloatType>;
|
|
1745
|
+
/** Std of the effect across data subsamples. */
|
|
1746
|
+
readonly data_subset_std: OptionType<FloatType>;
|
|
1747
|
+
/** Closed-form E-value — confounder strength needed to explain the effect away. */
|
|
1748
|
+
readonly robustness_value: OptionType<FloatType>;
|
|
1749
|
+
/** Unobserved-confounder sensitivity (tipping) curve: effect at each simulated strength. */
|
|
1750
|
+
readonly sensitivity: OptionType<StructType<{
|
|
1751
|
+
readonly strengths: VectorType<FloatType>;
|
|
1752
|
+
readonly effects: VectorType<FloatType>;
|
|
1753
|
+
}>>;
|
|
1754
|
+
}>>;
|
|
1755
|
+
/** ALE dose-response of `dose_feature` (present when `config.dose_feature` is set). */
|
|
1756
|
+
readonly dose_response: OptionType<StructType<{
|
|
1757
|
+
readonly feature: StringType;
|
|
1758
|
+
readonly grid: VectorType<FloatType>;
|
|
1759
|
+
readonly effect: VectorType<FloatType>;
|
|
1760
|
+
readonly lower: OptionType<VectorType<FloatType>>;
|
|
1761
|
+
readonly upper: OptionType<VectorType<FloatType>>;
|
|
1762
|
+
/** Rows per dose bin — drives the surface's "you are here" (busiest bin) marker. */
|
|
1763
|
+
readonly size: VectorType<IntegerType>;
|
|
1764
|
+
}>>;
|
|
1765
|
+
readonly verdict: VariantType<{
|
|
1766
|
+
/** A real, robust, material effect. */
|
|
1767
|
+
readonly causal: NullType;
|
|
1768
|
+
/** A small but real effect, or no clear effect after adjustment. */
|
|
1769
|
+
readonly modest: NullType;
|
|
1770
|
+
/** Adjusted, but the estimate isn't trustworthy (placebo fails). */
|
|
1771
|
+
readonly adjustment_insufficient: NullType;
|
|
1772
|
+
/** No like-for-like comparison exists (positivity violated). */
|
|
1773
|
+
readonly non_identifiable_positivity: NullType;
|
|
1774
|
+
/** The estimand can't be formed (treatment barely varies). */
|
|
1775
|
+
readonly not_estimable: StringType;
|
|
1776
|
+
}>;
|
|
1838
1777
|
}>;
|
|
1839
|
-
readonly
|
|
1840
|
-
/**
|
|
1841
|
-
readonly
|
|
1842
|
-
/**
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1778
|
+
readonly DesignBasisType: VariantType<{
|
|
1779
|
+
/** Clear effect → power the trial to detect the observed effect. */
|
|
1780
|
+
readonly detect_observed: NullType;
|
|
1781
|
+
/** Fuzzy / maybe-nothing → power to the smallest effect worth acting on. */
|
|
1782
|
+
readonly resolve_vs_null: NullType;
|
|
1783
|
+
/** A trust check failed → randomise to remove the bias adjustment couldn't. */
|
|
1784
|
+
readonly de_bias: NullType;
|
|
1785
|
+
/** No overlap → randomise within the comparable range. */
|
|
1786
|
+
readonly restrict_to_overlap: NullType;
|
|
1787
|
+
/** No control group exists → hold back a random sample next time. */
|
|
1788
|
+
readonly create_control: NullType;
|
|
1849
1789
|
}>;
|
|
1850
|
-
readonly
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
readonly
|
|
1855
|
-
|
|
1856
|
-
readonly
|
|
1790
|
+
readonly TrialOptionType: StructType<{
|
|
1791
|
+
readonly label: StringType;
|
|
1792
|
+
/** Fraction assigned to the treatment (0..1; 0.5 = even). */
|
|
1793
|
+
readonly treated_share: FloatType;
|
|
1794
|
+
readonly n_treated: IntegerType;
|
|
1795
|
+
readonly n_control: IntegerType;
|
|
1796
|
+
readonly n_total: IntegerType;
|
|
1857
1797
|
}>;
|
|
1858
|
-
readonly
|
|
1859
|
-
|
|
1860
|
-
readonly
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1798
|
+
readonly PowerCurveType: StructType<{
|
|
1799
|
+
readonly n: VectorType<IntegerType>;
|
|
1800
|
+
readonly power: VectorType<FloatType>;
|
|
1801
|
+
}>;
|
|
1802
|
+
readonly ExperimentDesignType: StructType<{
|
|
1803
|
+
readonly verdict: VariantType<{
|
|
1804
|
+
/** A real, robust, material effect. */
|
|
1805
|
+
readonly causal: NullType;
|
|
1806
|
+
/** A small but real effect, or no clear effect after adjustment. */
|
|
1807
|
+
readonly modest: NullType;
|
|
1808
|
+
/** Adjusted, but the estimate isn't trustworthy (placebo fails). */
|
|
1809
|
+
readonly adjustment_insufficient: NullType;
|
|
1810
|
+
/** No like-for-like comparison exists (positivity violated). */
|
|
1811
|
+
readonly non_identifiable_positivity: NullType;
|
|
1812
|
+
/** The estimand can't be formed (treatment barely varies). */
|
|
1813
|
+
readonly not_estimable: StringType;
|
|
1814
|
+
}>;
|
|
1815
|
+
readonly basis: VariantType<{
|
|
1816
|
+
/** Clear effect → power the trial to detect the observed effect. */
|
|
1817
|
+
readonly detect_observed: NullType;
|
|
1818
|
+
/** Fuzzy / maybe-nothing → power to the smallest effect worth acting on. */
|
|
1819
|
+
readonly resolve_vs_null: NullType;
|
|
1820
|
+
/** A trust check failed → randomise to remove the bias adjustment couldn't. */
|
|
1821
|
+
readonly de_bias: NullType;
|
|
1822
|
+
/** No overlap → randomise within the comparable range. */
|
|
1823
|
+
readonly restrict_to_overlap: NullType;
|
|
1824
|
+
/** No control group exists → hold back a random sample next time. */
|
|
1825
|
+
readonly create_control: NullType;
|
|
1826
|
+
}>;
|
|
1827
|
+
/** Effect size the trial is powered to detect (observed, or materiality). */
|
|
1828
|
+
readonly target_effect: FloatType;
|
|
1829
|
+
/** Outcome spread (pooled SD) used to size it. */
|
|
1830
|
+
readonly outcome_sd: FloatType;
|
|
1831
|
+
readonly target_power: FloatType;
|
|
1832
|
+
readonly alpha: FloatType;
|
|
1833
|
+
/** Chance the CURRENT sample would already detect `target_effect`; `none` when there's no comparison group. */
|
|
1834
|
+
readonly current_power: OptionType<FloatType>;
|
|
1835
|
+
/** Categories both groups must be matched on (most-imbalanced confounders). */
|
|
1836
|
+
readonly match_on: ArrayType<StringType>;
|
|
1837
|
+
/** Ranked split options (even split first; cost-saving alternates). */
|
|
1838
|
+
readonly options: ArrayType<StructType<{
|
|
1839
|
+
readonly label: StringType;
|
|
1840
|
+
/** Fraction assigned to the treatment (0..1; 0.5 = even). */
|
|
1841
|
+
readonly treated_share: FloatType;
|
|
1842
|
+
readonly n_treated: IntegerType;
|
|
1843
|
+
readonly n_control: IntegerType;
|
|
1844
|
+
readonly n_total: IntegerType;
|
|
1845
|
+
}>>;
|
|
1846
|
+
/** The detect-chance curve for the chart. */
|
|
1847
|
+
readonly power_curve: StructType<{
|
|
1848
|
+
readonly n: VectorType<IntegerType>;
|
|
1849
|
+
readonly power: VectorType<FloatType>;
|
|
1850
|
+
}>;
|
|
1851
|
+
/** One generated, plain-language sentence framing the recipe. */
|
|
1852
|
+
readonly rationale: StringType;
|
|
1853
|
+
}>;
|
|
1854
|
+
readonly DesignConfigType: StructType<{
|
|
1855
|
+
/** Significance level (default 0.05). */
|
|
1856
|
+
readonly alpha: OptionType<FloatType>;
|
|
1857
|
+
/** Target chance of detecting the effect (default 0.8). */
|
|
1858
|
+
readonly target_power: OptionType<FloatType>;
|
|
1859
|
+
/** Smallest effect worth acting on — sizes the trial to this when set / when there's no trustworthy observed effect. */
|
|
1860
|
+
readonly materiality: OptionType<FloatType>;
|
|
1861
|
+
/** Treatment shares to offer as options (default [0.5]). */
|
|
1862
|
+
readonly treated_shares: OptionType<ArrayType<FloatType>>;
|
|
1869
1863
|
}>;
|
|
1870
1864
|
};
|
|
1871
1865
|
};
|