Skip to content

Commit

Permalink
Merge pull request #247 from drakileshr/patch-1
Browse files Browse the repository at this point in the history
Update 03-counterfactuals.qmd
  • Loading branch information
malcolmbarrett authored Aug 7, 2024
2 parents db2f1aa + 75e4d35 commit dc43ac4
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion chapters/03-counterfactuals.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ data_observed |>
group_by(exposure) |>
summarise(avg_outcome = mean(observed_outcome))
```
Now our estimated causal effect (because interference exists) is `r data_observed |> group_by(exposure) |> summarise(avg_outcome = mean(observed_outcome)) |> mutate(exposure = c(1, 0)) |> pivot_wider(names_from = exposure, values_from = avg_outcome, names_prefix = "x_") |> summarise(estimate = x_1 - x_0) |> pull() |> round(1)`. This demonstrates what can go wrong when *interference* occurs. One of the main ways to combat interference is change the *unit* under consideration. Here, each individual, each unique *id*, is considered a unit, and there is interference between units (i.e. between partners). If instead we consider each *partner* as a unit and randomize the partners rather than the individuals, we solve the interference issue, as there is not interference *between* different partner sets. This is sometimes referred to as a *cluster randomized trial*. What we decide to do within each cluster may depend on the causal question at hand. For example, if we want to know what would happen if *everyone* at chocolate ice cream versus if *everyone* at vanilla, we would want to randomize both partners to either chocolate or vanilla, as seen below.
Now our estimated causal effect (because interference exists) is `r data_observed |> group_by(exposure) |> summarise(avg_outcome = mean(observed_outcome)) |> mutate(exposure = c(1, 0)) |> pivot_wider(names_from = exposure, values_from = avg_outcome, names_prefix = "x_") |> summarise(estimate = x_1 - x_0) |> pull() |> round(1)`. This demonstrates what can go wrong when *interference* occurs. One of the main ways to combat interference is change the *unit* under consideration. Here, each individual, each unique *id*, is considered a unit, and there is interference between units (i.e. between partners). If instead we consider each *partner* as a unit and randomize the partners rather than the individuals, we solve the interference issue, as there is not interference *between* different partner sets. This is sometimes referred to as a *cluster randomized trial*. What we decide to do within each cluster may depend on the causal question at hand. For example, if we want to know what would happen if *everyone* ate chocolate ice cream versus if *everyone* ate vanilla, we would want to randomize both partners to either chocolate or vanilla, as seen below.

```{r}
set.seed(11)
Expand Down

0 comments on commit dc43ac4

Please sign in to comment.