Skip to content

Instantly share code, notes, and snippets.

@stasSajin
Created June 26, 2020 03:24
Show Gist options
  • Save stasSajin/cf9dacd5dac9a2e3b4ada986e6c1c180 to your computer and use it in GitHub Desktop.
Save stasSajin/cf9dacd5dac9a2e3b4ada986e6c1c180 to your computer and use it in GitHub Desktop.
def estimate_cuped(df):
# estimate the theta that minimizes the control variate
theta = df.cov().loc["income", "minutes"] / df.cov().loc["income", "income"]
y_new = df.minutes - theta * df.income
return y_new[df[group == 1]].mean() - y_new[df[group == 0]].mean()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment