Random Assignment Subject to Constraints

Alexander Coppock, Yale University

6/18/2017

Most random assignment schemes can be handled by the randomizr package for R as a variant of simple, complete, clustered, or blocked random assignment. However, some assignment schemes can’t be expressed as one (or even a combination) of these. In this document, I show how one such scheme can be expressed as a linear programming problem. I am grateful to Robin, a student in my 2016 Field Experiments course for stumping me on a random assignment protocol, her friend Kat who figured it out in Excel (shudder) using solver, and to this Stack Overflow answer (https://stackoverflow.com/a/35805005/4172083) for inspiration.

Standard Random Assignment Procedures

Most random assignment schemes can be expressed as either simple or complete:

The Problem

Imagine a dataset of 80 fingers on 16 hands belonging to 8 people. Our goal is assign 40 fingers to treatment and 40 to control. We want to treat exactly half the thumbs, indexes, etc. We also want to treat exactly 5 fingers for each person. And we want each hand to have two or three treated fingers.

At first this seems like a blocking problem. With blocked random assignment, we conduct complete random assignment within each block. But if we create blocks of person-hand-finger, we have 80 unique blocks of size 1. If we create person-finger blocks, we have 40 unique blocks, but we have no guarantee that each hand will have either two or three treated fingers.

What we need to do is to impose a series of constraints and let the lpSolve package for R solve the linear programming problem.

The Solution

First, let’s make a dataset that corresponds to an 8-person version of the experiment:

Conclusion

The reason we need this procedure is that in a setup like this one, each “subject” is a unique snowflake - Person 1 only has one left pinky, one right index, etc. If she had two left pinkies, then we could block on person_hand_finger, and randomly assign exactly one to treatment every time. In the absence of multiple left pinkies per person, we want to assign either the left or the right pinky to treatment. But we also want to ensure that exactly half of the left pinkies are assigned to treatment. These complex and overlapping constraints mean that we have to abandon the standard blocking paradigm. Instead, we can express the problem as a linear programming optimization scheme where the stochasticity comes from the random “utility” in the objective function.