Applied Health Economics, RWE & HTA
Overview / Module 3 / Day 29
Module 3 · Causal inference for RWE · Day 29 of 100

RWE Standards: Protocols, Reporting and Data Fitness

The best analysis is worth little if a reviewer cannot see what was done, why, and whether it was decided before the results were known. Canada has its own reporting standard for real-world evidence, written by CDA-AMC with Health Canada and INESSS. Today you map your Module 3 work onto it, write the protocol in the internationally harmonized HARPER structure, assess whether the data are fit for purpose, draw the design diagram reviewers expect, and see in numbers why pre-specification matters.

▶
Video for Day 29 coming soon

By the end of today you can

  • name the 12 sections of the CDA-AMC Guidance for Reporting Real-World Evidence
  • write protocols in HARPER order with a design diagram, and register them before analysis
  • assess data fitness: completeness and timeliness of the variables the question depends on
  • log every protocol deviation, with its date, reason, and whether results had been seen
  • report the range of defensible analyses, not the most favourable one

Today's 5.5-hour plan

LessonProjectBreakCommitFrançais
0:00–0:45
29.1 The standards: CDA-AMC, HARPER, RECORD-PE
0:45–1:25
29.2 Is the data fit for purpose?
1:25–1:40
Break
1:40–2:10
29.3 The design diagram
2:10–2:50
29.4 Twenty-four defensible analyses
2:50–3:05
Break
3:05–3:35
29.5 Truth check
3:35–3:55
29.6 Checking a protocol against the guidance
3:55–4:50
29.7 Mini-project: the Module 3 protocol
4:50–5:00
29.8 Save your work
5:00–5:30
Bloc français

In this lesson

29.1 The standards: CDA-AMC, HARPER, RECORD-PE (45 min)

Three documents cover most of what a Canadian RWE study will be judged against.

CDA-AMC Guidance for Reporting Real-World Evidence (May 2023). Written by CADTH (now CDA-AMC) with Health Canada and INESSS, for studies submitted to regulators and HTA bodies. It is organized in 12 reporting sections, with a recommendations checklist:

#Section
1Research questions and study design
2Setting and context
3Data specifications: access, cleaning methods, linkage
4Data sources, data dictionary and variables
5Participants
6Exposure definitions and comparators
7Outcomes
8Bias, confounding, and effect modifiers or subgroup effects
9Statistical methods
10Study findings
11Interpretation and generalizability
12Limitations

Recommendations worth knowing by heart:

  • Data provenance. Describe the data's origin, custodians and transformations, the database version, and data quality such as completeness.
  • Protocol. Register an a priori protocol on a public platform; the guidance names the Real-World Evidence Registry, ClinicalTrials.gov and the EU PAS Register. Log every deviation with its date and reason.
  • Bias. For each bias, state its expected direction and size, and say which biases could not be addressed.
  • Effect modification. At a minimum, look at age, sex and race or ethnicity.
  • Time-related bias. Consider target trial emulation to avoid immortal time and selection bias (Days 22–23).

HARPER (HARmonized Protocol Template to Enhance Reproducibility, a joint ISPE/ISPOR task force, 2022) is a protocol template for RWE studies of treatment effects, combining text, structured tables and a design diagram. It asks investigators to state the estimand, data provenance, design parameters and analysis choices precisely enough for someone else to reproduce the study.

RECORD-PE (BMJ 2018) extends the STROBE and RECORD reporting checklists to pharmacoepidemiology studies using routinely collected data: how drug exposure was defined from dispensings, new-user designs, how confounding by indication was handled.

The three overlap. Write the protocol in HARPER order, check it against the CDA-AMC sections, and report the finished study with RECORD-PE.


29.2 Is the data fit for purpose? (40 min)

A dataset is not good or bad; it is fit or unfit for a particular question. For this study, the key variables are the eGFR at time zero (eligibility and the strongest confounder), albuminuria, dispensings (exposure) and kidney failure (outcome). Measure their completeness and timeliness:

"""Day 29.2: is the extract fit for purpose? Completeness and timeliness of the variables the study rests on."""

import os
import sys

sys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__)), ".."))
import pandas as pd  # noqa: E402

