---
title: "Randomization 2: Some common types of designs | *Randomisation 2 : Quelques types courants de conception*"
author: "Yannick + Macartan; Alyssa + Vin"
date: today
bibliography: assets/learningdays-book.bib
format:
  revealjs:
    embed-resources: true
---

## Some common designs | *Quelques types courants de conception*

::: {.columns}
::: {.column .lang-en width="50%"}

1. Factorial
2. Waitlist (delayed access)
3. Encouragement

:::
::: {.column .lang-fr width="50%"}

1. Factorielle
2. Liste d'attente (accès graduel)
3. Incitations

:::
:::

## 1. Factorial Design | *Conception factorielle*

::: {.columns}
::: {.column .lang-en width="50%"}

- In a factorial design, there are two or more **factors** and each factor has two or more conditions.
- Each unit is assigned to one of the possible combinations of these conditions.

:::
::: {.column .lang-fr width="50%"}

- Dans un plan factoriel, il y a au moins deux **facteurs** et chaque facteur comporte au moins deux conditions.
- Chaque unité est assignée à l'une des combinaisons possibles de ces conditions.

:::
:::

## 1. Factorial Design | *Conception factorielle* {.compact-table}

| | Transport: No | Transport: Yes |
|:--|:--|:--|
| **Information: No** | Neither | Transport only |
| **Information: Yes** | Information only | Information + Transportation |

## 1. Factorial Design | *Conception factorielle* {.compact-table}

| | Transport: No | Transport: Yes |
|:--|:--|:--|
| **Information: No** | Neither | Transport only |
| **Information: Yes** | Information only | Information + Transportation |

::: {.columns}
::: {.column .lang-en width="50%"}

There are many possible treatment effects (comparisons) in a factorial design:

1. Conditional Average Treatment Effect (CATE): the ATE of one factor, for a given level of the other factor.

:::
::: {.column .lang-fr width="50%"}

Il y a plusieurs effets de traitement (comparaisons) dans une conception factorielle :

1. Effet moyen de traitement conditionnel (CATE) : l'effet moyen d'un des facteurs, en maintenant fixe la valeur de l'autre facteur.

:::
:::

## 1. Factorial Design | *Conception factorielle* {.compact-table}

| | Transport: No | Transport: Yes |
|:--|:--|:--|
| **Information: No** | Neither | Transport only |
| **Information: Yes** | Information only | Information + Transportation |

::: {.columns}
::: {.column .lang-en width="50%"}

- There are four possible CATEs in this design.
- One is the CATE of information conditional on having transport. It compares the cell with information + transport to the cell with transport only. We can ignore the first column.

:::
::: {.column .lang-fr width="50%"}

- Il y a 4 CATE possibles dans cette conception.
- L'un d'eux est le CATE de l'information sous la condition d'avoir reçu le transport. Cela compare la cellule avec information + transport à la cellule avec transport seulement. Nous ignorons la première colonne.

:::
:::

## 1. Factorial Design | *Conception factorielle* {.compact-table}

| | Transport: No | Transport: Yes |
|:--|:--|:--|
| **Information: No** | Neither | Transport only |
| **Information: Yes** | Information only | Information + Transportation |

::: {.columns}
::: {.column .lang-en width="50%"}

2. Interaction effect: the ATE of one factor may differ by levels of the other factor. A treatment effect may be larger or smaller depending on the other treatment.

:::
::: {.column .lang-fr width="50%"}

2. Effet d'interaction : l'effet d'un facteur peut dépendre de la condition d'assignation de l'unité à un autre facteur. Un facteur peut amplifier ou réduire l'effet de l'autre.

:::
:::

## 1. Factorial Design | *Conception factorielle* {.compact-table}

| | Transport: No | Transport: Yes |
|:--|:--|:--|
| **Information: No** | Neither | Transport only |
| **Information: Yes** | Information only | Information + Transportation |

