# Sequential Blocking

Sequential blocking can improve the precision of experiments by balancing treatment assignment across covariates known to affect the outcome of interest even when observations arrive sequentially and the covariate distributions of the sample are unknown or only known imprecisely.

ExperimentPilot supports sequential blocking on categorical and continuous covariates and mixtures thereof. For overviews of sequential blocking, see e.g.,  and .

## Discrete Covariates

ExperimentPilot offers two blocking methods for discrete covariates, exact blocking and minimization blocking. See  for an in-depth description of both approaches.

### Exact Blocking

Exact blocking only uses information from previous units with the same covariate profile as the current unit. Let $$q$$ be the current unit to be assigned treatment and let its covariate profile be given by $$\boldsymbol{x}_q$$. Denote by $$T(r)$$ the assigned treatment group of a previous unit $$r$$ with covariate profile $$\boldsymbol{x}_r$$. Then, define $$n_t=|\{r|\boldsymbol{x}_r=\boldsymbol{x}_r \text{ and } T(r)=t\}|$$, i.e. the number of previous units with the same covariate profile as $$q$$ assigned to treatment group $$t$$. Then, the current unit is assigned to the group with the minimum number of previous units. That is, $$Pr(T=t)=\frac{1}{|\{t|n_{t}=\min_t\{n_t\}\}|}, \text{ if } n_t=\min_t\{n_t\}$$ and $$Pr(T=t)=0$$ otherwise.

Probabilistic Option: Instead of assigning the current unit to the group with the least units with certainty, ExperimentPilot also allows a probabilistic or "biased coin" design. This alternative assignment procedure is given by $$Pr(T=t)=\frac{1-\frac{n_t}{\sum_t n_t}}{\sum_t 1-\frac{n_t}{\sum_t n_t}}.$$ If all covariates are discrete and blocked exactly, probabilistic assignment can be enabled by checking the probabilistic checkbox.

### Minimization Blocking

Instead of only considering information from previous units with the same covariate profile, minimization blocking uses information from units matching the current unit on at least one covariate. Define by $$n_{jt}=|\{r|\boldsymbol{x}^j_r=\boldsymbol{x}^j_r \text{ and } T(r)=t\}|$$ the number of previous units that match the current unit on the $$j$$-th covariate and are assigned to group $$t$$. Then, the imbalance on covariate $$j$$ for group $$t$$ is given by $$s_{jt}=\frac{n_{jt}}{\sum_t n_{jt}}$$. Summing up across covariates, we obtain the aggregate imbalance as $$S_t=\sum_j s_{jt}$$. Assignment probabilities for the current unit are then given by $$Pr(T=t)=\frac{1-\frac{S_t}{\sum_t S_t}}{\sum_t 1-\frac{S_t}{\sum_t S_t}}.$$

## Continuous Covariates

For continuous covariates, ExperimentPilot implements the distance blocking method, as described in . For two units $$q$$ and $$r$$, with covariate profiles $$\boldsymbol{x}_q$$ and $$\boldsymbol{x}_r$$, we measure their similarity using the Mahalanobis distance: $$MD_{qr}=\sqrt{(\boldsymbol{x}_q-\boldsymbol{x}_r)'\Sigma^{-1}(\boldsymbol{x}_q-\boldsymbol{x}_r)}$$.

Let $$q$$ be the current unit, then the aggregated similarity score for group $$t$$ is given by $$\overline{MD}_{qt}=Median(\{MD_{qr}|T(r)=t\})$$. Using this score, the assignment probability of the current unit to $$t$$ is then given by $$Pr(T=t)=\frac{\overline{MD}_{qt}}{\sum_t \overline{MD}_{qt}}.$$

## Mixed Covariate Types

ExperimentPilot allows blocking on discrete and continuous covariates simultaneously. Let $$P_{dt}$$ be the assignment probability to treatment group $$t$$ of the current unit computed from all discrete covariates based on the minimization procedure and let $$P_{ct}$$ be the assignment probability to $$t$$ for the current unit computed from all continuous covariates. Then, the assignment probability to $$t$$ of the current unit for discrete and continuous covariates jointly is given by $$Pr(T=t)=\frac{P_{dt}+P_{ct}}{\sum_t P_{dt}+P_{ct}}.$$

## References

 Cavaille, C. (2019), Implementing Blocked Randomization in Online Survey Experiments, Methodological Note.
 Moore, R., & Moore, S. (2017). Blocking for Sequential Political Experiments. Political Analysis, 21(4), 507-523.