cleverly.ParametricGFormulaMethod#
- class cleverly.ParametricGFormulaMethod(models: ModelSpec = ModelSpec(outcome_learner=None, treatment_learner=None, missingness_learner=None, intermediate_learner=None, pseudo_learner=None, censoring_learner=None, density_bins=None, ratio='density', screen_treatment=False, screen_threshold=0.1, min_retain=None, outcome_by_arm=False, survival_model='iterated_mean'), cross_fitting: CrossFitting = CrossFitting(enabled=False, n_folds=10, learner_folds=5, repeats=1, stratify_by='none', targeting_scheme='pooled', fold_evaluation=False, split_plan=None), targeting: Targeting = Targeting(fluctuation='logistic', algorithm='iterative', g_bounds='auto', q_bounds=None, nuisance_bound=0.01, submodel_alpha=0.9995, target_weights=False, step_size=0.001, max_iter=20, tol=1e-10, stopping='relative', step_bound=None, step_search=True, iterate='last', isotonic=False), inference: Inference = Inference(alpha=0.05, n_bootstrap=0, bootstrap_resampling='auto', simultaneous=True, n_multiplier='auto', multiplier_kind='rademacher'), runtime: Runtime = Runtime(random_state=None, run_id=None, n_jobs=1), name: str = 'parametric_gformula', n_draws: int = 10, n_derivative_draws: int | None = None, covariate_types: Any = None, covariate_learner: Any = None, hazard_learner: Any = None)[source]#
Configure the parametric g-formula of a longitudinal regimen.
Forward simulation of fitted covariate, outcome and hazard laws (Robins 1986; McGrath et al. 2020), fitted by
cleverly.longitudinal.ParametricGFormula. The method fits in sample, socross_fittingdefaults toCrossFitting(enabled=False), and above one fold the engine refuses. It fits no fluctuation, so the fluctuation settings ofTargetingstay at their defaults. A point-treatment functional and a working model over regimens refuse the method.- Parameters:
- models
ModelSpec Nuisance learners.
outcome_learnerfits the outcome model, andtreatment_learnerfits the natural-treatment models.pseudo_learneris refused.- cross_fitting
CrossFitting Sample-splitting settings. The default is in sample, and the engine refuses more than one fold.
- targeting
Targeting g_boundsandq_bounds.g_boundsmoves the positivity diagnostics only.- inference
Inference Interval and resampling settings.
- runtime
Runtime Seed, run identifier, and parallelism.
- name
str Stable method name.
- n_draws
int The simulated histories per unit behind the estimate.
- n_derivative_draws
intorNone The simulated histories per unit behind the derivatives.
Nonetakes the larger ofn_drawsand ten.- covariate_types
mappingorNone The type of each time-varying column at nodes
2..T.- covariate_learner
estimatororNone The template of every covariate model.
Noneis a main-terms GLM.- hazard_learner
estimatororNone The template of every hazard model of a survival outcome.
Noneis a GLM.
- models
See also
GComputationMethodThe iterated conditional expectation form of the same parameter.
cleverly.longitudinal.ParametricGFormulaThe engine this configuration is translated for.
cleverly.LongitudinalTreatmentThe design whose functionals take this method.
Examples
>>> from cleverly import ParametricGFormulaMethod >>> method = ParametricGFormulaMethod(n_draws=20) >>> method.name, method.cross_fitting.enabled ('parametric_gformula', False) >>> kwargs = method.estimator_kwargs(longitudinal=True) >>> kwargs["n_draws"], kwargs["n_folds"], "alpha" in kwargs (20, 1, False)
Methods#
- ParametricGFormulaMethod.estimator_kwargs(*, longitudinal: bool = False) dict[str, Any][source]#
Translate this configuration for the longitudinal g-formula engine.
- Parameters:
- longitudinalbool
Must be true, because the estimator is longitudinal.
- Returns:
- Raises:
MethodConfigurationErrorWhen
longitudinalis false, or when a fluctuation setting differs from its default.