::: {.columns}
::: {.column .lang-en width="50%"}

- Does having transport change the effect of information? We compare the CATE of information with transport (from before) to the CATE of information without transport.
- If the 2 CATEs are different, we say there is an interaction effect.

:::
::: {.column .lang-fr width="50%"}

- Est-ce que le transport change l'effet de l'information ? Nous comparons le CATE de l'information avec transport (comme avant) au CATE de l'information sans transport.
- Si les 2 CATE sont différents, on dira qu'il y a un effet d'interaction.

:::
:::

## 1. Factorial Design | *Conception factorielle* {.compact-table}

| | Transport: No | Transport: Yes |
|:--|:--|:--|
| **Information: No** | Neither | Transport only |
| **Information: Yes** | Information only | Information + Transportation |

::: {.columns}
::: {.column .lang-en width="50%"}

3. Average effect of one treatment (given the distribution of the other treatment).

:::
::: {.column .lang-fr width="50%"}

3. Effet moyen d'un traitement (étant donné la distribution de l'autre traitement).

:::
:::

## 1. Factorial Design | *Conception factorielle* {.smaller}

### Design-based analysis

::: {.columns}
::: {.column .lang-en width="50%"}

Main estimands

:::
::: {.column .lang-fr width="50%"}

Paramètres

:::
:::

```{r factorial-estimands-table, echo = FALSE, results = "asis"}
library(kableExtra)

grey <- "#E8E8E8"
blue <- "#DCEEFB"
green <- "#D4EDDA"

factorial_estimands_tab <- data.frame(
  v1 = c("$X_1$", "", "", ""),
  v2 = c("0", "1", "All", "Diff"),
  v3 = c(
    "$\\overline{y}_{00}$", "$\\overline{y}_{10}$", "$\\overline{y}_{.0}$",
    "$\\tau_1 \\mid X_2{=}0$"
  ),
  v4 = c(
    "$\\overline{y}_{01}$", "$\\overline{y}_{11}$", "$\\overline{y}_{.1}$",
    "$\\tau_1 \\mid X_2{=}1$"
  ),
  v5 = c("$\\overline{y}_{0.}$", "$\\overline{y}_{1.}$", "$\\overline{y}$", "$\\tau_1$"),
  v6 = c(
    "$\\tau_2 \\mid X_1{=}0$", "$\\tau_2 \\mid X_1{=}1$", "$\\tau_2$", "$\\tau_{12}$"
  ),
  check.names = FALSE
)

cat(
  factorial_estimands_tab |>
    kable(
      col.names = c("", "", "0", "1", "All", "Diff"),
      escape = FALSE,
      align = "c"
    ) |>
    add_header_above(c(" " = 2, "$X_2$" = 3, " " = 1)) |>
    column_spec(3, background = c(grey, grey, blue, green)) |>
    column_spec(4, background = c(grey, grey, blue, green)) |>
    column_spec(5, background = c(blue, blue, blue, green)) |>
    column_spec(6, background = rep(green, 4)) |>
    kable_styling(full_width = FALSE, font_size = 18, position = "center")
)
```

## 1. Factorial Design | *Conception factorielle*


```{r, echo = TRUE}
library(randomizr)
set.seed(12345)

information <- complete_ra(N = 24, m = 12)
transport <- block_ra(blocks = information)

table(information, transport)
```


## 2. Waitlist design (delayed access) | *Liste d'attente (accès graduel)*

::: {.columns}
::: {.column .lang-en width="50%"}

- Situation: Only a certain number of units can be treated at a time. Once treated, a unit stays in treatment.
- When an intervention can be or must be rolled out in stages, you can randomize the order (*timing*) in which units are treated.

:::
::: {.column .lang-fr width="50%"}

- Situation : seul un certain nombre d'unités peuvent être traitées en même temps. Une fois traitée, une unité reste en traitement.
- Lorsqu'une intervention peut ou doit être déployée par étapes, vous pouvez randomiser l'ordre (*timing*) de traitement des unités.

