# Chapter 22: Omitted Variables, Measurement Error, Simultaneity, and Endogeneity
# Fundamentals of Python for Financial Econometrics - Omitted Variables, Measurement Error, Simultaneity, and Endogeneity
# Dataset: Ceteris Lab teaching sample

# Chapter 22: Omitted Variables, Measurement Error, Simultaneity, and Endogeneity
# **Economic question:** Why can a beautifully estimated regression still answer the wrong question?
#
# Endogeneity means the regressor is statistically connected to the structural error, threatening causal interpretation.

# %% Cell 2
import numpy as np, statsmodels.api as sm
rng=np.random.default_rng(22)
z=rng.normal(size=400); v=rng.normal(size=400)
x=.8*z+v; e=.7*v+rng.normal(size=400); y=1+1.5*x+e
print(sm.OLS(y,sm.add_constant(x)).fit().params)

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