# Chapter 27: Potential Outcomes and Randomized Experiments
# Fundamentals of Python for Financial Econometrics - Potential Outcomes and Randomized Experiments
# Dataset: Ceteris Lab teaching sample

# Chapter 27: Potential Outcomes and Randomized Experiments
# **Economic question:** What does a causal effect mean for one unit, and why can we never observe both potential outcomes?
#
# A causal effect compares two potential outcomes for the same unit, but only one is observed.

# %% Cell 2
import numpy as np
rng=np.random.default_rng(27); n=2000; treatment=rng.binomial(1,.5,n); y0=rng.normal(50,10,n); y=y0+5*treatment+rng.normal(0,3,n)
ate=y[treatment==1].mean()-y[treatment==0].mean()
print('difference in means',ate)

# Interpretation checklist
# - State the unit of observation and units of every variable.
# - Separate association, prediction, and causation.
# - Report magnitude and uncertainty.
# - Identify the most important threat to validity.