:::
:::

## 2. Waitlist design (delayed access) | *Liste d'attente (accès graduel)*

![](images/delayed_access.png){width="300px" fig-align="center"}

::: {.columns}
::: {.column .lang-en width="50%"}

- Your control group are the as-yet untreated units.

:::
::: {.column .lang-fr width="50%"}

- Votre groupe de contrôle est constitué des unités pas encore traitées.

:::
:::

## 2. Waitlist design (delayed access) | *Liste d'attente (accès graduel)*

::: {.columns}
::: {.column .lang-en width="50%"}

- We need to assume **no anticipation**.
- This means that the potential outcome is not affected by future treatment status.

:::
::: {.column .lang-fr width="50%"}

- Nous devons faire l'hypothèse d'**aucune anticipation**.
- Cela signifie que le résultat potentiel n'est pas affecté par l'état futur du traitement.

:::
:::

## 2. Waitlist design (delayed access) | *Liste d'attente (accès graduel)*

::: {.columns}
::: {.column .lang-en width="50%"}

- We analyze the data from all time periods together.
- Be careful: the probability of assignment to treatment will vary over time because units assigned to treatment in earlier stages are not eligible for treatment in later stages.

:::
::: {.column .lang-fr width="50%"}

- Nous analysons les données de toutes les périodes ensemble.
- Attention : la probabilité d'assignation au traitement variera dans le temps car les unités assignées au traitement à des stades antérieurs ne sont plus éligibles aux stades ultérieurs.

:::
:::

# 3. Encouragement design | *Conception incitative*

## 3. Encouragement design | *Conception incitative*


```{r, include = FALSE}
library(CausalQueries)
```

::: {.columns}
::: {.column .lang-en width="50%"}

```{r, echo = FALSE}
make_model("Z -> D -> Y <- D") |> 
  plot_model(labels = c("Z (encouragement)", "D (treatment)", "Y (outcome)"),
       nodecol = "white", textcol = "black", textsize = 8)

```
:::
::: {.column .lang-fr width="50%"}


```{r, echo = FALSE}

make_model("Z -> D -> Y <- D") |> 
  plot_model(labels = c("Z (incitation)", "D (traitement)", "Y (résultat)"),
       nodecol = "white", textcol = "black", textsize = 8)



```

:::
:::

## 3. Encouragement design | *Conception incitative*

::: {.columns}
::: {.column .lang-en width="50%"}

- Situation: You can't force people to take (receive) your treatment. Treatment assigned is not the same as treatment received.
- We can randomize **encouragement** $Z$ to take the treatment, such as a request to drink coffee or offering a subsidy to participate in a program.
- We measure the encouragement $Z$, taking the treatment $D$, and the outcome $Y$.

:::
::: {.column .lang-fr width="50%"}

- Situation : vous ne pouvez pas forcer les gens à prendre (recevoir) le traitement. Le traitement assigné n'est pas le même que le traitement reçu.
- Nous pouvons randomiser l'**incitation** $Z$ à suivre le traitement, par exemple en demandant de boire un café ou en offrant une subvention.
- On mesure l'incitation $Z$, le traitement reçu $D$, et le résultat $Y$.

:::
:::

## 3. Encouragement design | *Conception incitative*

::: {.columns}
::: {.column .lang-en width="50%"}

- $D$ is not randomized!
- So it is difficult to learn the ATE of $D$ on $Y$.
- But we may be able to target other estimands.

:::
::: {.column .lang-fr width="50%"}

- $D$ n'est pas randomisé !
- Il est alors difficile d'estimer l'ATE de $D$ sur $Y$.
- Mais nous pouvons peut-être cibler d'autres paramètres.

:::
:::

## 3. Encouragement design | *Conception incitative*

::: {.columns}
::: {.column .lang-en width="50%"}

**Estimand 1:**

