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