# Chapter 26: Censoring, Selection, Quantiles, and Robust Methods
# Fundamentals of Python for Financial Econometrics - Censoring, Selection, Quantiles, and Robust Methods
# Dataset: Ceteris Lab teaching sample

# Chapter 26: Censoring, Selection, Quantiles, and Robust Methods
# **Economic question:** What if the mean is not the whole story, or part of the outcome is unobserved?
#
# Quantile regression asks how covariates relate to different points of the conditional outcome distribution, not just its mean.

# %% Cell 2
import numpy as np, statsmodels.api as sm
rng=np.random.default_rng(26); x=rng.uniform(0,10,500); y=2+.7*x+rng.standard_t(3,500)*(1+.2*x)
X=sm.add_constant(x)
for q in [.25,.5,.75]:
    fit=sm.QuantReg(y,X).fit(q=q)
    print(q, 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.
