{"schemaVersion":2,"courseId":"iv2sls","module":{"id":"iv2sls-why-ols-fails","title":"1 · Why OLS fails","summary":"Endogeneity from omitted variables and simultaneity makes OLS biased and inconsistent.","stages":[{"type":"read","title":"The exogeneity assumption","html":"<h2>What OLS quietly assumes</h2><p>Write the model as</p><p class=\"katexish\">y = β₀ + β₁·x + ε</p><p>OLS gives a consistent, unbiased estimate of β₁ <strong>only if the regressor is exogenous</strong>: the error term ε must be uncorrelated with x, written <code>Cov(x, ε) = 0</code>. Intuitively, everything we left out of the model (bundled into ε) must not move together with x.</p><p>When instead <code>Cov(x, ε) ≠ 0</code> we say x is <em>endogenous</em>. OLS then attributes to x variation that really belongs to ε, and β̂₁ is pulled away from the truth.</p><div class=\"callout\"><b>Key idea.</b> OLS regresses y on <em>all</em> the comovement between x and y. If part of that comovement runs through ε, OLS cannot tell the causal part from the contaminated part — and the bias does <em>not</em> shrink as n → ∞.</div><h3>Two classic ways endogeneity arises</h3><ul><li><strong>Omitted variables.</strong> A confounder u drives both x and y. Leaving u out dumps it into ε, so x and ε share u.</li><li><strong>Simultaneity / reverse causality.</strong> y also feeds back into x (price ↔ quantity, police ↔ crime), so x responds to the same shocks as y.</li></ul>","id":"iv2sls-why-ols-fails-01","skillIds":["iv2sls.endogeneity"],"estimatedMinutes":6,"difficulty":"applied","prerequisiteStageIds":[]},{"type":"read","title":"The sign and size of the bias","html":"<h2>How big is the OLS bias?</h2><p>Suppose the true structural model has a confounder u that we cannot observe:</p><p class=\"katexish\">x = π·u + v,  y = β₀ + β₁·x + γ·u + η</p><p>Because u appears in both equations, x carries information about u, and u sits inside the regression error ε = γ·u + η. The asymptotic OLS bias is</p><p class=\"katexish\">plim β̂₁ = β₁ + γ · Cov(x,u)/Var(x)</p><p>So the bias has the <strong>sign of γ·π</strong> (the product of how u affects y and how u affects x). If both effects are positive, OLS <em>over</em>states β₁; if they have opposite signs it <em>under</em>states it.</p><div class=\"callout\"><b>Key idea.</b> More data sharpens a <em>wrong</em> answer: the standard error shrinks around a biased point. Precision is not the same as correctness.</div><p>This is why we need a new strategy. We cannot fix endogeneity by collecting more rows — we need <em>extra information</em> in the form of an instrument, the subject of Module 2.</p>","id":"iv2sls-why-ols-fails-02","skillIds":["iv2sls.instrument-relevance"],"estimatedMinutes":6,"difficulty":"applied","prerequisiteStageIds":["iv2sls-why-ols-fails-01"]},{"type":"code","title":"Watch OLS miss the truth","note":"True β₁ = 2. A hidden confounder u raises both x and y, so OLS overshoots — and tightening n does not help.","code":"import numpy as np, statsmodels.api as sm, matplotlib.pyplot as plt\nrng = np.random.default_rng(0)\n\ndef ols_slope(n):\n    u = rng.normal(0,1,n)                # hidden confounder\n    x = 1.0*u + rng.normal(0,1,n)        # u drives x\n    y = 1 + 2*x + 3*u + rng.normal(0,1,n)# u also drives y (true beta1=2)\n    return sm.OLS(y, sm.add_constant(x)).fit().params[1]\n\nns = [50,100,200,500,1000,2000]\nest = [ols_slope(n) for n in ns]\nfor n,b in zip(ns,est):\n    print(f'n={n:5d}   OLS beta1_hat = {b:.3f}   (true = 2.000)')\n\nplt.figure(figsize=(6,3.7))\nplt.axhline(2,color='#c9c6ac',ls='--',lw=2,label='true beta1 = 2')\nplt.plot(ns,est,'o-',color='#da9100',lw=2,label='OLS estimate')\nplt.xlabel('sample size n'); plt.ylabel('beta1_hat')\nplt.title(f'OLS converges to {est[-1]:.2f}, not 2  (inconsistent)')\nplt.legend()","id":"iv2sls-why-ols-fails-03","skillIds":["iv2sls.endogeneity"],"estimatedMinutes":10,"difficulty":"applied","prerequisiteStageIds":["iv2sls-why-ols-fails-02"]},{"type":"interactive","title":"Confounding slider","note":"γ controls how strongly the hidden u also pushes y. At γ = 0 there is no confounding and OLS is fine; crank it up and the estimate drifts away from the true 2.","params":[{"name":"gamma","label":"Confounder strength γ (effect of u on y)","min":-4,"max":4,"step":0.25,"value":3}],"template":"import numpy as np, statsmodels.api as sm, matplotlib.pyplot as plt\nrng = np.random.default_rng(0); n=800\nu = rng.normal(0,1,n)\nx = 1.0*u + rng.normal(0,1,n)\ny = 1 + 2*x + {{gamma}}*u + rng.normal(0,1,n)\nres = sm.OLS(y, sm.add_constant(x)).fit()\nb = res.params[1]\nplt.figure(figsize=(6,3.7))\nplt.scatter(x,y,s=10,color='#da9100',alpha=.4)\nxs=np.linspace(x.min(),x.max(),50)\nplt.plot(xs,res.params[0]+b*xs,color='#c9c6ac',lw=2,label='OLS fit')\nplt.plot(xs,res.params[0]+2*xs,color='#af983f',lw=2,ls='--',label='true slope=2')\nplt.legend(); plt.title(f'gamma={{gamma}}  ->  OLS beta1_hat = {b:.2f}  (bias {b-2:+.2f})')","id":"iv2sls-why-ols-fails-04","skillIds":["iv2sls.instrument-relevance"],"estimatedMinutes":8,"difficulty":"applied","prerequisiteStageIds":["iv2sls-why-ols-fails-03"]},{"type":"quiz","title":"Check: source of the bias","prompt":"An unobserved variable raises both schooling x and wages y. We regress wages on schooling by OLS. What happens as the sample grows very large?","choices":["The estimate converges to the true return to schooling","The estimate stays biased; only its standard error shrinks","The bias grows without bound","OLS becomes unbiased once n > 1000"],"answer":1,"hint":"Endogeneity is about consistency, not sampling noise.","explain":"Omitted-variable bias does not vanish with n. The point estimate converges to a wrong number while its SE shrinks around that wrong number — precise but inconsistent.","id":"iv2sls-why-ols-fails-05","skillIds":["iv2sls.endogeneity"],"estimatedMinutes":5,"difficulty":"applied","prerequisiteStageIds":["iv2sls-why-ols-fails-04"],"variantId":"iv2sls-why-ols-fails-05-core"},{"type":"quiz","title":"Check: sign of the bias","prompt":"In x = π·u + v and y = β₁·x + γ·u + η, suppose γ > 0 and π > 0. OLS will tend to…","choices":["overstate β₁","understate β₁","estimate β₁ exactly","give a negative β̂₁ regardless"],"answer":0,"hint":"The asymptotic bias has the sign of γ·π.","explain":"With γ·π > 0 the omitted u creates positive comovement between x and the error, so OLS attributes extra positive slope to x and overstates β₁.","id":"iv2sls-why-ols-fails-06","skillIds":["iv2sls.instrument-relevance"],"estimatedMinutes":5,"difficulty":"applied","prerequisiteStageIds":["iv2sls-why-ols-fails-05"],"variantId":"iv2sls-why-ols-fails-06-core"}]}}
