# Different Slopes and Centering
# Module 7 - Binary by Continuous Interactions
# Dataset: MODULE7_WAGE_GROUPS_SYNTHETIC

# Different Slopes and Centering
#
# Module 7 notebook lab. This notebook uses an original Ceteris Lab synthetic teaching dataset and does not report real empirical findings.

# Learning goal
# Estimate group-specific slopes and show how centering changes the reference point.
#
# Dataset: MODULE7_WAGE_GROUPS_SYNTHETIC. Variables: hourly_wage, female, education, experience.

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

df = pd.read_csv("/data/module-7/module7_wage_groups_synthetic.csv")
df["educ_centered"] = df["education"] - df["education"].mean()
df["female_educ_centered"] = df["female"] * df["educ_centered"]
model = sm.OLS(df["hourly_wage"], sm.add_constant(df[["female", "educ_centered", "female_educ_centered", "experience"]])).fit()
print(model.params.round(3))

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