cleverly.LongPanel#
- class cleverly.LongPanel(unit: str, time: str, treatment: str | Sequence[str], baseline: Sequence[str], time_varying: Sequence[str] = (), censoring: str | None = None, outcome: str | None = None, event: str | Mapping[str, str] | None = None, times: Sequence[Any] | None = None, cluster: str | None = None, weights: str | None = None, weights_type: Literal['probability'] = 'probability', weights_estimated: bool = False, outcome_family: Literal['gaussian', 'binomial', 'auto'] = 'auto', continuous_treatment: bool = False, treatment_probabilities: Mapping[Any, str] | None = None, censoring_probabilities: str | None = None, treatment_support: Any = None, dose_atoms: Sequence[float] = ())[source]#
Declare a longitudinal study read from a long panel: one row per unit and time.
Each row holds the covariates measured before that row’s decision, the decision, and whether the unit is still observed after it.
cleverly.longitudinal.LongitudinalData.from_long_panel()states the layout, the generated column names and the refusals. The estimands are those ofLongitudinalTreatment, and one unit’s rows are one observation.- Parameters:
- unit
str The unit identifier column.
- time
str The decision-time column.
- treatment
stror sequenceofstr The decision at each row. A list of columns is one vector node per time.
- baselinesequence
ofstr Unit-level covariates measured before the first decision. The list names at least one column.
- time_varyingsequence
ofstr Covariates measured at each row before that row’s decision.
- censoring
strorNone 1where the unit is still observed after the row’s decision.- outcome
strorNone An end-of-study outcome, one value per unit.
- event
strormappingofstrtostrorNone A survival event indicator on each row, or one column per competing cause. Declare exactly one of
outcomeandevent.- timessequence or
None Every decision time, in time order.
Noneuses the times the panel holds, sorted, and needs numbers, dates or durations.- cluster
strorNone Independent-cluster identifier, constant within a unit.
- weights
strorNone Unit-level probability-weight column.
- weights_type{“probability”}
Interpretation of
weights.- weights_estimatedbool
Whether the supplied weights were estimated from these data.
- outcome_family{“auto”, “gaussian”, “binomial”}
Outcome family used by the sequential regressions.
- continuous_treatmentbool
Whether the treatment holds a continuous dose at every node.
- treatment_support
SupportorNone The declared conditional support of the dose at every node.
- dose_atomssequence
offloat The doses with a recorded point mass at every node.
- treatment_probabilities
mappingofleveltostr,orNone The known treatment mechanism: each level mapped to the column that holds
P(A_t = level | past)on each row. A tuple of(level, column)pairs, the form the design stores, is also accepted.- censoring_probabilities
strorNone The column that holds
P(C_t = 1 | past)on each row.
- unit
See also
LongitudinalTreatmentThe same declaration on a wide frame.
CausalStudyWhat a design is handed to along with the data.
cleverly.longitudinal.LongitudinalData.from_long_panelThe container it builds.
Examples
>>> from cleverly import LongPanel >>> design = LongPanel( ... unit="customer", ... time="week", ... treatment="offer", ... baseline=["age"], ... time_varying=["engagement"], ... censoring="active", ... outcome="bought", ... ) >>> design.time_varying ('engagement',)
Methods#
Attributes#
- LongPanel.outcome_role#
The outcome the identified functional names: the outcome or the event columns.