cleverly.longitudinal.snmm#
- cleverly.longitudinal.snmm(data: Any, *, outcome: str, treatment: Sequence[str], baseline: Sequence[str], regimens: Any = None, time_varying: Sequence[Sequence[str]] | None = None, censoring: Sequence[str] | None = None, id: str | None = None, weights: str | None = None, weights_type: str = 'probability', weights_estimated: bool = False, family: str = 'auto', continuous_treatment: Sequence[str] = (), **kwargs: Any) StructuralNestedMeanResult[source]#
One-call structural nested mean model, mirroring
cleverly.longitudinal.ltmle().- Parameters:
- data
DataFrameorLongitudinalData One wide frame, or a container that has already read the columns.
- outcome
str The end-of-study outcome column.
- treatmentsequence
ofstr The treatment column of each node, in time order.
- baselinesequence
ofstr The covariates measured before any treatment.
- regimens
mapping, sequence,orNone Static regimens, as for
StructuralNestedMean.- time_varyingsequence
ofsequenceofstrorNone The covariates measured before the treatment of each node.
- censoringsequence
ofstrorNone Refused when it names a column.
- id
strorNone A cluster column.
- weights
strorNone A column of known observation weights.
- weights_type
str How to read
weights.- weights_estimatedbool
Declare that the weights came out of a fitted model.
- family{“auto”, “binomial”, “gaussian”}
The outcome family.
- continuous_treatmentsequence
ofstr The treatment columns that hold a dose.
- **kwargs
Any The remaining
StructuralNestedMeansettings.
- data
- Returns:
StructuralNestedMeanResultThe blips, the reference mean, and the declared regimen means and contrasts.
See also
StructuralNestedMeanThe estimator class and its settings.
Examples
>>> from cleverly.datasets import make_longitudinal >>> from cleverly.learners import GLM >>> from cleverly.longitudinal import snmm >>> frame, _ = make_longitudinal(n=300, seed=0, censoring=False) >>> result = snmm( ... frame, ... outcome="Y", ... treatment=["A1", "A2"], ... baseline=["W1", "W2"], ... time_varying=[[], ["L2"]], ... outcome_learner=GLM(family="binomial"), ... treatment_learner=GLM(family="binomial"), ... n_folds=2, ... random_state=0, ... ) >>> "ey_reference" in result True