Preparing for causal inference in R
Next, we’ll implement an example causal inference problem in R. Take our previous problem, as discussed in Chapter 2, of a group of students changing their home location from a noisy neighborhood to a quieter place. The university observed the change might have brought improvement in their grades and performance in class. They assign you as a researcher to learn whether there is any causal link between moving neighborhoods and improved grades.
Preparing and loading data
We use a toy dataset representing students who moved from a noisy to a quieter neighborhood. The data is located in the Git repository. The dataset includes grades before and after the move, noise levels in the neighborhood, and other factors such as study hours, part-time job status, and family income.
Let’s transform the data for our analysis.
Specifically, we begin by reading a CSV file named student_data.csv
(provided in the Git repository) into a data...