from corridor.db import ROOT, connect  # noqa: E402
from corridor.rwe import D  # noqa: E402

con = connect()
q = lambda s: con.sql(s).fetchall()[0]  # noqa: E731
n = q(f"SELECT count(*) FROM read_csv('{D}/rwe_persons.csv')")[0]
rows = []
for k, month in ((0, "2026-01-01"), (6, "2026-07-01"), (11, "2026-12-01")):
    c = q(f"""
        SELECT avg((e.last IS NOT NULL AND e.last >= DATE '{month}' - INTERVAL 365 DAY)::INT),
               avg((u.last IS NOT NULL AND u.last >= DATE '{month}' - INTERVAL 365 DAY)::INT),
               median(date_diff('day', e.last, DATE '{month}'))
        FROM read_csv('{D}/rwe_persons.csv') p
        LEFT JOIN (SELECT person_id, max(lab_date) AS last FROM read_csv('{D}/rwe_labs.csv')
                   WHERE test = 'egfr' AND lab_date < DATE '{month}' GROUP BY 1) e USING (person_id)
        LEFT JOIN (SELECT person_id, max(lab_date) AS last FROM read_csv('{D}/rwe_labs.csv')
                   WHERE test = 'uacr' AND lab_date < DATE '{month}' GROUP BY 1) u USING (person_id)""")
    rows.append({"trial month": k, "eGFR in the last 365 days": f"{c[0]:.1%}", "UACR in the last 365 days": f"{c[1]:.1%}",
                 "median days since last eGFR": int(c[2])})
tab = pd.DataFrame(rows)
print(f"{n:,} people in the extract")
print(tab.to_string(index=False))
gap = q(f"""SELECT median(d), quantile_cont(d, 0.9) FROM (
        SELECT date_diff('day', lag(lab_date) OVER (PARTITION BY person_id ORDER BY lab_date), lab_date) AS d
        FROM read_csv('{D}/rwe_labs.csv') WHERE test = 'egfr') WHERE d IS NOT NULL""")
print(f"\ndays between eGFR tests: median {gap[0]:.0f}, 90th percentile {gap[1]:.0f}")
disp = con.sql(f"SELECT drug, count(*) AS n, min(dispense_date) AS first, max(dispense_date) AS last, "
               f"mode(days_supply) AS usual_supply FROM read_csv('{D}/rwe_dispensations.csv') GROUP BY 1 ORDER BY 1").df()
print(disp.to_string(index=False))
ev = con.sql(f"SELECT event, count(*) AS n, min(event_date) AS first, max(event_date) AS last "
             f"FROM read_csv('{D}/rwe_events.csv') GROUP BY 1 ORDER BY 1").df()
print(ev.to_string(index=False))
tab.to_csv(os.path.join(ROOT, "docs", "data_fitness.csv"), index=False)
9,805 people in the extract
 trial month eGFR in the last 365 days UACR in the last 365 days  median days since last eGFR
           0                    100.0%                     79.8%                           84
           6                     99.9%                     81.4%                           84
          11                     98.8%                     66.3%                           87

days between eGFR tests: median 145, 90th percentile 271
   drug     n      first       last  usual_supply
renavex 27731 2026-01-01 2028-12-28            90
  sglt2  6667 2026-01-01 2028-12-28            90
          event    n      first       last
          death 1302 2026-01-01 2028-12-28
hospitalization 4570 2026-01-01 2028-12-28
 kidney_failure  438 2026-01-04 2028-12-24

eGFR is nearly complete at every trial start (99–100% within a year; median 84 days old), but tests are 145 days apart on average, so the "current" eGFR in a trial month can be months stale. UACR is the weak point: 66–81% of people have a result within a year. People with no UACR result were coded "no albuminuria", and an old result can be out of date: misclassification of a confounder, the kind of measurement error Day 28's truth check pointed to. Dispensings and events cover 2026–2028 with 90-day supplies. A fitness table like this belongs in section 3 of the CDA-AMC report, and its limitations in section 12.

Check it in R:

