causallib.survival.base_survival module

class causallib.survival.base_survival.SurvivalBase[source]

Bases: abc.ABC

Interface class for causal survival analysis with fixed baseline covariates.

abstract estimate_population_outcome(**kwargs) pandas.core.frame.DataFrame[source]

Returns population averaged survival curves.

Returns

with time-step index, treatment values as columns and survival as entries

Return type

pd.DataFrame

abstract fit(X: pandas.core.frame.DataFrame, a: pandas.core.series.Series, t: pandas.core.series.Series, y: pandas.core.series.Series)[source]

Fits internal learner(s).

Parameters
  • X (pd.DataFrame) – Baseline covariate matrix of size (num_subjects, num_features).

  • a (pd.Series) – Treatment assignment of size (num_subjects,).

  • t (pd.Series) – Followup duration, size (num_subjects,).

  • y (pd.Series) – Observed outcome (1) or right censoring event (0), size (num_subjects,).

Returns

self

class causallib.survival.base_survival.SurvivalTimeVaryingBase[source]

Bases: causallib.survival.base_survival.SurvivalBase

Interface class for causal survival analysis estimators that support time-varying followup covariates. Followup covariates matrix (XF) needs to have a ‘time’ column, and indexed by subject IDs that correspond to the other inputs (X, a, y, t). All columns other than ‘time’ will be used for time-varying adjustments.

Example XF format: +—-+——+——+——+ | id | t | var1 | var2 | +—-+——+——+——+ | 1 | 0 | 1.4 | 22 | | 1 | 4 | 1.2 | 22 | | 1 | 8 | 1.5 | NaN | | 2 | 0 | 1.6 | 10 | | 2 | 11 | 1.6 | 11 | +—-+——+——+——+

abstract fit(X: pandas.core.frame.DataFrame, a: pandas.core.series.Series, t: pandas.core.series.Series, y: pandas.core.series.Series, XF: Optional[pandas.core.frame.DataFrame] = None) None[source]

Fits internal survival functions.

Parameters
  • X (pd.DataFrame) – Baseline covariate matrix of size (num_subjects, num_features).

  • a (pd.Series) – Treatment assignment of size (num_subjects,).

  • t (pd.Series) – Followup duration, size (num_subjects,).

  • y (pd.Series) – Observed outcome (1) or right censoring event (0), size (num_subjects,).

  • XF (pd.DataFrame) – Time-varying followup covariate matrix

Returns

A fitted estimator with precalculated survival functions.