Read cleverly’s output#
Every tutorial prints the same three kinds of output: the study description, the summary of the causal question, and the summary of an estimate. Results, inference, and assessment covers the estimate summary and its checks in more depth.
The study description#
A study description writes down the study you would run if you could assign the treatment
yourself: who is in it, when follow-up starts, what is compared, and what is measured. cleverly
stores it as a StudyProtocol and prints one line for each field. You write every field in your
own words; cleverly records them with the result and does not check them against the data.
from cleverly import StudyProtocol
protocol = StudyProtocol(
target_population="Adults discharged home from a participating hospital",
eligibility=["Age 18 or older", "Discharged alive"],
time_zero="Hospital discharge, before the navigation offer",
treatment_strategies=["Offer navigation", "Usual discharge support"],
treatment_versions=["Two navigator calls within 30 days", "No navigator calls"],
outcome="Readmission within 30 days",
horizon="30 days after discharge",
intercurrent_event_handling=["Treat death before readmission as a competing event"],
interference_unit="Individual patient",
assumption_rationale=["The recorded baseline variables cover the common causes"],
)
print("\n".join(protocol.summary_lines()))
print(protocol.fingerprint)
printed label |
what it records |
|---|---|
Population |
the people the answer applies to |
Eligibility |
who enters the study |
Follow-up starts |
time zero: the moment that lines up eligibility, the treatment decision and the start of follow-up. Only information recorded before it should be adjusted for, that is, used to compare like with like |
Strategies |
the treatment plans compared, such as offering a program or not |
Versions |
what each plan delivers in practice, in the same order as the plans |
Outcome and Horizon |
what is measured, and by when |
Intercurrent events |
what to do about events after time zero that change what the outcome means, such as death before readmission or leaving the health plan (see below) |
Interference unit |
the unit within which one person’s treatment may change another’s outcome. “Individual patient” says that no patient’s treatment affects another patient |
Rationale |
why you believe the conditions for a causal answer, listed under “The causal question” below, hold in this study |
The fingerprint is a short code computed from every field. Each result keeps the fingerprint of
the description it was fitted under. Different fingerprints mean the descriptions differ in at least
one field, even a reworded rationale, so compare the printed fields before you compare the numbers.
Intercurrent events#
An intercurrent event happens after time zero and changes what the outcome means. Each way of handling one asks a different question, and a tutorial names the composite or hypothetical strategy in parentheses where it uses one.
strategy |
what it does |
example |
|---|---|---|
treatment policy |
use the outcome whatever happened in between |
analyze the offer regardless of how many contacts the patient completed |
composite |
fold the event into the outcome |
score death before day 30 as the worst transition score |
competing event |
report each event as it happens in the real world, with the other events left as they are |
readmission and death, where a patient who dies can no longer be readmitted |
hypothetical |
ask what would have happened had the event not occurred |
the readmission risk had every patient stayed enrolled, or had death been prevented |
A hypothetical strategy needs extra conditions, because the data never show the world it
describes: whether the event happens must depend only on what was recorded before it, and every
kind of person must have had a real chance of avoiding it. cleverly cannot check either one.
Censoring columns on the design already ask the “had everyone stayed in follow-up” question, and
eliminate= on the design, such as TimeToEvent(..., eliminate=["death"]), asks “had death been
prevented”. Time-to-event outcomes shows how to ask each of
the event questions.
The causal question#
study.identify(question) checks that the design can pose the question and prints a summary before
any model is fitted; whether the answer is causal still rests on the conditions it lists. The heading names the question with a short code in brackets, such as
Causal question (ate) for an average effect or (ey_regime) for the mean outcome under each
treatment plan over time.
part |
what to read |
|---|---|
Question, Outcome, Treatment, Adjusted for (Baseline over time) |
the question in words and the role of each column. Check that every adjusted-for column was recorded before the treatment |
Answered by |
how the data answer the question. “adjusting for covariates” means comparing people with the same recorded characteristics; “adjusting for history” does the same at each treatment time, using everything recorded up to then; “randomized assignment” uses the recorded chances of a randomized treatment |
What each treatment time adjusts for |
for a treatment given more than once, the columns each decision is compared within |
Conditions the answer rests on |
each condition in plain words, and in the |
Methods |
the estimators that can fit this question, by the name you pass as |
The methods table lists the methods that fit the question, and a note says how many others cannot;
summary(detail="full") gives each reason. The tutorials use tmle, targeted maximum likelihood
estimation. It fits a model of the outcome and a model of who got the treatment, then corrects the
outcome model’s estimate with the treatment model. Its interval is valid when both models
predict well, and its estimate stays unbiased in large samples if either model is right. Start
with tmle. The others answer special situations, such as a treatment model that a strong
predictor makes extreme (collaborative_tmle); the
examples index matches each situation to
its method.
The estimate#
An estimate summary has a header that repeats the question and the fitted models, a table of estimates, a table that says what each row estimates, and numbered warnings and notes. Each row’s name reads as follows.
ate_regimen[always vs never, readmission @ t=2]
| | | | |
| | plans compared cause time point
| kind of plan
what is estimated
part |
values you will meet |
|---|---|
what is estimated |
|
kind of plan |
none for one treatment given once at fixed levels, such as |
inside the brackets |
the plan or plans, named as in your code; a cause when several events compete; and |
The “What each row estimates” table under the estimates spells out every row name in words, such
as “probability of readmission by time 2 if every unit followed plan always”. Read that table
whenever a name in your output is unfamiliar. A TimeToEvent result also reports the actual grid
time in the time column of curve() and to_frame().
Labels, warnings and notes#
A support column appears when an estimate is experimental, and a note below the table says
why. supported means a registered simulation study covers this configuration, such as the same
method, design and kind of plan, and its checks passed. experimental means no study covers it,
or a stated condition applies, such as too few clusters; the interval then has no checked
coverage. The label does not say the estimate is wrong.
The word “licenses” in a warning means “covers”. For example, the E-value says how strongly a missing confounder would need to be tied to both the treatment and the outcome to explain the effect away, and its “limit” version does the same for the end of the confidence interval nearer no effect. “No validation study licenses the E-value of the limit” means no study covers that number. You can still report it, with a plain caveat such as “this E-value describes this sample; no simulation study has checked it for this kind of analysis”. Read the support label lists where the label appears and what each reason means.
Other notes appear only when something changes how to read a number: for example, that a model was
fitted and scored on the same rows, that a cap on extreme weights (the inverse chances of treatment that the correction step uses) changed
some people’s weights, or that an
estimate’s interval leans on few rows (SparseInfluenceWarning).