# Day 29: the data-fitness numbers again in R (eGFR and UACR completeness at the first trial month).
suppressPackageStartupMessages({ library(DBI); library(duckdb) })
con <- dbConnect(duckdb(shared_home = FALSE))
labs <- dbGetQuery(con, "SELECT * FROM read_csv('data/rwe_labs.csv')")
people <- dbGetQuery(con, "SELECT person_id FROM read_csv('data/rwe_persons.csv')")
dbDisconnect(con, shutdown = TRUE)
t0 <- as.Date("2026-01-01")
recent <- function(test) {
  l <- labs[labs$test == test & labs$lab_date < t0 & labs$lab_date >= t0 - 365, ]
  mean(people$person_id %in% l$person_id)
}
cat(sprintf("eGFR in the last 365 days: %.1f%%; UACR: %.1f%%\n", 100 * recent("egfr"), 100 * recent("uacr")))
eg <- labs[labs$test == "egfr", ]
eg <- eg[order(eg$person_id, eg$lab_date), ]
gaps <- as.numeric(unlist(tapply(eg$lab_date, eg$person_id, function(d) diff(sort(d)))))
cat(sprintf("days between eGFR tests: median %.0f, 90th percentile %.0f\n", median(gaps), quantile(gaps, 0.9)))
eGFR in the last 365 days: 100.0%; UACR: 79.8%
days between eGFR tests: median 145, 90th percentile 271

29.3 The design diagram (30 min)

HARPER and the CDA-AMC guidance both ask for a diagram that places every window relative to time zero: eligibility look-backs, covariate assessment, exposure, follow-up. Reviewers find immortal time and covariates measured after time zero in seconds on a diagram, and in hours in prose.

"""Day 29.3: the study design diagram that HARPER and the CDA-AMC guidance ask for (one trial shown)."""

import os
import sys

sys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__)), ".."))
import matplotlib  # noqa: E402

matplotlib.use("Agg")
import matplotlib.pyplot as plt  # noqa: E402

from corridor.db import ROOT  # noqa: E402

bars = [  # (label, start month, end month relative to time zero, colour)
    ("Eligibility: no Renavex ever before (2025 users excluded)", -84, 0, "#a78bfa"),
    ("Eligibility: eGFR 20-60, latest test in the last 12 months", -12, 0, "#a78bfa"),
    ("Covariates: diagnoses, drugs, hospital stays (warehouse 2019-2025)", -84, 0, "#22b8cf"),
    ("Covariates: latest eGFR and UACR, SGLT2 use", -12, 0, "#22b8cf"),
    ("Exposure: first Renavex dispensing in the trial month (vs none)", 0, 1, "#3ecf8e"),
    ("Follow-up: kidney failure, death, hospitalization", 0, 24, "#f5a524"),
]
fig, ax = plt.subplots(figsize=(9, 3.6))
for i, (label, a, b, c) in enumerate(bars[::-1]):
    ax.barh(i, b - a, left=a, color=c, height=0.55)
    ax.text(-86, i, label, ha="right", va="center", fontsize=8.5)
ax.axvline(0, color="black", lw=1.2)
ax.text(0, len(bars) - 0.35, "Day 0: first day of trial month k\n(k = 0..11, Jan-Dec 2026)", ha="center", fontsize=8)
ax.set_xlim(-86, 26)
ax.set_xticks([-84, -12, 0, 12, 24])
ax.set_xticklabels(["2019\n(history starts)", "-12", "0", "+12", "+24"])
ax.set_xlabel("months relative to time zero")
ax.set_yticks([])
ax.spines[["top", "right", "left"]].set_visible(False)
fig.tight_layout()
fig.savefig(os.path.join(ROOT, "figures", "day29_design_diagram.png"), dpi=150, bbox_inches="tight")
print("wrote figures/day29_design_diagram.png")

Study design diagram

Every bar ends at or before day 0 except exposure (the trial month) and follow-up. A covariate bar that crossed day 0 would be adjusting for something the treatment could affect.


29.4 Twenty-four defensible analyses (40 min)

Bug of the day. Every analysis involves choices that are each defensible: how recent the eGFR must be, how to model it, which provinces, which weights. Run all 24 combinations and report the one that looks best:

