Get startedGet started for free

Stratifying an experiment

You are working with a government organization that wants to undertake an experiment around how some particular government policies impact the net wealth of individuals in a number of areas.

They have approached you to help set up the experimental design. They have warned you that there is likely to be a small group of users who already have high net wealth and are concerned that this group might overshadow any experimental outcome observed. You know just what to do!

Use your knowledge of experimental design to undertake block randomization, stratifying by the high_wealth column in the provided wealth_data DataFrame. There are 2000 rows in the DataFrame with 200 high net wealth subjects (high_wealth is 1).

This exercise is part of the course

Experimental Design in Python

View Course

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# Create the first block
strata_1 = wealth_data[wealth_data[____] == ____]
strata_1['Block'] = ____

# Create two groups assigning to Treatment or Control
strata_1_g1 = strata_1.____(____, replace=False)
strata_1_g1['T_C'] = ____
strata_1_g2 = strata_1.drop(strata_1_g1.index)
strata_1_g2[____] = 'C'
Edit and Run Code