In this lab you will work through effect
modification and interaction using the
RHC dataset, investigating whether the effect of
right-heart catheterization on mortality is modified by a patient’s
Do-Not-Resuscitate (DNR) status. You will prepare an analysis-ready
dataset, fit logistic regression models with a product term (the
multiplicative scale), and calculate the Relative Excess Risk due to
Interaction (RERI), Attributable Proportion (AP) and Synergy Index (SI)
— all three on the additive scale. Your TA will walk through the worked
solution during the session.
These are the questions you will ask in P3 on your own locked paper. If your paper’s outcome is time-to-event, use Tuesday’s time-to-event tools rather than this lab’s logistic recipe.
Before you come to lab, install the two packages this exercise needs:
install.packages(c("interactionR", "Publish"))Note the capital P in Publish — the
CRAN package is capitalised even though the function you call is
lowercase publish().
Things to know about the exercise before you read its output:
with(high_dasi_data, table(rhc_status, dnr_status, death_status)).
Only 23 of the 623 patients have a DNR order, and the exercise’s
reference cell — RHC and a DNR order — holds 3
patients, 1 of whom died. Every RERI, AP and S you compute
divides by them, which is why their intervals are so wide. This is
Tuesday’s “count first” slide, in the lab’s own data.No RHC and
No”; the code does the reverse (both indicators are 1 for
“No”), so the reference cell is RHC with a DNR order.em = TRUE it treats the first
exposure named as the modifier, so as called it shows DNR’s effect by
RHC. Problem 1 asks for RHC’s effect by DNR: read it from the
publish() rows, or swap the order of
exposure_names.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 5 — Interaction and effect modification | Tuesday separated effect modification from interaction on a clean smoking × income example, then stress-tested both on the paper’s four groups (obesity × waist fat): each question has its own adjustment set, each scale its own answer, and every cell gets counted first. This lab does both questions on a binary outcome, where logistic regression is the right tool: Problem 1 is effect modification (RHC’s confounders only), Problem 2 is interaction (the confounders of both). |
| Slide deck | Week 5 deck | The same material as slides, with speaker notes. Press
S for notes, F for fullscreen. |
| Your increment | P3 — Effect modification | Run one pre-specified effect-modification test on your own paper’s exposure, and state the verdict as evidence rather than as a mechanism: what the data show at the precision you have, and what the interval leaves open. |
| Worked example | P3 example — its code | A completed P3, including how the verdict is worded when the interval is wide. That wording is the hard part, not the arithmetic. |
| Milestone | M1 — Replication and interrogation | P3 enters M1 as Effect modification. P3 is optional and ungraded with nothing to submit; M1 is where it is assessed. |