"""Day 29 bug of the day: choosing the analysis after seeing the results. 24 defensible specifications,
then report the most favourable one."""

import os
import sys

sys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__)), ".."))
import itertools  # noqa: E402

import numpy as np  # noqa: E402
import pandas as pd  # noqa: E402

from corridor.db import ROOT  # noqa: E402
from corridor.ps import PS_FORMULA, fit_ps, weighted_risks, weights  # noqa: E402
from corridor.tte import load  # noqa: E402

t = load()
choices = {"eGFR window": {"365 days": 365, "180 days": 180},
           "eGFR in the PS": {"spline": PS_FORMULA, "linear": PS_FORMULA.replace("cr(egfr, df=4)", "egfr")},
           "province": {"both": None, "Ontario": 0},
           "weights": {"ATE": "ate", "ATT": "att", "overlap": "overlap"}}
rows = []
for combo in itertools.product(*[list(v.items()) for v in choices.values()]):
    (wl, win), (pl, f), (prl, prov), (wtl, kind) = combo
    d = t[t.egfr_age_days <= win]
    if prov is not None:
        d = d[d.qc == prov]
    d = d.reset_index(drop=True)
    _, e = fit_ps(d, f.replace(" + qc", "") if prov is not None else f)
    r1, r0 = weighted_risks(d.kf24, d.start, weights(e, d.start, kind))
    rows.append({"eGFR window": wl, "eGFR in PS": pl, "province": prl, "weights": wtl, "starts": int(d.start.sum()),
                 "ratio": round(r1 / r0, 2)})
s = pd.DataFrame(rows).sort_values("ratio").reset_index(drop=True)
s.to_csv(os.path.join(ROOT, "docs", "specification_curve.csv"), index=False)
print(f"{len(s)} specifications: ratios from {s.ratio.min():.2f} to {s.ratio.max():.2f}, median {s.ratio.median():.2f}")
print("\nthe three most favourable:")
print(s.head(3).to_string(index=False))
pre = s.query("`eGFR window` == '365 days' and `eGFR in PS` == 'spline' and province == 'both' and weights == 'overlap'")
print(f"\nthe pre-specified analysis (365 days, spline, both provinces, overlap): {pre.ratio.iloc[0]:.2f} "
      f"(rank {pre.index[0] + 1} of {len(s)})")
24 specifications: ratios from 0.62 to 0.81, median 0.73

the three most favourable:
eGFR window eGFR in PS province weights  starts  ratio
   365 days     spline  Ontario     ATE     632   0.62
   365 days     linear  Ontario     ATE     632   0.62
   365 days     linear     both     ATE    1041   0.65

the pre-specified analysis (365 days, spline, both provinces, overlap): 0.80 (rank 21 of 24)

The same data give ratios from 0.62 to 0.81. An analyst who explored and then wrote "Renavex reduced kidney failure by 38% (Ontario, ATE weights)" would not have made any single error. The error is in the selection. The pre-specified analysis (overlap weights, both provinces) ranks 21st of 24, the least impressive. That is why the guidance asks for a registered protocol and a deviation log, and why changes made after seeing results must be flagged.

Why it matters at work: reviewers increasingly ask whether an RWE study was registered, and a sponsor study without a protocol is weighted down. Analysts on the receiving side (CDA-AMC, INESSS, ICES) check the submission against its registered protocol. A specification curve like this one is also a strong sensitivity analysis: it shows the whole range, not one chosen point.

Where you'll meet this: the Real-World Evidence Registry and EU PAS Register; "multiverse" or specification-curve analyses; CDA-AMC reviewer comments on submitted RWE


29.5 Truth check (30 min)

Each of the 24 specifications targets its own population and estimand, so each has its own truth:

"""Day 29 truth check: each of the 24 specifications against the truth for ITS population and estimand.
How far is the 'best-looking' result from the truth, compared with the pre-specified one?"""

import os
import sys

sys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__)), ".."))
import duckdb  # noqa: E402
import numpy as np  # noqa: E402
import pandas as pd  # noqa: E402

from corridor.db import ROOT  # noqa: E402
from corridor.ps import PS_FORMULA, fit_ps  # noqa: E402
from corridor.truth import TRUTH  # noqa: E402
from corridor.tte import load  # noqa: E402