- We can learn the average effect of the *encouragement* $Z$ to take the treatment on the outcome $Y$.
- This is the ATE of $Z$, also known as **ITT**, the intent-to-treat effect.

:::
::: {.column .lang-fr width="50%"}

**Paramètre 1 :**

- Nous pouvons estimer l'effet moyen de *l'encouragement* $Z$ à suivre le traitement sur le résultat $Y$.
- C'est l'ATE de $Z$, aussi appelé **ITT**, l'effet de l'intention de traiter.

:::
:::

## 3. Encouragement design | *Conception incitative*

::: {.columns}
::: {.column .lang-en width="50%"}

**Estimand 2:**

- With some additional assumptions, we can also learn the average effect of *taking the treatment* $D$ for Compliers.
- This is known as the Complier Average Causal Effect (CACE) or Local Average Treatment Effect (LATE).

:::
::: {.column .lang-fr width="50%"}

**Paramètre 2 :**

- Avec quelques hypothèses supplémentaires, nous pouvons aussi estimer l'effet moyen de *l'acceptation du traitement* $D$ pour les conformistes.
- C'est l'effet causal moyen du conformiste (CACE) ou l'effet moyen local du traitement (LATE).

:::
:::

## 3. Encouragement design | *Conception incitative*

::: {.columns}
::: {.column .lang-en width="50%"}

- Who are Compliers? They are units that would take the treatment if encouraged ($D(1)=1$) and not if not  ($D(0)=0$).

:::
::: {.column .lang-fr width="50%"}

- Qui sont les conformistes ? Des unités qui prendraient le traitement si encouragées ($D(1)=1$) et pas sinon ($D(0)=0$).

:::
:::

| Type | $Z=1$ | $Z=0$ |
|:--|:--:|:--:|
| Always Taker | $D(1)=1$ | $D(0)=1$ |
| **Complier** | $D(1)=1$ | $D(0)=0$ |
| Never Taker | $D(1)=0$ | $D(0)=0$ |
| Defier | $D(1)=0$ | $D(0)=1$ |




## 3. Encouragement design | *Conception incitative*

::: {.columns}
::: {.column .lang-en width="50%"}

- Additional assumption 1: For CACE, we need **excludability** (exclusion restriction): the encouragement $Z$ only affects the outcome $Y$ through taking the treatment $D$.

:::
::: {.column .lang-fr width="50%"}

- Hypothèse supplémentaire 1 : pour le CACE, nous avons besoin de **l'excluabilité** (restriction d'exclusion) : l'encouragement $Z$ n'affecte $Y$ qu'à travers le traitement $D$.

:::
:::


## 3. Encouragement design | *Conception incitative*

::: {.columns}
::: {.column .lang-en width="50%"}

- Additional assumption 2: For CACE using this design, we also need the assumption of **monotonicity**. This means no Defiers.

:::
::: {.column .lang-fr width="50%"}

- Hypothèse supplémentaire 2 : pour le CACE, nous avons aussi besoin de **monotonicité**. Cela signifie qu'il n'y a pas de non-conformistes.

:::
:::

| Type | $Z=1$ | $Z=0$ |
|:--|:--:|:--:|
| Always Taker | $D(1)=1$ | $D(0)=1$ |
| **Complier** | $D(1)=1$ | $D(0)=0$ |
| Never Taker | $D(1)=0$ | $D(0)=0$ |

## 3. Encouragement design | *Conception incitative*

::: {.columns}
::: {.column .lang-en width="50%"}

- Careful (1)! Do not compare those who take treatment ($D=1$) to those who do not ($D=0$). Taking treatment is not randomly assigned and the two groups are not comparable.

:::
::: {.column .lang-fr width="50%"}

- Attention (1) ! Ne comparez pas les sujets qui prennent le traitement ($D=1$) à ceux qui ne le prennent pas ($D=0$). La prise du traitement n'est pas aléatoire et les deux groupes ne sont pas comparables.

