Due: 1 hour after class ends
You will work in your pre-assigned teams. Each team should submit ONLY ONE report for this exercise. You must write the names of all team members at the top of the report containing your responses. You all must do the work using one student’s computer and R/RStudio.
Have one team member open R/RStudio on their computer and share their screen with the other team members within the breakout room. At the top of the team report, write “host” in parenthesis besides this student’s name. Have another team member be responsible for documenting the responses. At the top of the team report, write “writer” in parenthesis besides this student’s name.
NOTE: Generally, you will not be penalized for not taking on these roles many times during the semester. This is to simply ensure that you do switch the roles around a “decent number” of times within each team throughout the semester. That said, I will penalize any student who obviously dominates these roles over everyone else, so be sure to give other students an opportunity to do them.
You all should have R and RStudio installed on your computers by now. If you do not, first install the latest version of R here: https://cran.rstudio.com (remember to select the right installer for your operating system). Next, install the latest version of RStudio here: https://www.rstudio.com/products/rstudio/download/. Scroll down to the “Installers for Supported Platforms” section and find the right installer for your operating system.
Gradescope will let you select your team mates when submitting, so make sure to do so. Only one person needs to submit the sheet on Gradescope. You can submit your document in the most common formats, but pdf files are preferred. Submit on Gradescope here: https://www.gradescope.com/courses/157499/assignments. Be sure to submit under the right assignment entry.
The purpose of this lab is to help you gain some experience doing causal inference.
Right Heart Catheterization (RHC) is a procedure for directly measuring how well the heart is pumping blood to the lungs. The procedure involves an insertion of a catheter (hollow tube) into right side of heart and through to pulmonary artery to monitor heart function and blood flow from the heart to lungs. RHC is often applied to critically ill patients for directing immediate and subsequent treatment. However, administering RHC may cause serious complications, though the risks are usually small. There is some debate whether the use of RHC actually leads to improved treatment.
Download the data file (named rhc.txt
) from Sakai and save it locally to the same directory as your R markdown file. To find the data file on Sakai, go to Resources \(\rightarrow\) Datasets \(\rightarrow\) In-Class Analyses. Once you have downloaded the data file into the SAME folder as your R markdown file, load and clean the data by using the following R code.
Remember to double-check the dimensions and first few rows of the data to confirm you have the right file. Also, convert the two variables treatment
and dth30
to binary variables. You MUST exclude the variable surv2md1
from the analysis, as shown in the code, so that you are left with 51 covariates.
library(ggplot2)
library(cobalt)
library(MatchIt)
library(randomForest)
# Read in the data
RHC <- read.table("rhc.txt",head=T)
RHC <- RHC[,-which(names(RHC)=="surv2md1")]
The dataset contains data on 5735 hospitalized adult patients at five medical centers in the U.S. The variable rhc
indicates whether RHC was applied within 24 hours of admission (TRUE/FALSE). Each patient was followed up with some treatment procedures that may have been influenced by the RHC result if it was performed on the patient.
The outcome variable is dth30
– death at 30 days (TRUE: dead; FALSE: alive).
Based on information from a panel of experts, a set of 52 variables were identified that are potentially related to both the decision to use RHC and the outcome. The goal is to estimate the treatment effect of RHC on death at 30 days. Let pr(Y(w) = 1) = pw be the fraction of patients with dth30=1
for treatment group w (w=0 or 1, that is rhc=FALSE
or rhc=TRUE
respectively).
The target estimand is the average causal effect Q = p1 - p0 for patients with rhc=TRUE
.
That is, we will focus on estimating ATT and not ATE, that is, treatment effect for those who actually received RHC. Clearly, this analysis models death, which means high probabilities are BAD. If RHC works, ATT should be negative.
Download the code book for the data (named rhc_codebook.pdf
) from Sakai; go to the same folder you downloaded the data file from.
Based only on the information available to you, can you consider this a randomized study? Why or why not?
Are the covariates in this data balanced between the two groups (rhc=FALSE
vs rhc=TRUE
)? If no, which covariates are not? How did you assess balance?
dth30
using the main effects of ALL covariates and rhc
. Using the fitted model, compute the ATT for the patients with rhc=TRUE
as follows:
rhc=TRUE
using the fitted model. This is an estimate of p1 for those patients.R
, you can use predict(model_object,type="response")
.rhc=FALSE
and their values for the other covariates unchanged, and generate new predicted probabilities for them. This is an estimate of p0 for those patients.rhc
equals TRUE
). The average is the estimated ATT.You really should be answering this question using a confidence interval, so as to quantify uncertainty. We will not do this in class but it can be done relatively easily via bootstrap
. You will learn bootstrap soon and should then try this on your own. Based on your estimated effect from question 2, are treated patients better or worse off with RHC?
Given your answer to question 2, do you trust your conclusions from question 4? Why or why not?