# Chapter 25: Binary, Ordered, and Count Outcomes
# Fundamentals of Python for Financial Econometrics - Binary, Ordered, and Count Outcomes
# Dataset: Ceteris Lab teaching sample

# Chapter 25: Binary, Ordered, and Count Outcomes
# **Economic question:** How should we model outcomes that are probabilities, categories, or event counts?
#
# When the dependent variable is discrete, the conditional mean is constrained and interpretation shifts from slopes to probabilities or expected counts.

# %% Cell 2
import numpy as np, statsmodels.api as sm
rng=np.random.default_rng(25); x=rng.normal(size=800); p=1/(1+np.exp(-(-.5+1.2*x))); y=rng.binomial(1,p)
fit=sm.Logit(y,sm.add_constant(x)).fit(disp=False)
print(fit.params); print(fit.get_margeff().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.
