---
title: "RCT: Medicaid and medical debt"
date: "2026-03-05"
date-format: "long"
format:
  html:
    toc: true
  typst:
    toc: true
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```

# Does receiving Medicaid reduce medical debt?

In 2008, in response to the ACA's mandate that states expand Medicaid eligibility, Oregon used a lottery to randomly assign people to receive Medicaid ([see here](https://www.nber.org/programs-projects/projects-and-centers/oregon-health-insurance-experiment) for more details). Researchers tracked (and continue to track) a whole host of health and financial outcomes as a result of receiving access to Medicaid. 

You're going to investigate the effect of Medicaid on one outcome:

![Excerpt from Oregon Medicaid study codebook](img/oregon-medicaid.jpg)

## Load data

```{r}
#| label: libraries-data
#| warning: false
#| message: false

library(tidyverse)
library(parameters)

# TODO: Use read_csv() to load data/oregon.csv
```


## Clean data

There are two categorical columns in this dataset. It will make it easier to calculate differences in proportions if we have numeric versions of the columns too. Use `mutate()` and `case_when()` or `ifelse()` (look at the dplyr cheatsheet) to add two new columns:

- `treatment_num`: 0 if not treated, 1 if treated
- `outcome_num`: 0 if the person doesn't owe money, 1 if the person does owe money

```{r}
# TODO: Add two new columns with numeric versions of treatment and outcome
```


## Find the difference in outcome caused by treatment

```{r}
# TODO: Use group_by() and summarize() (or just count()) to calculate the
# proportion of people of people in the treatment and control groups who have
# medical debt. Is there a difference?
```

```{r}
# TODO: Use lm() to calculate the exact difference in the proportion of people
# with medical debt across the treatment and control groups. Is the difference
# significant? Substantial?
```

```{r}
# TODO: For bonus fun, try to visualize the difference in proportions
```
