# Chapter 18: Simple Linear Regression
# Fundamentals of Python for Financial Econometrics - Simple Linear Regression
# Dataset: Ceteris Lab teaching sample

# Chapter 18: Simple Linear Regression
# **Economic question:** How does consumption change with income in a simple model?
#
# OLS chooses the line that minimizes the sum of squared residuals.

# %% Cell 2
import numpy as np
import statsmodels.api as sm
rng=np.random.default_rng(18)
income=np.linspace(20,100,120)
cons=8+0.55*income+rng.normal(0,8,120)
res=sm.OLS(cons,sm.add_constant(income)).fit()
print(res.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.
