| The name of a Greek god | A prognostic factor | The treatment, a heart transplant | The outcome, death |
|---|---|---|---|
| Rheia | 0 | 0 | 0 |
| Kronos | 0 | 0 | 1 |
| Demeter | 0 | 0 | 0 |
| Hades | 0 | 0 | 0 |
| Hestia | 0 | 1 | 0 |
| Poseidon | 0 | 1 | 0 |
| Hera | 0 | 1 | 0 |
| Zeus | 0 | 1 | 1 |
| Artemis | 1 | 0 | 1 |
| Apollo | 1 | 0 | 1 |
Stanford University
Normal regression estimates associations. But we want causal estimates: what would happen if everyone in the study were exposed to x vs if no one was exposed.
y ~ x + z where z is all covariatesxx = 1 for one, x = 0 for the other)mean(x_1) - mean(x_0)Often more statistically precise than propensity-based methods
Incredibly flexible
Basis of other important causal models, e.g. causal survival analysis and TMLE
greek_data)| The name of a Greek god | A prognostic factor | The treatment, a heart transplant | The outcome, death |
|---|---|---|---|
| Rheia | 0 | 0 | 0 |
| Kronos | 0 | 0 | 1 |
| Demeter | 0 | 0 | 0 |
| Hades | 0 | 0 | 0 |
| Hestia | 0 | 1 | 0 |
| Poseidon | 0 | 1 | 0 |
| Hera | 0 | 1 | 0 |
| Zeus | 0 | 1 | 1 |
| Artemis | 1 | 0 | 1 |
| Apollo | 1 | 0 | 1 |
+ 10 more rows
y ~ a + la| The name of a Greek god | A prognostic factor | The treatment, a heart transplant | The outcome, death |
|---|---|---|---|
| Rheia | 0 | 0 | 0 |
| Kronos | 0 | 0 | 1 |
| Demeter | 0 | 0 | 0 |
| Hades | 0 | 0 | 0 |
| Hestia | 0 | 1 | 0 |
| Poseidon | 0 | 1 | 0 |
| Hera | 0 | 1 | 0 |
| Zeus | 0 | 1 | 1 |
| Artemis | 1 | 0 | 1 |
| Apollo | 1 | 0 | 1 |
a| The name of a Greek god | A prognostic factor | The treatment, a heart transplant | The outcome, death |
|---|---|---|---|
| Rheia | 0 | 0 | 0 |
| Kronos | 0 | 0 | 1 |
| Demeter | 0 | 0 | 0 |
| Hades | 0 | 0 | 0 |
| Hestia | 0 | 1 | 0 |
| Poseidon | 0 | 1 | 0 |
| Hera | 0 | 1 | 0 |
| Zeus | 0 | 1 | 1 |
| Artemis | 1 | 0 | 1 |
| Apollo | 1 | 0 | 1 |
| The name of a Greek god | A prognostic factor | The treatment, a heart transplant | The outcome, death |
|---|---|---|---|
| Rheia | 0 | 0 | 0 |
| Kronos | 0 | 0 | 1 |
| Demeter | 0 | 0 | 0 |
| Hades | 0 | 0 | 0 |
| Hestia | 0 | 1 | 0 |
| Poseidon | 0 | 1 | 0 |
| Hera | 0 | 1 | 0 |
| Zeus | 0 | 1 | 1 |
| Artemis | 1 | 0 | 1 |
| Apollo | 1 | 0 | 1 |
a to a single value for each cloned data set| The name of a Greek god | A prognostic factor | a | The outcome, death |
|---|---|---|---|
| Rheia | 0 | 0 | 0 |
| Kronos | 0 | 0 | 1 |
| Demeter | 0 | 0 | 0 |
| Hades | 0 | 0 | 0 |
| Hestia | 0 | 0 | 0 |
| Poseidon | 0 | 0 | 0 |
| Hera | 0 | 0 | 0 |
| Zeus | 0 | 0 | 1 |
| Artemis | 1 | 0 | 1 |
| Apollo | 1 | 0 | 1 |
| The name of a Greek god | A prognostic factor | a | The outcome, death |
|---|---|---|---|
| Rheia | 0 | 1 | 0 |
| Kronos | 0 | 1 | 1 |
| Demeter | 0 | 1 | 0 |
| Hades | 0 | 1 | 0 |
| Hestia | 0 | 1 | 0 |
| Poseidon | 0 | 1 | 0 |
| Hera | 0 | 1 | 0 |
| Zeus | 0 | 1 | 1 |
| Artemis | 1 | 1 | 1 |
| Apollo | 1 | 1 | 1 |
a to a single value for each cloned data set# set all participants to have a = 0 untreated_data <- greek_data |> mutate(a = 0) # set all participants to have a = 1 treated_data <- greek_data |> mutate(a = 1)# set all participants to have a = 0 untreated_data <- greek_data |> mutate(a = 0) # set all participants to have a = 1 treated_data <- greek_data |> mutate(a = 1)
# predict under the data where everyone is untreated predicted_untreated <- greek_model |> augment(newdata = untreated_data) |> select(untreated = .fitted) # predict under the data where everyone is treated predicted_treated <- greek_model |> augment(newdata = treated_data) |> select(treated = .fitted) predictions <- bind_cols( predicted_untreated, predicted_treated )# predict under the data where everyone is untreated predicted_untreated <- greek_model |> augment(newdata = untreated_data) |> select(untreated = .fitted) # predict under the data where everyone is treated predicted_treated <- greek_model |> augment(newdata = treated_data) |> select(treated = .fitted) predictions <- bind_cols( predicted_untreated, predicted_treated )
# A tibble: 1 × 3
mean_treated mean_untreated difference
<dbl> <dbl> <dbl>
1 0.5 0.5 0
Continuous exposures
We recommend g-computation over propensity scores for continuous exposures because of stability issues
10-continuous-g-computation-exercises.qmd10:00