# Policy Evaluation and Self-Selection
# Module 7 - Policy Evaluation and Self-Selection
# Dataset: MODULE7_PROGRAM_EVALUATION_SYNTHETIC

# Policy Evaluation and Self-Selection
#
# Module 7 notebook lab. This notebook uses an original Ceteris Lab synthetic teaching dataset and does not report real empirical findings.

# Learning goal
# Compare randomized and self-selected treatment comparisons.
#
# Dataset: MODULE7_PROGRAM_EVALUATION_SYNTHETIC. Variables: treatment, outcome, baseline_score, motivation_score.

# %% Cell 3
import pandas as pd
import statsmodels.api as sm

df = pd.read_csv("/data/module-7/module7_program_evaluation_synthetic.csv")
randomized = df[df["random_assignment"] == 1]
self_selected = df[df["self_selected"] == 1]
for name, sample in [("random assignment sample", randomized), ("self-selected participants", self_selected)]:
    model = sm.OLS(sample["outcome"], sm.add_constant(sample[["treatment", "baseline_score"]])).fit()
    print(name, round(model.params["treatment"], 3))

# Reflection
# Write two sentences: one coefficient, group difference, or predicted-probability interpretation, and one limitation or coding choice that matters.
