# Chapter 20: Functional Forms, Dummy Variables, and Interactions
# Fundamentals of Python for Financial Econometrics - Functional Forms, Dummy Variables, and Interactions
# Dataset: Ceteris Lab teaching sample

# Chapter 20: Functional Forms, Dummy Variables, and Interactions
# **Economic question:** When is a one-unit change not the right way to describe an economic relationship?
#
# Functional form determines what a coefficient means, so interpretation must match the transformation.

# %% Cell 2
import numpy as np, pandas as pd, statsmodels.formula.api as smf
rng=np.random.default_rng(20)
n=300
experience=rng.uniform(0,10,n); group=rng.integers(0,2,n)
wage=20+2*experience+5*group+1.2*experience*group+rng.normal(0,3,n)
df=pd.DataFrame({'wage':wage,'experience':experience,'group':group})
print(smf.ols('wage ~ experience * group',data=df).fit().summary())

# 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.