:::
:::

## 3. Encouragement design | *Conception incitative*


```{r, include = FALSE}
library(ggplot2)

encouragement_type_dag <- function(labels) {
  labs <- data.frame(
    x = c(1.1, 4.5, 4.5, 4.5),
    y = c(3.0, 5.0, 3.0, 1.0),
    label = labels
  )

  arrows <- data.frame(
    x = c(4.5, 2.0, 1.6, 4.5),
    y = c(4.55, 3.0, 2.65, 2.45),
    xend = c(4.5, 3.55, 3.85, 4.5),
    yend = c(3.45, 3.0, 1.35, 1.55)
  )

  ggplot() +
    geom_segment(
      data = arrows,
      aes(x = x, y = y, xend = xend, yend = yend),
      arrow = arrow(length = unit(0.15, "cm"), type = "closed"),
      linewidth = 0.45,
      inherit.aes = FALSE
    ) +
    geom_text(
      data = labs,
      aes(x = x, y = y, label = label),
      size = 4.2,
      inherit.aes = FALSE
    ) +
    coord_fixed(ratio = 0.9, xlim = c(0, 6), ylim = c(0, 6), expand = FALSE) +
    theme_void()
}
```

::: {.columns}
::: {.column .lang-en width="50%"}

```{r, echo = FALSE, fig.width = 5, fig.height = 4}
encouragement_type_dag(c("Type", "Z (encouragement)", "D (treatment)", "Y (outcome)"))
```
:::
::: {.column .lang-fr width="50%"}


```{r, echo = FALSE, fig.width = 5, fig.height = 4}
encouragement_type_dag(c("Type", "Z (incitation)", "D (traitement)", "Y (résultat)"))
```

:::
:::


## 3. Encouragement design | *Conception incitative*

::: {.columns}
::: {.column .lang-en width="50%"}

- Careful (2)! For the CACE, we have to assess whether excludability and monotonicity hold in our study.
- If not, we can still target the ITT with the other standard key assumptions.

:::
::: {.column .lang-fr width="50%"}

- Attention (2) ! Il faut évaluer si la restriction d'exclusion et la monotonicité sont raisonnables dans notre étude.
- Sinon, nous pouvons encore cibler l'ITT avec les autres hypothèses clés standardes.

:::
:::

## 3. Encouragement design | *Conception incitative*

::: {.columns}
::: {.column .lang-en width="50%"}

- When would you target ITT? When would you target CACE?
- ITT: Policy can directly change $Z$, but not $D$.
- CACE: We may want to know the effect of $D$ even if it's for just some of the units.

:::
::: {.column .lang-fr width="50%"}

- Quand cibler l'ITT ? Quand cibleriez-vous le CACE ?
- ITT : la politique peut modifier directement $Z$, mais pas $D$.
- CACE : nous pourrions vouloir connaître l'effet de $D$ même si ce n'est que pour certaines unités.

:::
:::

## Summary | *Résumé*

::: {.columns}
::: {.column .lang-en width="50%"}

- Factorial: 2 or more treatments with possible interaction
- Waitlist: when we have a constraint on how many treatments can be delivered at once
- Encouragement: when we can't force units to take the treatment

:::
::: {.column .lang-fr width="50%"}

- Factorielle : 2 traitements ou plus avec interaction possible
- Liste d'attente : contrainte sur le nombre de traitements délivrés à la fois
- Incitation : quand on ne peut pas obliger les unités à recevoir le traitement

:::
:::

## Resources | *Ressources*

::: {.columns}
::: {.column .lang-en width="50%"}

EGAP Methods Guide on Randomization: <https://egap.org/resource/10-things-to-know-about-randomization/>

:::
::: {.column .lang-fr width="50%"}

Guide des méthodes EGAP sur la randomisation : <https://egap.org/fr/resource/10-choses-a-savoir-sur-la-randomisation/>

:::
:::
