-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathChapter5_v1.tex
More file actions
2086 lines (1548 loc) · 63.6 KB
/
Copy pathChapter5_v1.tex
File metadata and controls
2086 lines (1548 loc) · 63.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
\ifdefined\ishandout
\documentclass[11pt,english,handout]{beamer}
\else
\documentclass[11pt,english]{beamer}
\fi
%\documentclass[11pt]{beamer}
\usepackage{mathptmx}
\renewcommand{\sfdefault}{lmss}
\renewcommand{\familydefault}{\sfdefault}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{xcolor,multirow,colortbl}
\PassOptionsToPackage{normalem}{ulem}
\usepackage{ulem}
\usepackage{caption}
\captionsetup{labelformat=empty}
\usepackage{bbm}
\usepackage{upgreek}
\usepackage{graphicx}
\setbeamertemplate{section in toc}[sections numbered]
\makeatletter
\usepackage{caption}
\usepackage{bm}
\usepackage{subfig}
\captionsetup[table]{skip=10pt}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Textclass specific LaTeX commands.
% this default might be overridden by plain title style
\newcommand\makebeamertitle{\frame{\maketitle}}%
% (ERT) argument for the TOC
\AtBeginDocument{%
\let\origtableofcontents=\tableofcontents
\def\tableofcontents{\@ifnextchar[{\origtableofcontents}{\gobbletableofcontents}}
\def\gobbletableofcontents#1{\origtableofcontents}
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands.
%\documentclass[presentation]{beamer}
\def\Tiny{\fontsize{7pt}{8pt}\selectfont}
\def\Normal{\fontsize{8pt}{10pt}\selectfont}
\usetheme{Madrid}
\usecolortheme{lily}
%\setbeamercovered{transparent}
\useinnertheme{rounded}
\setbeamertemplate{footline}{\hfill\Normal{\insertframenumber/\inserttotalframenumber}}
%\setbeamertemplate{footline}{}
\setbeamertemplate{navigation symbols}{}
\newenvironment{changemargin}[2]{%
\begin{list}{}{%
\setlength{\topsep}{0pt}%
\setlength{\leftmargin}{#1}%
\setlength{\rightmargin}{#2}%
\setlength{\listparindent}{\parindent}%
\setlength{\itemindent}{\parindent}%
\setlength{\parsep}{\parskip}%
}%
\item[]}{\end{list}}
\setbeamertemplate{footline}{\hfill\insertframenumber/\inserttotalframenumber}
\setbeamertemplate{navigation symbols}{}
%\usepackage{times} % fonts are up to you
\usepackage{graphicx}
%\usepackage{graphics}
\usepackage{epsfig}
\usepackage{bm}
\usepackage{epsf}
\usepackage{float}
\usepackage[final]{pdfpages}
\usepackage{multirow}
\usepackage{colortbl}
\usepackage{xkeyval}
%\usepackage{sgame}
%\usepackage{pst-node}
\usepackage{listings}
\usepackage{ifthen}
%\usepackage{hyperref}
\usepackage{tikz}
%\usepackage{times} % fonts are up to you
%\usepackage{graphicx}
%\usepackage{graphics}
\usepackage{epsfig,bm,epsf,float}
\usepackage[final]{pdfpages}
\usepackage{xcolor,multirow,colortbl}
\usepackage{xkeyval}
\usepackage{verbatim}
%\usepackage{sgame}
%\usepackage{pst-node}
\usepackage{listings}
%\usepackage{handoutWithNotes}
%\pgfpagesuselayout{3 on 1 with notes}[letterpaper,border shrink=5mm]
%\pgfpagesuselayout{2 on 1 with notes landscape}[letterpaper,border shrink=5mm]
\usepackage{setspace}
\usepackage{ragged2e}
\setbeamersize{text margin left=1em,text margin right=1em} % CambridgeUS spacing if you use default instead
%\pdfmapfile{+sansmathaccent.map}
% Table formatting
\usepackage{booktabs}
% Decimal align
\usepackage{dcolumn}
\newcolumntype{d}[0]{D{.}{.}{5}}
\global\long\def\expec#1{\mathbb{E}\left[#1\right]}
\global\long\def\var#1{\mathrm{Var}\left[#1\right]}
\global\long\def\cov#1{\mathrm{Cov}\left[#1\right]}
\global\long\def\prob#1{\mathrm{Prob}\left[#1\right]}
\global\long\def\one{\mathbf{1}}
\global\long\def\diag{\operatorname{diag}}
\global\long\def\expe#1#2{\mathbb{E}_{#1}\left[#2\right]}
\DeclareMathOperator*{\plim}{\text{plim}}
%\usefonttheme[onlymath]{serif}
\usepackage{appendixnumberbeamer}
\renewcommand{\thefootnote}{}
\setbeamertemplate{footline}
{
\leavevmode%
% \hbox{%
% \begin{beamercolorbox}[wd=\paperwidth,ht=2.25ex,dp=1ex,right]{date in head/foot}%
%\usebeamerfont{date in head/foot}\insertshortdate{}\hspace*{2em}%
\hfill
%turning the next line into a comment, erases the frame numbers
\insertframenumber{}\hspace*{2ex}\vspace{1ex}
% \end{beamercolorbox}}%
}
\definecolor{blue}{RGB}{0, 0, 210}
\definecolor{red}{RGB}{170, 0, 0}
\makeatother
\usepackage[english]{babel}
\usepackage{tikz}
\newcommand*\circled[1]{\tikz[baseline=(char.base)]{ \node[circle,ball color=structure.fg, shade, color=white,inner sep=1.2pt] (char) {\tiny #1};}}
\makeatletter
\let\save@measuring@true\measuring@true
\def\measuring@true{%
\save@measuring@true
\def\beamer@sortzero##1{\beamer@ifnextcharospec{\beamer@sortzeroread{##1}}{}}%
\def\beamer@sortzeroread##1<##2>{}%
\def\beamer@finalnospec{}%
}
\makeatother
\definecolor{amethyst}{rgb}{0.6, 0.4, 0.8}
\setbeamersize{text margin left= .8em,text margin right=1em}
\newenvironment{wideitemize}{\itemize\addtolength{\itemsep}{10pt}}{\enditemize}
\newenvironment{wideitemizeshort}{\itemize}{\enditemize}
\newcommand{\indep}{\perp\!\!\!\!\perp}
\DeclareMathOperator*{\argmax}{arg\,max}
\DeclareMathOperator*{\argmin}{arg\,min}
\begin{document}
%% Title slide
\begin{frame}[noframenumbering]{}
\vspace{0.5cm}
\title[]{Chapter 5: Multivariate Regression}
\author{Jonathan Roth}
\date{Mathematical Econometrics I \\ Brown University\\}
\titlepage {\small{}\ }\thispagestyle{empty} \vspace{-30pt}
\end{frame}
\begin{frame}{Outline}
1. Deriving Multivariate Regression and OLS
\vspace{0.8cm}
2. Regression and Causality
\vspace{0.8cm}
3. Regression Odds and Ends
\end{frame}
\begin{frame}{Moving Beyond One ``Regressor''}
\begin{wideitemize}
\item
So far we've talked about regression as a way of approximating the CEF $E[Y_i|X_i =x ] \approx \alpha + x \beta $ for a single scalar $X_i$\smallskip
\begin{itemize}
\item
We then showed how the estimand ($\alpha$,$\beta$) can be estimated by OLS
\end{itemize}
\pause
\item
Next we'll see how this can be generalized to approximate/estimate $E[Y_i| \mathbf{X}_i =\mathbf{x} ] \approx \mathbf{x}' \bm{\beta}$ for a vector $ \mathbf{X_i} = (1,X_{i1},...,X_{iK})'$
\begin{itemize}\smallskip
\item
Note: As usual, I'll be putting vectors/matrices in bold type-face
\end{itemize}
\pause
\item
Two main motivations for this: \medskip
\end{wideitemize}
\pause
\begin{enumerate}
\item
We want to use regression to identify causal effects, but conditional unconfoundedness is only plausible with multiple controls \smallskip
\begin{itemize}
\item
In the Brown/URI example, we may want to control for high school GPA, family income, SAT, race ...
\end{itemize}
\medskip
\pause
\item
We want a \emph{nonlinear} CEF approx.: e.g. $E[Y_i\mid X_i]\approx\alpha+X_i\beta+X_i^2\gamma$ \smallskip
\begin{itemize}
\item We can ``trick`` regression into doing this by setting $\mathbf{X_i} = (1, X_{i}, X_{i}^2)'$
\end{itemize}
\end{enumerate}
\end{frame}
\begin{frame}{Log Wages by Age}
\centering
\includegraphics[width = 0.8 \linewidth]{logwages}
\end{frame}
\begin{frame}{OLS Regression (Linear Fit)}
\centering
\includegraphics[width = 0.8 \linewidth]{logwages-linear}
\end{frame}
\begin{frame}{OLS Regression (Quadratic Fit)}
\centering
\includegraphics[width = 0.8 \linewidth]{logwages-quadratic}
\end{frame}
\begin{frame}{Multivariate Regression as a Least-Squares Problem}
\begin{wideitemize}
\item
Recall with univariate OLS we solved for
$$(\alpha, \beta) = \argmin_{a,b} E[ (Y_i - (a + b X_i))^2 ] $$
We showed if the CEF is linear, then $E[Y|X] = \alpha + \beta X$; while if not, $\alpha + \beta X$ gave the best non-linear approximation
\pause
\item
We will now consider the multi-variate analog:
\begin{align*}
\boldsymbol\beta= \arg \min_{\mathbf{b}} E\left[(Y_i-\mathbf{X}_i^\prime\boldsymbol b)^2\right]
\end{align*}
\item
Using similar steps for the univariate case, we can show that if the CEF is linear in $\mathbf{X}$, then $E[Y| \mathbf{X}] = \mathbf{X}'\boldsymbol{\beta}$; if not, then $\mathbf{X}'\boldsymbol{\beta}$ is the MSE-minimizing approximation to the CEF.
\end{wideitemize}
\end{frame}
% \begin{frame}{Multivariate Regression as a CEF Approximation}
%\vspace{0.1cm}
% \begin{wideitemize}
% \item
% As before, let's consider the mean-squared error (MSE) minimizing linear approximation to the true CEF, $\mu(\mathbf{x})=E[Y_i\mid\mathbf{X}_i=\mathbf{x}]$:
%\begin{align*}
%\boldsymbol\beta= \arg \min_{\mathbf{b}} E\left[(\mu(\mathbf{X}_i)-\mathbf{X}_i^\prime\boldsymbol b)^2\right]
%\end{align*}
%
%\pause{}\vspace{-0.4cm}
%
% \item How do we solve this without knowing $\mu(\mathbf{x})$? \pause{} As before, we can show
%\begin{align*}
%\boldsymbol\beta= \arg \min_{\mathbf{b}} E\left[(Y_i-\mathbf{X}_i^\prime\boldsymbol b)^2\right]
%\end{align*}
%
%And then take FOC to solve for $\boldsymbol{\beta}$\pause{}\smallskip
%\item Proof for this equivalence again follows by LIE-ing:
%\begin{align*}
%E\left[(Y_i-\mathbf{X}_i^\prime\boldsymbol b)^2\right]=&E\left[((\mu(\mathbf{X}_i)-\mathbf{X}_i^\prime\boldsymbol b) + (Y_i- \mu(\mathbf{X}_i)))^2\right]\\
%\pause{}
%=&E\left[(\mu(\mathbf{X}_i)-\mathbf{X}_i^\prime\boldsymbol b)^2\right]+\underbrace{E\left[(Y_i- \mu(\mathbf{X}_i))^2\right]}_{\text{Doesn't depend on $\mathbf{b}$}}\\
%&+2 \underbrace{E\left[(\mu(\mathbf{X}_i)-\mathbf{X}_i^\prime\boldsymbol b)(Y_i- \mu(\mathbf{X}_i))\right]}_{\text{$=0$ by LIE}}
%\end{align*}
%so $\arg\min_{\textbf{b}} E\left[(Y_i-\mathbf{X}_i^\prime\boldsymbol b)^2\right]=\arg\min_{\textbf{b}} E\left[(\mu(\mathbf{X}_i)-\mathbf{X}_i^\prime\boldsymbol b)^2\right]$
%
% \end{wideitemize}
% \end{frame}
%
\begin{frame}{Solving for Regression Coefficients}
\begin{wideitemize}
\item
So the \emph{population regression coefficient} $\boldsymbol\beta$ solves least squares problem
$$\bm{\beta} = \argmin_{\mathbf{b}} E[ (Y_i - \mathbf{X}_i '\mathbf{b})^2]$$
\pause
\item
To solve for $\bm{\beta}$, we take the derivative (i.e. gradient) and set it to zero
\begin{align*}
& \dfrac{d}{d \bm{\beta}} E[ (Y_i - \mathbf{X}_i '\bm{\beta})^2] = \mathbf{0} \pause{} \\
\Rightarrow & E[ \dfrac{d}{d \bm{\beta}} (Y_i - \mathbf{X}_i '\bm{\beta})^2] = \mathbf{0} \pause{} \\
\Rightarrow & E[-2 \mathbf{X}_i (Y_i - \mathbf{X}_i '\bm{\beta})] = \mathbf{0} \pause{}\\
\Rightarrow & E[\mathbf{X}_i Y_i] = E[\mathbf{X}_i \mathbf{X}_i ']\bm{\beta}
\end{align*}
\end{wideitemize}
\end{frame}
\begin{frame}{Multivariate Regression, in the Population and Sample}
\begin{wideitemize}
\item
Solving for $\bm{\beta}$, we obtain an expression involving population means:
$$\bm{\beta} = E[ \bm{X}_i \bm{X}_i' ]^{-1} E[\bm{X}_i Y_i] $$
\vspace{-0.3cm}
\begin{itemize}
\item With a bit of algebra, you can show that this reduces to the bivariate formulas $\beta=\frac{Cov(X_i,Y_i)}{Var(X_i)}$ and $\alpha=E[Y_i]-E[X_i]\beta$ when $\mathbf{X}_i=(1,X_i)^\prime$
\end{itemize}
\pause\smallskip
\item
To estimate $\bm{\beta}$, we can replace population means with sample means.
\pause
$$ \bm{\hat\beta} = \left( \frac{1}{N} \sum_{i=1}^N \bm{X}_i \bm{X}_i' \right)^{-1} \left( \frac{1}{N} \sum_{i=1}^N \bm{X}_i Y_i \right)$$
\pause\smallskip
\item
We thus now have a general way of estimating $E[Y_i\mid \mathbf{X}_i]\approx \mathbf{X}_i^\prime\boldsymbol{\beta}$ for any vector $\mathbf{X}_i=(1,X_{i1},\dots,X_{iK})^\prime$
\end{wideitemize}
\end{frame}
%Outline
% Motivation
% Example 1 --- multivariate regression
% Mechanics of Multivariate Least-Squares
% Interpreting coefficients
% Example 2 -- multivariate controls. Dale and Krueger
% Omitted variable bias
% F-tests?
\begin{frame}{Quadratic Regression of Log Wages on Age}
\begin{center}
\includegraphics[width = 0.8 \linewidth]{logwages-quadratic}
\begin{tabular}{lr}
Constant & 5.8591 \\
Age & 0.0403 \\
Age$^2$ & -0.0005
\end{tabular}
\end{center}
\end{frame}
\begin{frame}{Interpreting Quadratic Regression Coefficients}
\begin{itemize}
\item
With a quadratic fit, we have
$$E[Y_i | X_i =x] \approx \bm{\hat\beta}_0 + \bm{\hat\beta}_1 x + \bm{\hat\beta}_2 x^2$$
\smallskip
\pause
\item
What is the slope of $ E[Y_i | X_i =x] $? Differentiating, we have \pause{}
$$\dfrac{d}{dx} E[Y_i | X_i =x] \approx \bm{\hat\beta}_1 + 2 \bm{\hat\beta}_2 x$$
\smallskip
\pause
\item
The estimated derivative from a multivariate regression, in this case $ \bm{\hat\beta}_1 + 2 \bm{\hat\beta}_2 x$, is sometimes called the ``marginal effect'' at $x$
\smallskip
\begin{itemize}
\item
This terminology is a bit unfortunate: this need not be a \textit{causal} effect, just an estimated derivative of the CEF
\end{itemize}
\end{itemize}
\end{frame}
\begin{frame}{Interpreting Our Example Coefficients}
\begin{tabular}{lr}
Constant ($\bm\hat\beta_0$) & 5.8591 \\
Age ($\bm\hat\beta_1$) & 0.0403 \\
Age$^2$ ($\bm\hat\beta_2$) & -0.0005
\end{tabular}
\medskip
\begin{wideitemize}
\item
What is the estimated slope of average log-earnings w.r.t. age? \pause
\item
$\bm{\hat\beta_1} + 2 \bm{\hat\beta_2} \cdot Age \pause{} = 0.0403 - 2 \times 0.0005\cdot Age = \pause{} 0.0403 - 0.001 \cdot Age$.
\pause
\item
For what age is estimated earnings highest? \pause
$$0.0403 - 0.001 \cdot Age = 0 \pause{} \Rightarrow Age = 0.0403 / 0.001 = 40.3 $$
\end{wideitemize}
\end{frame}
\begin{frame}{Re-Writing Multivariate OLS with Matrix Algebra}
\begin{wideitemize}
\item
We showed that
$$ \bm{\hat\beta} = \left( \frac{1}{N} \sum_{i=1}^N \bm{X}_i \bm{X}_i' \right)^{-1} \left( \frac{1}{N} \sum_{i=1}^N \bm{X}_i Y_i \right)$$
\item
This formula is often given more compactly with matrix notation.
\pause
\item
Let $\bm{X}$ be an $N \times K$ matrix w/ $X_{ik}$ giving the element in row $i$ and column $k$. \pause Likewise let $\bm{Y} = (Y_1,...,Y_N)'$.
\pause
\item
For example, if $\bm{X}_i = (1, X_i)'$ and $N=3$, then
$$\bm{X} = \left( \begin{array}{rr} 1 & X_{1} \\ 1 & X_{2} \\ 1 & X_{3} \end{array} \right) \pause \hspace{2cm} \bm{Y} = \left( \begin{array}{r} Y_{1} \\Y_{2} \\ Y_{3} \end{array} \right)$$
\pause
\item
Using this notation, one can show that $\bm{\hat\beta} = \left(\bm{X'X}\right)^{-1} \bm{X}'\bm{Y}$
\end{wideitemize}
\end{frame}
\begin{frame}{Asymptotic Properties of Multivariate OLS}
\begin{wideitemize}
\item
To test hypotheses about the population CEF, we need to derive the asymptotic distribution of $\bm{\hat\beta}$.
\pause
\item
As with univariate OLS, we can show that $\bm{\hat\beta}$ is consistent and asymptotically normally distributed.
\pause
\item
The proofs are very similar to those for univariate OLS, so I'll skip them and show you the results!
\pause
\item
\textbf{Consistency:} $\bm{\hat\beta} \rightarrow_p \bm{\beta}$.
\end{wideitemize}
\end{frame}
\begin{frame}{Asymptotic Properties of Multivariate OLS}
\begin{wideitemize}
\item
\textbf{Asymptotic normality}:
$$\sqrt{N} (\bm{\hat\beta} - \bm{\beta}) \rightarrow_d \mathrm{N}(0, \bm{\Sigma}),$$
\noindent where $\bm{\Sigma} = E[ \bm{X}_i \bm{X}_i' ]^{-1} Var( \bm{X}_i \epsilon_i ) E[ \bm{X}_i \bm{X}_i' ]^{-1} $ and $\epsilon_i = Y_i - \bm{X}_i' \bm{\beta}$
\pause
\item
We can estimate $\bm{\Sigma}$ by replacing population means with sample means
$$\bm{\hat\Sigma} = \left( \frac{1}{N} \sum_{i=1}^N \bm{X}_i \bm{X}_i' \right)^{-1} \left(\frac{1}{N} \sum_{i=1}^N \bm{X}_i \bm{X}_i' \hat\epsilon_i^2 \right) \left( \frac{1}{N} \sum_{i=1}^N \bm{X}_i \bm{X}_i' \right)^{-1} $$
where $\hat\epsilon_i = Y_i - \bm{X}_i' \bm{\hat\beta}$.
\item\pause{}
Note: $\bm{\hat\Sigma}$ is a \textit{matrix}.
\begin{itemize}
\item
The standard error for $\bm{\hat\beta}_j$ is $\sqrt{\bm{\hat\Sigma}_{jj}} / \sqrt{N}$
\item
The off-diagonal elements correspond with covariances between $\bm{\hat\beta}_j$,$\bm{\hat\beta}_k$
\end{itemize}
\end{wideitemize}
\end{frame}
\begin{frame}{Example - Log Earnings by Age}
\begin{tabular}{lrr}
Variable & Coefficient & SE \\ \hline
Constant ($\beta_0$) & 5.8591 & 0.1409 \\
Age ($\beta_1$) & 0.0403 & 0.0077\\
Age$^2$ ($\beta_2$) & -0.0005 & 0.0001
\end{tabular}
\medskip
\begin{wideitemize}
\item
What is a confidence interval for $\beta_2$?
\pause{}
$$\hat\beta_2 \pm 1.96 \times SE_{\beta_2} = \pause{} -0.0005 \pm 1.96 \times 0.0001 \pause{} = [-0.0007, -0.0003] $$
\end{wideitemize}
\end{frame}
% PH to here 10/16
\begin{frame}{Controlling for Multiple Variables}
\begin{wideitemize}
\item
In addition to allowing for more flexible functional forms (e.g. quadratic), multivariate OLS allows us to approximate the CEF conditional on multiple variables at once
\pause
\item
Example: we have data from Texas on each county's presidential vote over the last three elections (2012,2016,2020)
\pause
\item
Let $Y_i = $ Biden vote share in county $i$, $X_{i1}$ = Clinton vote share in county $i$, and $X_{i2} = $ Obama vote share in county $i$
\pause
\item
We estimate the regression
$$Y_i = \beta_0 + \beta_1 X_{i1} + \beta_2 X_{i2} + \epsilon_i$$
\pause
\item
This says that
$$\scriptsize E[ \text{Biden vote} | \text{Clinton vote} , \text{Obama vote} ] \approx \beta_0 + \beta_1 \times \text{Clinton vote} + \beta_2 \times \text{Obama vote} $$
\end{wideitemize}
\end{frame}
\begin{frame}{OLS Estimates}
\begin{tabular}{lrr}
Variable & Coefficient & SE \\ \hline
Constant & 0.05 & 0.01 \\
Clinton & 1.39 & 0.13 \\
Obama & -0.56 & 0.13
\end{tabular}
\medskip
\pause
\begin{wideitemize}
\item
What is the predicted Biden vote share for a county where Obama got half the vote and Clinton got 60\%?
\pause
$$\hat\beta_0 + \hat\beta_1 0.6 + \hat\beta_2 0.5 = \pause{} 0.05 + 1.39 \times 0.6 - 0.56 \times 0.5 = \pause{} 0.604$$
\pause
\vspace{-0.5cm}
\item
Notice that the coefficient on Obama vote share is \textit{negative}
\item
Wait, does this mean Biden did worse in places that Obama did well?!
\end{wideitemize}
\end{frame}
\begin{frame}
\begin{center}
\includegraphics[width = 0.7 \linewidth]{biden-obama}
\end{center}
\begin{wideitemize}
\item
If we look at the data, we see that Biden vote share is highly positively correlated with Obama vote share.
\item
So what's going on?!
\end{wideitemize}
\end{frame}
\begin{frame}{Interpreting Regression Coefficients}
\begin{wideitemize}
\item
Remember that multivariate OLS is approximating the CEF as
$$E[Y_i | \bm{X}_i = \bm{x}] \approx \beta_0 + x_{i1} \beta_1 + x_{i2} \beta_2 $$
\pause
\item
Thus, $\beta_2$ is an estimate of a \textit{partial derivative},
$$\dfrac{\partial }{\partial x_{i2}} E[Y_i | \bm{X}_i = \bm{x}] \approx \beta_2 ,$$
\noindent i.e. the change in the CEF from changing $X_{i2}$ \textit{holding $X_{i1}$ constant}.
\pause
\item
If $\beta_2 < 0$, this means that among places where Clinton had the same vote share, Biden did better in places with lower Obama vote share.
\pause
\item
In other words, Biden did better in places where Democratic vote share was increasing between 2012 and 2016!
\end{wideitemize}
\end{frame}
\begin{frame}
\centering
\includegraphics[width = 0.8 \linewidth]{biden-obama-minus-clinton}
\end{frame}
\begin{frame}{Generalizing this idea}
\begin{wideitemize}
\item
The \textbf{Frisch-Waugh-Lovell} (FWL) theorem gives us a general way to interpret coefficients in multivariate regression. \pause Consider the regression
$$Y_i = \beta_0 + X_{i1} \beta_1 + X_{i2} \beta_2 + \epsilon_i$$
\pause
\item
FWL says that the OLS coefficient $\hat\beta_2$ can be obtained by the following steps:
\pause
\item
1) Regress $X_{i2}$ on $X_{i1}$ and a constant:
$$X_{i2} = \gamma_0 + X_{i1} \gamma_1 + u_i $$
\pause
\item
2) For each unit, predict $X_{i2}$ using the coefficients obtained in step 1)
$$\hat{X}_{i2} = \hat\gamma_0 + X_{i1} \hat\gamma_1 $$
\pause
\item
3) Obtain $\hat\beta_2$ by regressing $Y_i$ on the OLS residual $X_{i2} - \hat{X}_{i2}$:
$$Y_i = \alpha + (X_{i2} - \hat{X}_{i2}) \beta_2 + v_i$$
\end{wideitemize}
\end{frame}
\begin{frame}{Illustration Using Election Data}
\begin{wideitemize}
\item
Regress Obama vote share on Clinton vote share
\begin{tabular}{lr}
Intercept ($\hat\gamma_0$) & 0.03 \\
Clinton ($\hat\gamma_1$) & 0.98
\end{tabular}
\pause
\item
Predict Obama vote share using Clinton vote share:
$$\hat{X}_{i2} = \pause{} 0.03 + 0.98 X_{i1} $$
\vspace{-0.5cm}
\pause
\item
Regress Biden vote share on $X_{i2} - \hat X_{i2} $:
\begin{tabular}{lr}
Intercept ($\hat\alpha$) & 0.25 \\
Obama minus predicted ($\hat\beta_2$) & -0.56
\end{tabular}
\item
The estimate $\hat\beta_2$, -0.56, is exactly what we got before!
\end{wideitemize}
\end{frame}
\begin{frame}
\centering
\includegraphics[width = 0.7\linewidth]{biden-obama-residuals}
\begin{wideitemize}
\item
The slope of the best-fit line is precisely $\hat\beta_2 = -0.56$.
\item FWL generally gives us an easy way to visualize/interpret multivariate regression coefficients
\end{wideitemize}
\end{frame}
\begin{frame}{Measures of Model Fit}
\begin{wideitemize}
\item
Did adding a quadratic term help us improve our approximation to the wage-age CEF? How can we measure this?
\pause
\item
One way of measuring model fit is the population $R^2$: for the regression $Y_i = \bm{X}_i' \bm{\beta} + \epsilon_i$,
$$ R^2 = \frac{Var(\bm{X}_i' \bm{\beta})}{ Var(Y_i) } $$
\pause
\item
Intuitively, population $R^2$ measures the fraction of the variance of $Y_i$ explained by $\bm{X}_i ' \beta$\smallskip
\begin{itemize}
\item Since $Cov(\mathbf{X}_i^\prime\boldsymbol{\beta},e_i)=0$, we also have $R^2=1-\frac{Var(e_i)}{Var(Y_i)}$
\end{itemize}
\pause
\item
To estimate $R^2$, we replace population values with sample analogs
$$\hat{R}^2 = \frac{\frac{1}{N}\sum_i(\mathbf{X}_i^\prime\hat{\boldsymbol{\beta}}-\bar{\mathbf{X}}_i^\prime\hat{\boldsymbol{\beta}})^2}{\frac{1}{N} \sum_i (Y_i - \bar{Y})^2 }=1 - \dfrac{ \frac{1}{N} \sum_i \hat\epsilon_i^2 }{ \frac{1}{N} \sum_i (Y_i - \bar{Y})^2 }$$
\end{wideitemize}
\end{frame}
\begin{frame}{$R^2$ in the Wage-Age Example}
\begin{figure}
\subfloat[$\hat{R}^2$ = 0.44]{\includegraphics[width = 0.45 \linewidth]{logwages-linear}} \subfloat[$\hat{R}^2$ = 0.73]{\includegraphics[width = 0.45 \linewidth]{logwages-quadratic}}
\end{figure}
\begin{wideitemize}
\item
The linear fit explains 44\% of the variation in average earnings across ages, whereas the quadratic fit explains 73\%
\end{wideitemize}
\end{frame}
\begin{frame}{Caution about $\hat{R}^2$}
\begin{wideitemize}
\item
Caution: the sample $\hat{R}^2$ will always increase if you have a more complicated model. Why?
\pause
\item
The coefficients from a linear fit minimizes
$$ \frac{1}{N} \sum_i (\underbrace{Y_i - (\hat\beta_0 + \hat\beta_1 X_i)}_{\hat\epsilon_{Linear}})^2 $$
While the coefficients in a quadratic fit minimize
$$ \frac{1}{N} \sum_i (\underbrace{Y_i - (\hat\beta_0 + \hat\beta_1 X_i + \hat\beta_2 X_i^2)}_{\hat\epsilon_{Quad}})^2 $$
\noindent Since $\hat\beta_2 = 0$ is feasible in the quadratic minimization, the minimization will always be weakly lower w/a quadratic term
\pause
\item
But is a more complicated model always better?
\end{wideitemize}
\end{frame}
\begin{frame}
\begin{figure}
\subfloat[Quadratic, $\hat{R}^2$ = 0.44]{\includegraphics[width = 0.45 \linewidth]{quadfit-insample}} \subfloat[20th order poly, $\hat{R}^2$ = 0.70]{\includegraphics[width = 0.45 \linewidth]{p20fit-insample}}
\end{figure}
\begin{wideitemize}
\item
Suppose we take a sample of size 10,000 and fit a quadratic and a 20th order polynomial
\pause
\item
The 20th order poly has higher $R^2$, does it look reasonable to you?
\pause
\item
No, it looks too ``squiggly'' -- it has adapted to fit the exact points in the sample
\end{wideitemize}
\end{frame}
\begin{frame}
\only<2->{ \begin{figure}
\subfloat[Quadratic]{\includegraphics[width = 0.45 \linewidth]{quadfit-outsample}} \subfloat[20th order poly]{\includegraphics[width = 0.45 \linewidth]{p20fit-outsample}} \end{figure} }
\begin{wideitemize}
\item<1->
Suppose we draw a new sample and test the prediction of our model trained on the first data-set
\pause
\item
The quadratic fit generalizes pretty well to the new data.
\item
But the 20th-order polynomial does very poorly. It ``overfit'' the features of the specific previous sample. This doesn't generalize well to a new sample
\end{wideitemize}
\end{frame}
\begin{frame}{How Can We Avoid Over-Fitting?}
\begin{wideitemize}
\item
The challenge is to pick a rich enough model to capture the key features of the CEF, but not too rich a model such that we overfit
\pause
\item
There are several tools available to try to help with this task, none of which is perfect.
\pause
\item
\textbf{Adjusted} $\hat{R}^2$ is a modification to $\hat{R}^2$ that adds a penalty for models with more variables
\begin{itemize}
\item
Generally better than $\hat{R}^2$, but model w/highest $\hat{R}^2$ need not be best
\end{itemize}
\pause
\item
\textbf{Cross validation}: choose complexity of the model based on how well it does ``out of sample'' \pause
\begin{itemize}
\item
Split data in two: train model on one half, and see how well it predicts on the second half
\item
Choose the complexity of the model based on how well it predicts out of sample
\pause
\item
Cross-validation is the basis of modern \textit{machine learning} (ML) methods. \\
ML is very powerful, and recent work has extended ML for causal problems (but beyond scope of this class)
\end{itemize}
\end{wideitemize}
\end{frame}
\begin{frame}{Avoiding Overfitting in Practice}
\begin{wideitemize}
\item
The tools described above are useful for deciding between models, but in practice model selection is often done more heuristically
\pause
\item
Researchers will typically start with a simple model (e.g. linear or quadratic) that includes what they think are the most important variables
\pause
\item
Then, they will assess the ``robustness'' of the conclusions to adding/subtracting variables and/or higher-order terms.
\pause
\item
Generally, we will be more confident if the model conclusions are not sensitive to tweaks in the model specification.
% \pause
% \item
% Of course this is all about maximizing regression ``fit'' -- a different approach is to derive your regression specification from a theoretically-motivated \textbf{causal} query ...
\end{wideitemize}
\end{frame}
\begin{frame}{Outline}
\textcolor{red!75!green!50!blue!25!gray}{1. Deriving Multivariate Regression and OLS}$\checkmark$
\vspace{0.8cm}
2. Regression and Causality
\vspace{0.8cm}
\textcolor{red!75!green!50!blue!25!gray}{3. Regression Odds and Ends}
\end{frame}
\begin{frame}{Regression Meets Causality}
\vspace{0.2cm}
\begin{wideitemize}
\item
Multivariate regressions are often used to estimate causal effects under conditional unconfoundedness
\pause
\item
Recall that under conditional unconfoundedness,
$$CATE(\bm{x}) = E[ Y_{i} | D_i =1, \bm{X}_i = \bm{x} ] - E[Y_{i} | D_i =0 , \bm{X}_i =\bm{x}] $$
\pause
\item
Common to approximate the CEF linearly, as
$$E[ Y_i | D_i, \bm{X}_i ] \approx D_i \beta + \bm{X}_i' \bm{\gamma} $$
\pause
\item
Then conditional unconfoundedness implies that $CATE(\bm{x}) \approx \beta$. \smallskip
\begin{itemize}
\item Doesn't depend on $\mathbf{x}$, so also have $\beta\approx ATE$
\end{itemize}
\pause
\item
So if we estimate the multivariate regression
$$Y_i = D_i \beta + \bm{X}_i' \bm{\gamma} + \epsilon_i,$$
\noindent we can interpret $\bm{\hat\beta}$ as an estimate of the ATE.
\end{wideitemize}
\end{frame}
\begin{frame}{Dale and Krueger}
\begin{wideitemize}
\item
Dale \& Krueger (as you recall) are interested in the effect of attending a more selective college on earnings\smallskip
\begin{itemize}
\item
They have data on earnings and college application information from the College and Beyond (C\&B) Survey
\end{itemize}
\pause
\item
The C\&B survey covers students who attended 30 colleges for the high school class of 1978; it contains important variables:
\pause
\item
\textbf{Earnings} in 1996
\item
\textbf{College application and demographic variables} including SAT scores, class rank, family income, race, etc
\item
\textbf{College application decisions} --- i.e. the set of schools students applied to and were admitted
\end{wideitemize}
\end{frame}
\begin{frame}
\centering
\includegraphics[width = 0.5\linewidth]{dk-list-of-schools}
\end{frame}
\begin{frame}{Dealing with Selection}
\begin{wideitemize}
\item
Dale \& Krueger assume \textbf{conditional unconfoundedness}, i.e. $D_i \indep (Y_i(\cdot)) | X_i$ where $D_i$ is the average SAT score for students at your college and $X_i$ is a set of controls
\pause
\item
They then estimate regressions of the form
$$ln(Y_i) = D_i \beta + \bm{X}_i'\bm{ \gamma }+ \epsilon_i$$
\noindent where $Y_i$ is 1996 earnings
\pause
\item
If conditional unconfoundedness holds \& the regression approx. to the CEF is decent, then $\beta$ should (approximately) equal the treatment effect of attending a college with higher average SAT scores.
\end{wideitemize}
\end{frame}
\begin{frame}{First Pass: SAT Scores and Demographics in $\bm{X}_i$ }
\includegraphics[width =0.3\linewidth]{dk-results-table-reg1}
\begin{wideitemize}
\item
$\hat\beta = 0.076$ indicates about an increase in log wages of 7.6 from attending a school with 100 higher SAT points
\end{wideitemize}
\end{frame}
\begin{frame}{Do You Buy This Estimate?}
\begin{wideitemize}
\item
Why might unconfoundedness fail when using these controls? \smallskip
\pause
\begin{itemize}
\item
Which colleges you get into may depend on relevant unobserved factors --- e.g., students with better application essays may get into more colleges and earn more regardless of where they go
\end{itemize}