s = pd.read_csv(os.path.join(ROOT, "docs", "specification_curve.csv"))
t = load()
tr = duckdb.sql(f"SELECT * FROM read_csv('{TRUTH}/rwe_sequential_truth.csv')").df()
truths = []
for _, r in s.iterrows():
    d = t[t.egfr_age_days <= (365 if r["eGFR window"] == "365 days" else 180)]
    if r.province == "Ontario":
        d = d[d.qc == 0]
    d = d.reset_index(drop=True)
    f = PS_FORMULA if r["eGFR in PS"] == "spline" else PS_FORMULA.replace("cr(egfr, df=4)", "egfr")
    _, e = fit_ps(d, f.replace(" + qc", "") if r.province == "Ontario" else f)
    m = d.assign(trial=d.trial.astype(int), e=e).merge(tr, on=["person_id", "trial"])
    h = {"ATE": np.ones(len(m)), "ATT": m.start.to_numpy(), "overlap": (m.e * (1 - m.e)).to_numpy()}[r.weights]
    truths.append(np.average(m.kf24_start, weights=h) / np.average(m.kf24_no_start, weights=h))
s["truth"] = np.round(truths, 2)
s["error"] = (s.ratio - s.truth).round(2)
print(s.head(3).to_string(index=False))
print("...")
pre = s[(s["eGFR window"] == "365 days") & (s["eGFR in PS"] == "spline") & (s.province == "both") & (s.weights == "overlap")]
print(pre.to_string(index=False, header=False))
print(f"\nmean absolute error over all 24: {s.error.abs().mean():.2f}; most favourable: {abs(s.error.iloc[0]):.2f}; "
      f"pre-specified: {abs(pre.error.iloc[0]):.2f}")
eGFR window eGFR in PS province weights  starts  ratio  truth  error
   365 days     spline  Ontario     ATE     632   0.62   0.75  -0.13
   365 days     linear  Ontario     ATE     632   0.62   0.75  -0.13
   365 days     linear     both     ATE    1041   0.65   0.73  -0.08
...
365 days spline both overlap 1041 0.8 0.73 0.07

mean absolute error over all 24: 0.06; most favourable: 0.13; pre-specified: 0.07

The most favourable result (0.62) is the furthest from its truth (0.75, an error of 0.13). The pre-specified result is off by 0.07, and the average error across all 24 is 0.06. Choosing the best-looking result selects for estimates whose random error happened to point the "good" way. It is the winner's curse of Day 27 again, now applied to analysis choices.


29.6 Checking a protocol against the guidance (20 min)

A simple checker looks for each CDA-AMC section, plus five items both HARPER and the guidance ask for, in the headings and text of a Markdown protocol:

CDA_SECTIONS = {
    "Research questions and study design": ["research question", "study design", "target trial"],
    "Setting and context": ["setting", "context"],
    "Data specifications: access, cleaning, linkage": ["data access", "linkage", "cleaning"],
    "Data sources, data dictionary, variables": ["data source", "data dictionary"],
    "Participants": ["participants", "eligibility"],
    "Exposure definitions and comparators": ["exposure", "comparator"],
    "Outcomes": ["outcome"],
    "Bias, confounding, effect modifiers or subgroups": ["confounding", "bias"],
    "Statistical methods": ["statistical methods", "analysis plan"],
    "Study findings": ["findings", "results"],
    "Interpretation and generalizability": ["interpretation", "generalizability"],
    "Limitations": ["limitations"],
}
EXTRA_ITEMS = {                                    # items HARPER and the CDA-AMC guidance both ask for
    "Registration": ["registered", "registration"],
    "Protocol deviations / amendments": ["deviation", "amendment"],
    "Design diagram": ["design diagram"],
    "Sensitivity analyses": ["sensitivity analys"],
    "Data fitness / quality": ["completeness", "fit for purpose", "fit-for-purpose"],
}

