In this lab you will explore confounding and effect measure
collapsibility using the Right Heart Catheterization (RHC)
dataset, investigating the association between receiving a right-heart
catheterization and all-cause mortality. You will prepare the data,
produce a descriptive summary table, and fit a series of regression
models to calculate and compare crude, conditional, and marginal effect
estimates (odds ratios, risk ratios, and risk differences) — seeing how
adjustment affects each measure differently. Your TA will walk through
the worked solution during the session.
This is the workflow you will reuse in P2 on your own locked paper.
Before you come to lab, install the package every model chunk uses:
install.packages("Publish") # capital P; the function you call is lowercase publish()Three things to know about the downloaded exercise file:
read.csv line in the
first chunk. The data are in the zip’s Data/ folder, and
nothing else runs until df exists.Follow along as the TA explains the worked solution.
Run the R Markdown file yourself, as a group, on your own laptop.
Put your group name and the first names of everyone
present in the author: field at the top of the
file.
Add sessionInfo() in a final code chunk.
Knit to PDF or HTML and submit that one file before the lab ends.
No written explanations are required. If you get stuck, ask the TA in the room — that is what the session is for.
You receive Complete if the document knitted without errors, your group name and members are in it, and it was submitted before the lab ended. Only members present in the room receive credit.
This lab is one step in a weekly chain: Tuesday’s lecture sets up the method, Thursday’s lab runs it on fixed teaching data, and your increment applies it to the paper your group locked at M0.
| Document | How this lab connects | |
|---|---|---|
| This week’s lecture | Week 4 — Confounding and DAGs; Table 1; variable roles | Tuesday used the MASLD paper to decide what to adjust for — DAGs, the empirical criteria, why change-in-estimate and stepwise selection fail — and showed why an odds or hazard ratio moves on adjustment even without confounding. This lab runs the mechanics on a different dataset (RHC): crude, conditional and marginal odds ratios, risk ratios and risk differences, and standardisation. |
| Slide deck | Week 4 deck | The same material as slides, with speaker notes. Press
S for notes, F for fullscreen. |
| Your increment | P2 — Confounding diagnostic | Produce your own Table 1 plus a written adjustment rationale — which variables you adjust for, which you deliberately do not, and why. |
| Worked example | P2 example — its code | A completed P2: the Table 1, and the adjustment rationale written out. Read the rationale first — it is the part that carries the marks. |
| Milestone | M1 — Replication and interrogation | P2 enters M1 as Confounding, adjustment set, Table 1. P2 is optional and ungraded with nothing to submit; M1 is where it is assessed. |