Skip to content
DeepForgeby svx
All problems
HardStatisticsst-309

Placebo Test p-Value (Exact)

Problem

Return the exact two-sided placebo test p-value for a pre-period difference in means. Enumerate all C(n, n1) assignments of the n1 treated labels and report the fraction whose absolute mean difference is at least as large as the observed one. Return 1.0 when input is empty, lengths differ, or all units share one treatment value.

Hint

A significant placebo p-value means the pre-period groups already differed.

Test cases

case 1
in: [[1,2,3,4,5,6],[1,1,1,0,0,0]]
expected: 0.1
case 2
in: [[1,2,3,4,5,6,7,8],[1,1,0,0,0,0,0,0]]
expected: 0.07142857142857142
case 3
in: [[1,1,1,1],[1,1,0,0]]
expected: 1
case 4
in: [[1,2],[1,1]]
expected: 1
case 5
in: [[],[]]
expected: 1
Starter codePython
import itertools
def placebo_p_value(pre_outcomes, treatment):
    # Your code here
    pass

5 test cases · run your code against them in the editor