def check_protocol(text, sections=None):
    """For each required item, the first heading (## or ###) whose title or body mentions one of its words.
    Returns {item: heading or None}."""
    sections = sections or {**CDA_SECTIONS, **EXTRA_ITEMS}
    parts = re.split(r"^(#{1,3} .*)$", text, flags=re.M)
    blocks = [("(top)", parts[0])] + [(parts[i].lstrip("# ").strip(), parts[i + 1]) for i in range(1, len(parts), 2)]
    found = {}
    for item, words in sections.items():
        found[item] = next((h for h, body in blocks if any(w in (h + " " + body).lower() for w in words)), None)
    return found

Try it (15 min). Run the checker on the Day 22 protocol table (docs/target_trial_protocol.md). Which items are missing?

Solution
"""Day 29 try it: run the CDA-AMC section checker on the Day 22 protocol table. What is missing?"""

import os
import sys

sys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__)), ".."))
from corridor.db import ROOT  # noqa: E402
from corridor.reporting import check_protocol  # noqa: E402

text = open(os.path.join(ROOT, "docs", "target_trial_protocol.md"), encoding="utf-8").read()
found = check_protocol(text)
for item, where in found.items():
    print(f"  {'ok ' if where else 'MISSING'}  {item}{'' if not where else '  <- ' + where}")
print(f"\n{sum(v is None for v in found.values())} of {len(found)} items missing")
  ok   Research questions and study design  <- Target trial: Renavex and kidney failure in routine care
  MISSING  Setting and context
  MISSING  Data specifications: access, cleaning, linkage
  MISSING  Data sources, data dictionary, variables
  ok   Participants  <- Target trial: Renavex and kidney failure in routine care
  MISSING  Exposure definitions and comparators
  ok   Outcomes  <- Target trial: Renavex and kidney failure in routine care
  MISSING  Bias, confounding, effect modifiers or subgroups
  MISSING  Statistical methods
  MISSING  Study findings
  MISSING  Interpretation and generalizability
  MISSING  Limitations
  MISSING  Registration
  MISSING  Protocol deviations / amendments
  MISSING  Design diagram
  MISSING  Sensitivity analyses
  MISSING  Data fitness / quality

14 of 17 items missing

The target trial table covers the design, participants and outcomes, and little else: 14 of 17 items are missing. It even misses "study findings", because its results paragraph is headed "Result" and the checker looks for "results" or "findings". A keyword checker is a first pass that catches whole missing sections; it does not judge quality. The table remains the right first page; the protocol around it is today's mini-project.


29.7 Mini-project: the Module 3 protocol (55 min)

Write the Module 3 protocol in HARPER order, mapped to the 12 CDA-AMC sections, with numbers from earlier days and a deviation log, to docs/rwe_protocol.md. Then check it.

"""Day 29 mini-project: the Module 3 study protocol in HARPER order, mapped to the CDA-AMC reporting
sections, with a deviation log - written to docs/rwe_protocol.md and checked."""

import os
import sys

sys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__)), ".."))
import pandas as pd  # noqa: E402

from corridor.db import ROOT  # noqa: E402
from corridor.reporting import Deviation, check_protocol  # noqa: E402

est = pd.read_csv(os.path.join(ROOT, "docs", "m3_estimates.csv"))
fit = pd.read_csv(os.path.join(ROOT, "docs", "data_fitness.csv"))
ato = est.query("method == 'overlap weights'")["risk ratio"].iloc[0]
att = est.query("method == 'AIPW' and estimand == 'ATT'")["risk ratio"].iloc[0]
deviations = [
    Deviation("2026-11-26", "Statistical methods", "Primary estimand changed from all eligible (ATE) to starters (ATT) "
              "and the overlap population", "Poor overlap at high eGFR: ATE weights up to 8.5, ESS 439 of 1,041", True),
    Deviation("2026-11-26", "Exposure definitions", "Sustained strategies defined jointly with SGLT2 status",
              "Co-treatment changes the strategy being estimated", False),
    Deviation("2026-11-26", "Bias, confounding", "Frailty chart-review substudy added for bias analysis",
              "Negative control outcome suggested residual confounding", True)]
