Skip to content

Commit

Permalink
add subheaders
Browse files Browse the repository at this point in the history
  • Loading branch information
strengejacke committed Feb 23, 2025
1 parent 6c80086 commit a15a763
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion vignettes/practical_causality.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,9 @@ d$predictions <- predict(m_ipw, newdata = d, type = "response")
d$ipw <- ifelse(d$treatment == 1, 1 / d$predictions, 1 / (1 - d$predictions))
```

Next, we run the same model again, including the weights. We see that the treatment effect, after weighting, is about `9` points, i.e. the treatment on average results in a 9-point higher score for QoL.
## ATE calculated from IPW in simpler models

Now we run the same model again, including the weights. We see that the treatment effect, after weighting, is about `9` points, i.e. the treatment on average results in a 9-point higher score for QoL.

```{r}
m2 <- glmmTMB::glmmTMB(
Expand All @@ -132,6 +134,8 @@ Given the simplicity of the model, g-computation offers no significant advantage
estimate_contrasts(m2, "treatment", estimate = "population")
```

## ATE calculated from IPW and g-computation in more complex models

However, we have not properly modelled the longitudinal nature of our data. Since patients' quality of life (QoL) was measured at three distinct time points, allowing for an examination of treatment effects over time, we need to include an interaction between `treatment` and `time`. This revealed a substantially greater increase in QoL over time within the treatment group. In such more complex modeling scenarios, g-computation becomes particularly advantageous.

```{r fig.width = 6, fig.height = 4.5, out.width = "90%", out.height = "90%"}
Expand Down Expand Up @@ -178,6 +182,8 @@ estimate_contrasts(m4, "treatment")
estimate_contrasts(m4, "treatment", estimate = "population")
```

## Average treatment effect on the treated and untreated

The last example completes the "causal inference" topic by showing how to calculate the average treatment effect on the treated (ATT), and average treatment effect on the untreated (ATU).

The ATT measures how much the treatment changes the outcome for those who already received it. It can help to decide whether a program or treatment should be discontinued for the people currently benefiting from it. Likewise, the ATU estimates how much the treatment would change the outcome if it were given to those who didn't already receive it. It helps us decide whether a program or treatment should be expanded to include those who haven't yet benefited from it. It helps to assess the potential benefits of extending a program or treatment to a wider population.
Expand Down

0 comments on commit a15a763

Please sign in to comment.