# Chapter 21: Inference, Robust Standard Errors, and Diagnostics
# Fundamentals of Python for Financial Econometrics - Inference, Robust Standard Errors, and Diagnostics
# Dataset: Ceteris Lab teaching sample

# Chapter 21: Inference, Robust Standard Errors, and Diagnostics
# **Economic question:** How certain should we be about an estimated coefficient?
#
# A coefficient estimate without a defensible uncertainty estimate is only half an empirical result.

# %% Cell 2
import numpy as np, statsmodels.api as sm
rng=np.random.default_rng(21)
x=np.linspace(0,10,300)
y=2+.8*x+rng.normal(0,.3+.35*x,300)
ols=sm.OLS(y,sm.add_constant(x)).fit()
robust=ols.get_robustcov_results(cov_type='HC3')
print('classical SE',ols.bse[1],'HC3 SE',robust.bse[1])

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