text = f"""# Renavex in routine care: an emulated target trial (protocol, HARPER order)

**Registration:** to be registered on the Real-World Evidence Registry before analysis (placeholder ID RWE-0000).
**Version:** 1.1 (see the amendments and deviations log).

## 1. Research question and objectives
Research question: does starting Renavex, compared with not starting, lower the 24-month risk of kidney failure
in adults with type 2 diabetes and CKD stage 3a-4 treated in routine care in Ontario and Quebec? Study design:
an emulated target trial with twelve monthly sequential trials (January-December 2026).

## 2. Setting and context
Setting: publicly funded care in Ontario (listing October 2025) and Quebec (listing February 2026).

## 3. Data sources and data specifications
Data source: the Corridor Health RWE extract (registry, labs, dispensations, events, 2026-2028) linked on person_id
to the 2019-2025 warehouse. Data access: analysts receive a de-identified extract; linkage and cleaning were done
by the data custodian. Data dictionary: docs/data_dictionary_cohort_base.md and the Module 3 file list.
Data fitness: an eGFR test in the previous 365 days for {fit.iloc[0, 1]} of people at the first trial month;
UACR for {fit.iloc[0, 2]} (completeness by trial month in docs/data_fitness.csv).

## 4. Participants
Eligibility at each trial start: alive, free of kidney failure, never dispensed Renavex, latest eGFR 20-60 within
12 months.

## 5. Exposure and comparator
Exposure: a first Renavex dispensing in the trial month. Comparator: no dispensing that month (usual care).

## 6. Outcomes
Primary outcome: kidney failure within 24 months. Secondary outcome: death. Negative control outcome: hospitalization.

## 7. Design diagram
See figures/day29_design_diagram.png (design diagram: eligibility, covariate and follow-up windows).

## 8. Confounding, bias and effect modification
Confounding is addressed by the propensity score and outcome models (DAG, Day 21). Bias from unmeasured frailty is
examined with a negative control outcome, E-values and quantitative bias analysis. Effect modification: pre-specified
subgroups (eGFR, albuminuria, province, age) and quarters of baseline risk.

## 9. Statistical methods (analysis plan)
Primary: overlap weights; secondary: AIPW for the effect in starters; persons resampled for CIs.
Sensitivity analyses: E-values, frailty QBA, alternative eGFR windows (pre-specified, all reported).

## 10. Results
Findings to date: overlap-weighted risk ratio {ato:.2f}; AIPW effect in starters {att:.2f} (docs/m3_estimates.csv).

## 11. Interpretation and generalizability
Results apply to the overlap population and starters (Table 1, Day 24), not to people with eGFR above 45.

## 12. Limitations
Unmeasured frailty; albuminuria measured with error; 24-month horizon only.

## Amendments and deviations
| Date | Section | Change | Reason | After seeing results? |
|---|---|---|---|---|
""" + "\n".join(d.row() for d in deviations) + "\n"
open(os.path.join(ROOT, "docs", "rwe_protocol.md"), "w", encoding="utf-8").write(text)
found = check_protocol(text)
print(f"docs/rwe_protocol.md: {sum(v is not None for v in found.values())} of {len(found)} items found")
for item, where in found.items():
    if where is None:
        print("  missing:", item)
print(f"deviations made after seeing results: {sum(d.after_seeing_results for d in deviations)} of {len(deviations)}")
docs/rwe_protocol.md: 17 of 17 items found
deviations made after seeing results: 2 of 3

All 17 items are present. The deviation log is honest: two of the three changes were made after seeing results. The switch from ATE to the effect in starters is defensible (poor overlap at high eGFR), but it must be visible. Tomorrow's capstone turns this protocol into the full report. Before then, rewrite sections 8 and 12 in your own words, using Days 27 and 28: the subgroup findings, the negative control, and the frailty bias analysis with its limits.

29.8 Save your work

python -m pytest -q
git add .
git commit -m "Day 29: RWE reporting standards, data fitness, design diagram, protocol"

Day 29 checklist

  • I can name the 12 sections of the CDA-AMC Guidance for Reporting Real-World Evidence
  • I write protocols in HARPER order with a design diagram, and register them before analysis
  • I assess data fitness: completeness and timeliness of the variables the question depends on
  • I log every protocol deviation, with its date, reason, and whether results had been seen
  • I report the range of defensible analyses, not the most favourable one