cleverly.sensitivity.MissingnessTilt#
- class cleverly.sensitivity.MissingnessTilt(rows: tuple[tuple[str, tuple[Any, ...]], ...], backend: str | None, outcome: str = '', n_missing: int = 0, n: int = 0, arm_gamma: tuple[tuple[Any, float], ...] | None = None, level: float = 0.95, statuses: tuple[tuple[str, str], ...] = (), ratios: tuple[str, ...] = (), scales: tuple[tuple[str, str], ...] = (), readings: tuple[tuple[str, Resolution], ...] = ())[source]#
Estimates under departures from outcomes missing at random.
Returned by
missingness_tilt().to_frame()gives one row per(gamma, estimand), with the spread columns the estimate’s inference status names and onegamma[<level>]column per arm.- Parameters:
- rows
tuple The frame’s columns, as
(name, values)pairs.- backend
strorNone The dataframe backend
to_frame()emits.- outcome
str The outcome column.
- n_missing
int Rows whose outcome is missing.
- n
int Rows in the fit.
- arm_gamma
tupleoftupleorNone The declared
(arm, multiplier)pairs, orNonewhen every arm is tilted alike.- level
float The coverage level of the intervals.
- statuses
tupleoftupleofstr Each estimand’s inference status, as
(estimand, status)pairs.- ratios
tupleofstr The estimands on a ratio scale, whose spread is on the log scale.
- scales
tupleoftupleofstr Each estimand’s scale (
"difference","ratio","level"or"fraction"), as(estimand, scale)pairs, which sets its no-effect value.- readings
tupleoftuple For each estimand whose interval off
gamma = 0comes from the targeted tilt, the registry’s reading of that interval, as(estimand, Resolution)pairs.
- rows
- Attributes:
descriptivetupleofstrThe estimands whose interval off
gamma = 0no validation study licenses.
Methods#
- classmethod MissingnessTilt.build(payload: Mapping[str, Sequence[Any]], *, backend: str | None, outcome: str, n_missing: int, n: int, arm_gamma: tuple[tuple[Any, float], ...] | None, level: float, statuses: tuple[tuple[str, str], ...], ratios: tuple[str, ...] = (), scales: tuple[tuple[str, str], ...] = (), readings: tuple[tuple[str, Resolution], ...] = ()) MissingnessTilt[source]#
Build the tilt from its columns and the fit facts its summary prints.
- Parameters:
- payload
mappingofstrtosequence The frame’s columns.
- backend
strorNone The backend
to_frame()emits.- outcome
str The outcome column.
- n_missing
int Rows whose outcome is missing.
- n
int Rows in the fit.
- arm_gamma
tupleoftupleorNone The declared
(arm, multiplier)pairs, orNone.- level
float The coverage level of the intervals.
- statuses
tupleoftupleofstr Each estimand’s inference status.
- ratios
tupleofstr The estimands on a ratio scale.
- scales
tupleoftupleofstr Each estimand’s scale, as
(estimand, scale)pairs.- readings
tupleoftuple The registry’s reading of each targeted interval off
gamma = 0.
- payload
- Returns:
MissingnessTiltThe tilt.
- MissingnessTilt.plot(**kwargs: Any) Any[source]#
Plot one estimate against the tilt γ, with its interval where one is reported.
- Parameters:
- **kwargs
Passed to
cleverly.plotting.sensitivity():estimand=,outcome_label=,units=andtitle=.
- Returns:
FigureOne panel over the grid of γ.
Examples
>>> import matplotlib >>> matplotlib.use("Agg") >>> import matplotlib.pyplot as plt >>> from sklearn.linear_model import LinearRegression, LogisticRegression >>> from cleverly import ATE, CausalStudy, PointTreatment >>> from cleverly.datasets import make_missing_outcome >>> frame, _ = make_missing_outcome(n=300, seed=61) >>> design = PointTreatment( ... outcome="Y", treatment="A", adjustment=["W1", "W2", "W3"], missingness="Delta" ... ) >>> result = CausalStudy(frame, design=design).identify(ATE()).estimate( ... outcome_learner=LinearRegression(), ... treatment_learner=LogisticRegression(max_iter=1000), ... cross_fit=False, ... random_state=4, ... ) >>> fig = result.sensitivity.missingness(gamma=[-1.0, 0.0, 1.0]).plot() >>> fig.axes[0].get_ylabel() 'Average effect' >>> plt.close(fig)
Attributes#
- MissingnessTilt.descriptive#
The estimands whose interval off
gamma = 0no validation study licenses.
- MissingnessTilt.estimands#
The estimands the tilt reports, in order.
- MissingnessTilt.rows#
- MissingnessTilt.backend#