-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathusers-guide.tex
More file actions
executable file
·3597 lines (3056 loc) · 171 KB
/
users-guide.tex
File metadata and controls
executable file
·3597 lines (3056 loc) · 171 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
% Options for packages loaded elsewhere
\PassOptionsToPackage{unicode}{hyperref}
\PassOptionsToPackage{hyphens}{url}
\PassOptionsToPackage{dvipsnames,svgnames,x11names}{xcolor}
%
\documentclass[
letterpaper,
DIV=11,
numbers=noendperiod]{scrreprt}
\usepackage{amsmath,amssymb}
\usepackage{lmodern}
\usepackage{iftex}
\ifPDFTeX
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{textcomp} % provide euro and other symbols
\else % if luatex or xetex
\usepackage{unicode-math}
\defaultfontfeatures{Scale=MatchLowercase}
\defaultfontfeatures[\rmfamily]{Ligatures=TeX,Scale=1}
\fi
% Use upquote if available, for straight quotes in verbatim environments
\IfFileExists{upquote.sty}{\usepackage{upquote}}{}
\IfFileExists{microtype.sty}{% use microtype if available
\usepackage[]{microtype}
\UseMicrotypeSet[protrusion]{basicmath} % disable protrusion for tt fonts
}{}
\makeatletter
\@ifundefined{KOMAClassName}{% if non-KOMA class
\IfFileExists{parskip.sty}{%
\usepackage{parskip}
}{% else
\setlength{\parindent}{0pt}
\setlength{\parskip}{6pt plus 2pt minus 1pt}}
}{% if KOMA class
\KOMAoptions{parskip=half}}
\makeatother
\usepackage{xcolor}
\setlength{\emergencystretch}{3em} % prevent overfull lines
\setcounter{secnumdepth}{5}
% Make \paragraph and \subparagraph free-standing
\ifx\paragraph\undefined\else
\let\oldparagraph\paragraph
\renewcommand{\paragraph}[1]{\oldparagraph{#1}\mbox{}}
\fi
\ifx\subparagraph\undefined\else
\let\oldsubparagraph\subparagraph
\renewcommand{\subparagraph}[1]{\oldsubparagraph{#1}\mbox{}}
\fi
\usepackage{color}
\usepackage{fancyvrb}
\newcommand{\VerbBar}{|}
\newcommand{\VERB}{\Verb[commandchars=\\\{\}]}
\DefineVerbatimEnvironment{Highlighting}{Verbatim}{commandchars=\\\{\}}
% Add ',fontsize=\small' for more characters per line
\usepackage{framed}
\definecolor{shadecolor}{RGB}{241,243,245}
\newenvironment{Shaded}{\begin{snugshade}}{\end{snugshade}}
\newcommand{\AlertTok}[1]{\textcolor[rgb]{0.68,0.00,0.00}{#1}}
\newcommand{\AnnotationTok}[1]{\textcolor[rgb]{0.37,0.37,0.37}{#1}}
\newcommand{\AttributeTok}[1]{\textcolor[rgb]{0.40,0.45,0.13}{#1}}
\newcommand{\BaseNTok}[1]{\textcolor[rgb]{0.68,0.00,0.00}{#1}}
\newcommand{\BuiltInTok}[1]{\textcolor[rgb]{0.00,0.23,0.31}{#1}}
\newcommand{\CharTok}[1]{\textcolor[rgb]{0.13,0.47,0.30}{#1}}
\newcommand{\CommentTok}[1]{\textcolor[rgb]{0.37,0.37,0.37}{#1}}
\newcommand{\CommentVarTok}[1]{\textcolor[rgb]{0.37,0.37,0.37}{\textit{#1}}}
\newcommand{\ConstantTok}[1]{\textcolor[rgb]{0.56,0.35,0.01}{#1}}
\newcommand{\ControlFlowTok}[1]{\textcolor[rgb]{0.00,0.23,0.31}{#1}}
\newcommand{\DataTypeTok}[1]{\textcolor[rgb]{0.68,0.00,0.00}{#1}}
\newcommand{\DecValTok}[1]{\textcolor[rgb]{0.68,0.00,0.00}{#1}}
\newcommand{\DocumentationTok}[1]{\textcolor[rgb]{0.37,0.37,0.37}{\textit{#1}}}
\newcommand{\ErrorTok}[1]{\textcolor[rgb]{0.68,0.00,0.00}{#1}}
\newcommand{\ExtensionTok}[1]{\textcolor[rgb]{0.00,0.23,0.31}{#1}}
\newcommand{\FloatTok}[1]{\textcolor[rgb]{0.68,0.00,0.00}{#1}}
\newcommand{\FunctionTok}[1]{\textcolor[rgb]{0.28,0.35,0.67}{#1}}
\newcommand{\ImportTok}[1]{\textcolor[rgb]{0.00,0.46,0.62}{#1}}
\newcommand{\InformationTok}[1]{\textcolor[rgb]{0.37,0.37,0.37}{#1}}
\newcommand{\KeywordTok}[1]{\textcolor[rgb]{0.00,0.23,0.31}{#1}}
\newcommand{\NormalTok}[1]{\textcolor[rgb]{0.00,0.23,0.31}{#1}}
\newcommand{\OperatorTok}[1]{\textcolor[rgb]{0.37,0.37,0.37}{#1}}
\newcommand{\OtherTok}[1]{\textcolor[rgb]{0.00,0.23,0.31}{#1}}
\newcommand{\PreprocessorTok}[1]{\textcolor[rgb]{0.68,0.00,0.00}{#1}}
\newcommand{\RegionMarkerTok}[1]{\textcolor[rgb]{0.00,0.23,0.31}{#1}}
\newcommand{\SpecialCharTok}[1]{\textcolor[rgb]{0.37,0.37,0.37}{#1}}
\newcommand{\SpecialStringTok}[1]{\textcolor[rgb]{0.13,0.47,0.30}{#1}}
\newcommand{\StringTok}[1]{\textcolor[rgb]{0.13,0.47,0.30}{#1}}
\newcommand{\VariableTok}[1]{\textcolor[rgb]{0.07,0.07,0.07}{#1}}
\newcommand{\VerbatimStringTok}[1]{\textcolor[rgb]{0.13,0.47,0.30}{#1}}
\newcommand{\WarningTok}[1]{\textcolor[rgb]{0.37,0.37,0.37}{\textit{#1}}}
\providecommand{\tightlist}{%
\setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}\usepackage{longtable,booktabs,array}
\usepackage{calc} % for calculating minipage widths
% Correct order of tables after \paragraph or \subparagraph
\usepackage{etoolbox}
\makeatletter
\patchcmd\longtable{\par}{\if@noskipsec\mbox{}\fi\par}{}{}
\makeatother
% Allow footnotes in longtable head/foot
\IfFileExists{footnotehyper.sty}{\usepackage{footnotehyper}}{\usepackage{footnote}}
\makesavenoteenv{longtable}
\usepackage{graphicx}
\makeatletter
\def\maxwidth{\ifdim\Gin@nat@width>\linewidth\linewidth\else\Gin@nat@width\fi}
\def\maxheight{\ifdim\Gin@nat@height>\textheight\textheight\else\Gin@nat@height\fi}
\makeatother
% Scale images if necessary, so that they will not overflow the page
% margins by default, and it is still possible to overwrite the defaults
% using explicit options in \includegraphics[width, height, ...]{}
\setkeys{Gin}{width=\maxwidth,height=\maxheight,keepaspectratio}
% Set default figure placement to htbp
\makeatletter
\def\fps@figure{htbp}
\makeatother
\newlength{\cslhangindent}
\setlength{\cslhangindent}{1.5em}
\newlength{\csllabelwidth}
\setlength{\csllabelwidth}{3em}
\newlength{\cslentryspacingunit} % times entry-spacing
\setlength{\cslentryspacingunit}{\parskip}
\newenvironment{CSLReferences}[2] % #1 hanging-ident, #2 entry spacing
{% don't indent paragraphs
\setlength{\parindent}{0pt}
% turn on hanging indent if param 1 is 1
\ifodd #1
\let\oldpar\par
\def\par{\hangindent=\cslhangindent\oldpar}
\fi
% set entry spacing
\setlength{\parskip}{#2\cslentryspacingunit}
}%
{}
\usepackage{calc}
\newcommand{\CSLBlock}[1]{#1\hfill\break}
\newcommand{\CSLLeftMargin}[1]{\parbox[t]{\csllabelwidth}{#1}}
\newcommand{\CSLRightInline}[1]{\parbox[t]{\linewidth - \csllabelwidth}{#1}\break}
\newcommand{\CSLIndent}[1]{\hspace{\cslhangindent}#1}
\newcommand{\bs}{\symbf}
\newcommand{\mb}{\symbf}
\newcommand{\E}{\mathbb{E}}
\newcommand{\V}{\mathbb{V}}
\newcommand{\var}{\text{var}}
\newcommand{\cov}{\text{cov}}
\newcommand{\N}{\mathcal{N}}
\newcommand{\Bern}{\text{Bern}}
\newcommand{\Bin}{\text{Bin}}
\newcommand{\Pois}{\text{Pois}}
\newcommand{\Unif}{\text{Unif}}
\newcommand{\se}{\textsf{se}}
\newcommand{\au}{\underline{a}}
\newcommand{\du}{\underline{d}}
\newcommand{\Au}{\underline{A}}
\newcommand{\Du}{\underline{D}}
\newcommand{\xu}{\underline{x}}
\newcommand{\Xu}{\underline{X}}
\newcommand{\Yu}{\underline{Y}}
\renewcommand{\P}{\mathbb{P}}
\newcommand{\U}{\mb{U}}
\newcommand{\Xbar}{\overline{X}}
\newcommand{\Ybar}{\overline{Y}}
\newcommand{\real}{\mathbb{R}}
\newcommand{\bbL}{\mathbb{L}}
\renewcommand{\u}{\mb{u}}
\renewcommand{\v}{\mb{v}}
\newcommand{\M}{\mb{M}}
\newcommand{\X}{\mb{X}}
\newcommand{\Xmat}{\mathbb{X}}
\newcommand{\bfx}{\mb{x}}
\newcommand{\y}{\mb{y}}
\newcommand{\bfbeta}{\mb{\beta}}
\renewcommand{\b}{\symbf{\beta}}
\newcommand{\e}{\bs{\epsilon}}
\newcommand{\bhat}{\widehat{\mb{\beta}}}
\newcommand{\XX}{\Xmat'\Xmat}
\newcommand{\XXinv}{\left(\XX\right)^{-1}}
\newcommand{\hatsig}{\hat{\sigma}^2}
\newcommand{\red}[1]{\textcolor{red!60}{#1}}
\newcommand{\indianred}[1]{\textcolor{indianred}{#1}}
\newcommand{\blue}[1]{\textcolor{blue!60}{#1}}
\newcommand{\dblue}[1]{\textcolor{dodgerblue}{#1}}
\newcommand{\indep}{\perp\!\!\!\perp}
\newcommand{\inprob}{\overset{p}{\to}}
\newcommand{\indist}{\overset{d}{\to}}
\newcommand{\eframe}{\end{frame}}
\newcommand{\bframe}{\begin{frame}}
\newcommand{\R}{\textsf{\textbf{R}}}
\newcommand{\Rst}{\textsf{\textbf{RStudio}}}
\newcommand{\rfun}[1]{\texttt{\color{magenta}{#1}}}
\newcommand{\rpack}[1]{\textbf{#1}}
\newcommand{\rexpr}[1]{\texttt{\color{magenta}{#1}}}
\newcommand{\filename}[1]{\texttt{\color{blue}{#1}}}
\DeclareMathOperator*{\argmax}{arg\,max}
\DeclareMathOperator*{\argmin}{arg\,min}
\KOMAoption{captions}{tableheading}
\makeatletter
\@ifpackageloaded{tcolorbox}{}{\usepackage[many]{tcolorbox}}
\@ifpackageloaded{fontawesome5}{}{\usepackage{fontawesome5}}
\definecolor{quarto-callout-color}{HTML}{909090}
\definecolor{quarto-callout-note-color}{HTML}{0758E5}
\definecolor{quarto-callout-important-color}{HTML}{CC1914}
\definecolor{quarto-callout-warning-color}{HTML}{EB9113}
\definecolor{quarto-callout-tip-color}{HTML}{00A047}
\definecolor{quarto-callout-caution-color}{HTML}{FC5300}
\definecolor{quarto-callout-color-frame}{HTML}{acacac}
\definecolor{quarto-callout-note-color-frame}{HTML}{4582ec}
\definecolor{quarto-callout-important-color-frame}{HTML}{d9534f}
\definecolor{quarto-callout-warning-color-frame}{HTML}{f0ad4e}
\definecolor{quarto-callout-tip-color-frame}{HTML}{02b875}
\definecolor{quarto-callout-caution-color-frame}{HTML}{fd7e14}
\makeatother
\makeatletter
\makeatother
\makeatletter
\@ifpackageloaded{bookmark}{}{\usepackage{bookmark}}
\makeatother
\makeatletter
\@ifpackageloaded{caption}{}{\usepackage{caption}}
\AtBeginDocument{%
\ifdefined\contentsname
\renewcommand*\contentsname{Table of contents}
\else
\newcommand\contentsname{Table of contents}
\fi
\ifdefined\listfigurename
\renewcommand*\listfigurename{List of Figures}
\else
\newcommand\listfigurename{List of Figures}
\fi
\ifdefined\listtablename
\renewcommand*\listtablename{List of Tables}
\else
\newcommand\listtablename{List of Tables}
\fi
\ifdefined\figurename
\renewcommand*\figurename{Figure}
\else
\newcommand\figurename{Figure}
\fi
\ifdefined\tablename
\renewcommand*\tablename{Table}
\else
\newcommand\tablename{Table}
\fi
}
\@ifpackageloaded{float}{}{\usepackage{float}}
\floatstyle{ruled}
\@ifundefined{c@chapter}{\newfloat{codelisting}{h}{lop}}{\newfloat{codelisting}{h}{lop}[chapter]}
\floatname{codelisting}{Listing}
\newcommand*\listoflistings{\listof{codelisting}{List of Listings}}
\usepackage{amsthm}
\theoremstyle{definition}
\newtheorem{definition}{Definition}[chapter]
\theoremstyle{plain}
\newtheorem{theorem}{Theorem}[chapter]
\theoremstyle{definition}
\newtheorem{example}{Example}[chapter]
\theoremstyle{remark}
\renewcommand*{\proofname}{Proof}
\newtheorem*{remark}{Remark}
\newtheorem*{solution}{Solution}
\makeatother
\makeatletter
\@ifpackageloaded{caption}{}{\usepackage{caption}}
\@ifpackageloaded{subcaption}{}{\usepackage{subcaption}}
\makeatother
\makeatletter
\@ifpackageloaded{tcolorbox}{}{\usepackage[many]{tcolorbox}}
\makeatother
\makeatletter
\@ifundefined{shadecolor}{\definecolor{shadecolor}{rgb}{.97, .97, .97}}
\makeatother
\makeatletter
\makeatother
\ifLuaTeX
\usepackage{selnolig} % disable illegal ligatures
\fi
\IfFileExists{bookmark.sty}{\usepackage{bookmark}}{\usepackage{hyperref}}
\IfFileExists{xurl.sty}{\usepackage{xurl}}{} % add URL line breaks if available
\urlstyle{same} % disable monospaced font for URLs
\hypersetup{
pdftitle={A User's Guide to Statistical Inference and Regression},
pdfauthor={Matthew Blackwell},
colorlinks=true,
linkcolor={blue},
filecolor={Maroon},
citecolor={Blue},
urlcolor={Blue},
pdfcreator={LaTeX via pandoc}}
\title{A User's Guide to Statistical Inference and Regression}
\author{Matthew Blackwell}
\date{}
\begin{document}
\maketitle
\ifdefined\Shaded\renewenvironment{Shaded}{\begin{tcolorbox}[borderline west={3pt}{0pt}{shadecolor}, boxrule=0pt, interior hidden, breakable, frame hidden, enhanced, sharp corners]}{\end{tcolorbox}}\fi
\renewcommand*\contentsname{Table of contents}
{
\hypersetup{linkcolor=}
\setcounter{tocdepth}{2}
\tableofcontents
}
\bookmarksetup{startatroot}
\hypertarget{preface}{%
\chapter*{Preface}\label{preface}}
\addcontentsline{toc}{chapter}{Preface}
\markboth{Preface}{Preface}
\includegraphics{./assets/img/linear-approximation.png}
This is a set of notes for
\href{https://gov2002.mattblackwell.org}{Government 2002: Quantitative
Social Science Methods II} at Harvard University taught by
\href{https://www.mattblackwell.org}{Matthew Blackwell}. The goal of
this text is to provide a rigorous yet accessible introduction to the
foundational topics in statistical inference with a special application
to linear regression, a workhorse tool in the social sciences. The
material is intended for first-year PhD students in political science,
but it may be of interest more broadly. Much of the material has been
adopted from various sources (far too many to recount now), but this
book is especially indebted to the following texts:
\begin{itemize}
\tightlist
\item
Hansen, Bruce.
\href{https://www.amazon.com/Probability-Statistics-Economists-Bruce-Hansen/dp/0691235945/}{\emph{Probability
\& Statistics for Economists}}. Princeton University Press.
\item
Hansen, Bruce.
\href{https://www.amazon.com/Econometrics-Bruce-Hansen/dp/0691235899/}{\emph{Econometrics}}.
Princeton University Press.
\item
Wasserman, Larry.
\href{https://link.springer.com/book/10.1007/978-0-387-21736-9}{\emph{All
of Statistics: A Concise Course in Statistical Inference}}. Springer.
\item
Wooldridge, Jeffrey.
\href{https://mitpress.mit.edu/9780262232586/econometric-analysis-of-cross-section-and-panel-data/}{\emph{Econometric
Analysis of Cross Section and Panel Data}}
\end{itemize}
You can find the source for this book at
\url{https://github.com/mattblackwell/gov2002-book}. Any typos or errors
can be reported at
\url{https://github.com/mattblackwell/gov2002-book/issues}. Thanks for
reading.
This is a Quarto book. To learn more about Quarto books visit
\url{https://quarto.org/docs/books}.
\(\,\)
\bookmarksetup{startatroot}
\hypertarget{introduction}{%
\chapter{Introduction}\label{introduction}}
\(\,\)
This book, like so many books before it, will try to teach you
statistics. The field of statistics describes how we learn about the
world from quantitative data. In the social sciences, the vast majority
of empirical studies use statistical methods to provide evidence for
their arguments. While it is possible to conduct quantitative research
without understanding statistics, one must advise against it.
Quantitative research involves a host of \emph{choices} about what model
to use, what variables to include, what tuning parameters to set, what
assumptions to make, and so on. Without a deep understanding of
statistics, you will find these choices bewildering and often yield to
the default settings of your statistical software. The goal of this book
is to give you the foundation to confidently make those choices for your
specific application.
We will focus on two key goals in this book.
\begin{enumerate}
\def\labelenumi{\arabic{enumi}.}
\item
\textbf{Understand the basic ways to assess estimators} With
quantitative data, we often want to make statistical inferences about
some unknown feature of the world. We use estimators (which are just
ways of summarizing our data) to estimate these features. One major
goal of this book is to show the basics of this task at a general
enough level to be applicable to almost any estimator that you are
likely to encounter in research. The ideas of bias, sampling variance,
consistency, and asymptotic normality are common to such a large swath
of (frequentist) inference that you get a tremendous return on your
investment of time in these topics. Understand these core ideas and
you will have a language to analyze any fancy new estimator that pops
up in the next few decades.
\item
\textbf{Apply these ideas to estimation of regressions} This book will
apply these ideas to one particular workhorse task in the social
sciences: estimating regression functions. So many methods are either
use regression estimators like ordinary least squares or extend it in
some way. Understanding how these estimators work is vital for
conducting research in the social sciences. Regression and regression
estimators also provide an entry point for discussing parametric
models explicitly as approximation and projections rather than as
rigid assumptions about the truth of a given specification.
\end{enumerate}
Why write a book on statistics and regression when so many already
exist? Aside from hubris, my goal in this book is to find a level of
mathematical sophistication that will challenge and push political
scientists to develop stronger foundations in the material. While some
textbooks at this level exist in statistics and economics, they tend to
focus on applications less relevant to political science. This book
attempts to correct this.
\bookmarksetup{startatroot}
\hypertarget{estimation}{%
\chapter{Estimation}\label{estimation}}
\hypertarget{introduction-1}{%
\section{Introduction}\label{introduction-1}}
When studying probability, we assumed that we knew the parameter of a
distribution (the mean or the variance) and used probability theory to
understand what kind of data we would observe. Estimation and inference
put this engine in reverse and try to learn some aspect of the
data-generating process using only our observed data. There are two main
goals here: \textbf{estimation}, which is how we formulate our best
guess about a parameter of the DGP, and \textbf{inference}, which is how
we formalize and express uncertainty about our estimates.
\includegraphics{./assets/img/two-direction.png}
\leavevmode\vadjust pre{\hypertarget{exm-rct}{}}%
\begin{example}[Randomized control trial]\label{exm-rct}
Suppose we are conducting a randomized experiment on framing effects.
All respondents receive some factual information about current levels of
immigration. The message for the treatment group (\(D_i = 1\)) has an
additional framing of the positive benefits of immigration, while the
control group (\(D_i = 0\)) receives no additional framing. The outcome
is a binary outcome on whether the respondent supports increasing legal
immigration limits (\(Y_i = 1\)) or not (\(Y_i = 0\)). The observed data
consists of \(n\) pairs of random variables, the outcome, and the
treatment assignment: \(\{(Y_1, D_1), \ldots, (Y_n, D_n)\}\). Define the
two sample means/proportions in each group as \[
\Ybar_1 = \frac{1}{n_1} \sum_{i: D_i = 1} Y_i, \qquad\qquad \Ybar_0 = \frac{1}{n_0} \sum_{i: D_i = 0} Y_i,
\] where \(n_1 = \sum_{i=1}^n D_i\) is the number of treated units and
\(n_0 = n - n_1\) is the number of control units.
A standard estimator for the treatment effect in a study like this would
be the difference in means, \(\Ybar_1 - \Ybar_0\). But this is only one
possible estimator. We could also estimate the effect by taking this
difference in means separately by party identification and then
averaging those party-specific effects by the size of those groups. This
estimator is commonly called a \textbf{poststratification} estimator,
but it's unclear at first glance which of these two estimators we should
prefer.
\end{example}
What are the goals of studying estimators? In short, we prefer to use
\textbf{good} estimators rather than \textbf{bad} estimators. But what
makes an estimator good or bad? You probably have some intuitive sense
that, for example, an estimator that returns the value 3 is bad. Still,
it will be helpful for us to formally define and explore some properties
of estimators that will allow us to compare them and choose the good
over the bad.
\hypertarget{samples-and-populations}{%
\section{Samples and populations}\label{samples-and-populations}}
For most of this class, we'll focus on a relatively simple setting where
we have a set of random vectors \(\{X_1, \ldots, X_n\}\) that are
\textbf{independent and identically distributed} (iid) draws from a
distribution with cumulative distribution function (cdf) \(F\). They are
independent in that the random vectors \(X_i\) and \(X_j\) are
independent for all \(i \neq j\), and they are ``identically
distributed'' in the sense that each of the random variables \(X_i\)
have the same marginal distribution, \(F\).
You can think of each vector, \(X_i\), as the rows in your data frame.
Note that we're being purposely vague about this cdf---it simply
represents the unknown distribution of the data, otherwise known as the
\textbf{data generating process} (DGP). Sometimes \(F\) is also referred
to as the \textbf{population distribution} or even just
\textbf{population}, which has its roots in viewing the data as a random
sample from some larger population. As a shorthand, we often say that
the collection of random vectors \(\{X_1, \ldots, X_n\}\) is a
\textbf{random sample} from population \(F\) if \(\{X_1, \ldots, X_n\}\)
is iid with distribution \(F\). The \textbf{sample size} \(n\) is the
number of units in the sample.
Two metaphors can help build intuition about the concept of viewing the
data as an iid draw from \(F\):
\begin{enumerate}
\def\labelenumi{\arabic{enumi}.}
\tightlist
\item
\textbf{Random sampling}. Suppose we have a population of size \(N\)
that is much larger than our sample size \(n\), and we take a simple
random sample of size \(n\) from this population. Then the
distribution of the data in the random sample will be iid draws from
the population distribution of the variables we are sampling. For
instance, suppose we take a random sample from a population of US
citizens where the population proportion of Democratic party
identifiers is 0.33. Then if we randomly sample \(n = 100\) US
citizens, each data point \(X_i\) will be distributed Bernoulli with
probability of success 0.33.
\item
\textbf{Groundhog Day}. Random sampling does not always make sense as
a justification for iid data, especially when the units are not
samples at all but rather countries, states, or subnational units. In
this case, we have to appeal to a thought experiment where \(F\)
represents the fundamental uncertainty in the data-generating process.
The metaphor here is that if we could re-run history many times, like
the 1993 American classic comedy \emph{Groundhog Day}, data and
outcomes would change slightly due to the inherently stochastic nature
of the world. The iid assumption, then, is that each of the units in
our data has the same DGP producing this data or the same distribution
of outcomes under the \emph{Groundhog Day} scenario.{[}1{]}
\end{enumerate}
Note that there are many situations where the iid assumption is not
appropriate. We will cover some of those later in the semester. But much
of the innovation and growth in statistics over the last 50 years has
been figuring out how to perform statistical inference when iid does not
hold. Often, the solutions are specific to the type of iid violation you
have (spatial, time-series, network, or clustered). As a rule of thumb,
though, if you suspect iid is incorrect, your uncertainty statements
will likely be overconfident (for example, confidence intervals, which
we'll cover later, are too small).
\hypertarget{point-estimation}{%
\section{Point estimation}\label{point-estimation}}
\hypertarget{quantities-of-interest}{%
\subsection{Quantities of interest}\label{quantities-of-interest}}
We aim to learn about the data-generating process, represented by the
cdf, \(F\). We might be interested in estimating the cdf at a general
level or only some feature of the distribution, like a mean or
conditional expectation function. We will almost always have a
particular quantity in mind, but we'll introduce estimation at a general
level. So we'll let \(\theta\) represent the quantity of interest.
\textbf{Point estimation} describes how we obtain a single ``best
guess'' about \(\theta\).
\begin{tcolorbox}[enhanced jigsaw, title=\textcolor{quarto-callout-note-color}{\faInfo}\hspace{0.5em}{Note}, breakable, titlerule=0mm, opacityback=0, rightrule=.15mm, bottomrule=.15mm, colframe=quarto-callout-note-color-frame, coltitle=black, colbacktitle=quarto-callout-note-color!10!white, bottomtitle=1mm, toptitle=1mm, colback=white, arc=.35mm, opacitybacktitle=0.6, toprule=.15mm, leftrule=.75mm, left=2mm]
Some refer to quantities of interest as \textbf{parameters} or
\textbf{estimands} (that is, the target of estimation).
\end{tcolorbox}
\leavevmode\vadjust pre{\hypertarget{exm-prop}{}}%
\begin{example}[Population mean]\label{exm-prop}
Suppose we wanted to know the proportion of US citizens who support
increasing legal immigration in the US, which we denote as \(Y_i = 1\).
Then our quantity of interest is the mean of this random variable,
\(\mu = \E[Y_i]\), which is the probability of randomly drawing someone
from the population supporting increased legal immigration.
\end{example}
\leavevmode\vadjust pre{\hypertarget{exm-var}{}}%
\begin{example}[Population variance]\label{exm-var}
Feeling thermometer scores are a prevalent way to assess how a survey
respondent feels about a particular person or group. A survey asks
respondents how warmly they feel about a group from 0 to 100, which we
will denote \(Y_i\). We might be interested in how polarized views are
on a group in the population, and one measure of polarization could be
the variance, or spread, of the distribution of \(Y_i\) around the mean.
In this case, \(\sigma^2 = \V[Y_i]\) would be our quantity of interest.
\end{example}
\leavevmode\vadjust pre{\hypertarget{exm-rct-ii}{}}%
\begin{example}[RCT continued]\label{exm-rct-ii}
In Example~\ref{exm-rct}, we discussed a typical estimator for an
experimental study with a binary treatment. The goal of that experiment
is to learn about the difference between two conditional probabilities
(or expectations): the average support for increasing legal immigration
in the treatment group, \(\mu_1 = \E[Y_i \mid D_i = 1]\), and the same
average in the control group, \(\mu_0 = \E[Y_i \mid D_i = 0]\). This
difference, \(\mu_1 - \mu_0\), is a function of unknown features of
these two conditional distributions.
\end{example}
Each of these is a function of the (possibly joint) distribution of the
data, \(F\). In each of these, we are not necessarily interested in the
entire distribution, just summaries of it (central tendency, spread). Of
course, there are situations where we are also interested in the
complete distribution.
\hypertarget{estimators}{%
\subsection{Estimators}\label{estimators}}
When our sample size is more than a few observations, it makes no sense
to work with the raw data, \(X_1, \ldots, X_n\), and we inevitably will
need to \emph{summarize} the data in some way. We can represent this
summary as a function, \(g(x_1, \ldots, x_n)\), which might be the
formula for the sample mean or sample variance. This function is just a
regular function that takes in \(n\) numbers (or vectors) and returns a
number (or vector). We can also define a random variable based on this
function, \(Y = g(X_1, \ldots, X_n)\), which inherits its randomness
from the randomness of the data. Before we see the data, we don't know
what values of \(X_1, \ldots, X_n\) we will see, so we don't know what
value of \(Y\) we'll see either. We call the random variable
\(Y = g(X_1, \ldots, X_n)\) a \textbf{statistic} (or sometimes sample
statistics), and we refer to the probability distribution of a statistic
\(Y\) as the \textbf{sampling distribution} of \(Y\).
\begin{tcolorbox}[enhanced jigsaw, title=\textcolor{quarto-callout-warning-color}{\faExclamationTriangle}\hspace{0.5em}{Warning}, breakable, titlerule=0mm, opacityback=0, rightrule=.15mm, bottomrule=.15mm, colframe=quarto-callout-warning-color-frame, coltitle=black, colbacktitle=quarto-callout-warning-color!10!white, bottomtitle=1mm, toptitle=1mm, colback=white, arc=.35mm, opacitybacktitle=0.6, toprule=.15mm, leftrule=.75mm, left=2mm]
There is one potential confusion in how we talk about ``statistics.''
Just above, we defined a statistic as a random variable based on it
being a function of random variables (the data). But we sometimes refer
to the calculated value as a statistic as well, which is a specific
number that you see in your R output. To be precise, we should call the
latter the \textbf{realized value} of the statistic, but message
discipline is difficult to enforce in this context. A simple example
might help. Suppose that \(X_1\) and \(X_2\) are the results of a roll
of two standard six-sided dice. Then the statistic \(Y = X_1 + X_2\) is
a random variable that has a distribution over the numbers from \{2,
\ldots, 12\} that describes our uncertainty over what the sum will be
\emph{before we roll the dice}. Once we have rolled the dice and
observed the realized values \(X_1 = 3\) and \(X_2 = 4\), we observed
the realized value of the statistic, \(Y = 7\).
\end{tcolorbox}
At their most basic, statistics are just data summaries without aim or
ambition. Estimators are statistics with a purpose: to provide an
``educated guess'' about some quantity of interest.
\leavevmode\vadjust pre{\hypertarget{def-estimator}{}}%
\begin{definition}[]\label{def-estimator}
An \textbf{estimator} \(\widehat{\theta}_n = \theta(X_1, \ldots, X_n)\)
for some parameter \(\theta\), is a statistic intended as a guess about
\(\theta\).
\end{definition}
One important distinction of jargon is between an estimator and an
estimate, similar to the issues with ``statistic'' described above. The
estimator is a function of the data, whereas the \textbf{estimate} is
the \emph{realized value} of the estimator once we see the data. An
estimate is a single number, such as 0.38, whereas the estimator is a
random variable that has uncertainty over what value it will take.
Formally, the estimate is \(\theta(x_1, \ldots, x_n)\) when the data is
\(\{X_1, \ldots, X_n\} = \{x_1, \ldots, x_n\}\), whereas we represent
the estimator as a function of random variables,
\(\widehat{\theta}_n = \theta(X_1, \ldots, X_n)\).
\begin{tcolorbox}[enhanced jigsaw, title=\textcolor{quarto-callout-note-color}{\faInfo}\hspace{0.5em}{Note}, breakable, titlerule=0mm, opacityback=0, rightrule=.15mm, bottomrule=.15mm, colframe=quarto-callout-note-color-frame, coltitle=black, colbacktitle=quarto-callout-note-color!10!white, bottomtitle=1mm, toptitle=1mm, colback=white, arc=.35mm, opacitybacktitle=0.6, toprule=.15mm, leftrule=.75mm, left=2mm]
It is widespread, though not universal, to use the ``hat'' notation to
define an estimator and its estimand. For example, \(\widehat{\theta}\)
(or ``theta hat'') indicates that this estimator is targeting the
parameter \(\theta\).
\end{tcolorbox}
\leavevmode\vadjust pre{\hypertarget{exm-mean-est}{}}%
\begin{example}[Estimators for the population mean]\label{exm-mean-est}
Suppose we would like to estimate the population mean of \(F\), which we
will represent as \(\mu = \E[X_i]\). We could choose from several
estimators, all with different properties. \[
\widehat{\theta}_{n,1} = \frac{1}{n} \sum_{i=1}^n X_i, \quad \widehat{\theta}_{n,2} = X_1, \quad \widehat{\theta}_{n,3} = \text{max}(X_1,\ldots,X_n), \quad \widehat{\theta}_{n,4} = 3
\] The first is just the sample mean, which is an intuitive and natural
estimator for the population mean. The second just uses the first
observation. While this seems silly, this is a valid statistic (it's a
function of the data!). The third takes the maximum value in the sample,
and the fourth always returns three, regardless of the data.
\end{example}
\hypertarget{how-to-find-estimators}{%
\section{How to find estimators}\label{how-to-find-estimators}}
Where do estimators come from? There are a couple of different methods
that I'll cover briefly here before describing the ones that will form
the bulk of this class.
\hypertarget{parametric-models-and-maximum-likelihood}{%
\subsection{Parametric models and maximum
likelihood}\label{parametric-models-and-maximum-likelihood}}
The first method for generating estimators relies on \textbf{parametric
models}, where the researcher specifies the exact distribution (up to
some unknown parameters) of the DGP. Let \(\theta\) be the parameters of
this distribution and we then write \(\{X_1, \ldots, X_n\}\) are iid
draws from \(F_{\theta}\). We should also formally state the set of
possible values the parameters can take, which we call the
\textbf{parameter space} and usually denote as \(\Theta\). Because we're
assuming we know the distribution of the data, we can write the p.d.f.
as \(f(X_i \mid \theta)\) and define the likelihood function as the
product of these p.d.f.s over the units as a function of the parameters:
\[
L(\theta) = \prod_{i=1}^n f(X_i \mid \theta).
\] We can then define the \textbf{maximum likelihood} estimator (MLE)
for \(\theta\) as the values of the parameter that, well, maximize the
likelihood: \[
\widehat{\theta}_{mle} = \argmax_{\theta \in \Theta} \; L(\theta)
\] Sometimes we can use calculus to derive a closed-form expression for
the MLE. Still, we often use iterative techniques that search the
parameter space for the maximum.
Maximum likelihood estimators have very nice properties, especially in
large samples. Unfortunately, it also requires the correct knowledge of
the parametric model, which is often difficult to justify. Do we really
know if we should model a given event count variable as Poisson or
Negative Binomial? The attractive properties of MLE are only as good as
our ability to specify the parametric model.
\begin{tcolorbox}[enhanced jigsaw, title=\textcolor{quarto-callout-note-color}{\faInfo}\hspace{0.5em}{No free lunch}, breakable, titlerule=0mm, opacityback=0, rightrule=.15mm, bottomrule=.15mm, colframe=quarto-callout-note-color-frame, coltitle=black, colbacktitle=quarto-callout-note-color!10!white, bottomtitle=1mm, toptitle=1mm, colback=white, arc=.35mm, opacitybacktitle=0.6, toprule=.15mm, leftrule=.75mm, left=2mm]
One essential intuition to build about statistics is the
\textbf{assumptions-precision tradeoff}. You can usually get more
precise estimates if you make stronger and potentially more fragile
assumptions. Conversely, you will almost always get less accurate
estimates if you weaken your assumptions.
\end{tcolorbox}
\hypertarget{plug-in-estimators}{%
\subsection{Plug-in estimators}\label{plug-in-estimators}}
The second broad class of estimators is \textbf{semiparametric} in that
we will specify some finite-dimensional parameters of the DGP but leave
the rest of the distribution unspecified. For example, we might define a
population mean, \(\mu = \E[X_i]\), and a population variance,
\(\sigma^2 = \V[X_i]\) but leave unrestricted the shape of the
distribution. This approach ensures that our estimators will be less
dependent on correctly specifying distributions we have little intuition
about.
The primary method for constructing estimators in this setting is to use
the \textbf{plug-in estimator}, or the estimator that replaces any
population mean with a sample mean. Obviously, in the case of estimating
the population mean, \(\mu\), this means we will use the \textbf{sample
mean} as its estimate: \[
\Xbar_n = \frac{1}{n} \sum_{i=1}^n X_i \quad \text{estimates} \quad \E[X_i] = \int_{\mathcal{X}} x f(x)dx
\] What are we doing here? We are replacing the unknown population
distribution \(f(x)\) in the population mean with a discrete uniform
distribution over our data points, with \(1/n\) probability assigned to
each unit. Why do this? It encodes that if we have a random sample, our
best guess about the population distribution of \(X_i\) is the sample
distribution in our actual data. If this intuition fails, you can hold
onto an analog principle: sample means of random variables are natural
estimators of population means.
What about estimating something more complicated, like the expected
value of a function of the data, \(\theta = \E[r(X_i)]\)? The key is to
see that \(f(X_i)\) is also a random variable. Let's call this random
variable \(Y_i = f(X_i)\). Now we can see that \(\theta\) is just the
population expectation of this random variable, and using the plug-in
estimator, we get: \[
\widehat{\theta} = \frac{1}{n} \sum_{i=1}^n Y_i = \frac{1}{n} \sum_{i=1}^n r(X_i).
\]
With these facts in hand, we can describe the more general plug-in
estimator. When we want to estimate some quantity of interest that is a
function of population means, we can generate a plug-in estimator by
replacing any population mean with a sample mean. Formally, let
\(\alpha = g\left(\E[r(X_i)]\right)\) be a parameter that is defined as
a function of the population mean of a (possibly vector-valued) function
of the data. Then, we can estimate this parameter by plugging in the
sample mean for the population mean to get the \textbf{plug-in
estimator}, \[
\widehat{\alpha} = g\left( \frac{1}{n} \sum_{i=1}^n r(X_i) \right) \quad \text{estimates} \quad \alpha = g\left(\E[r(X_i)]\right)
\] This approach to plug-in estimation with sample means is very general
and will allow us to derive estimators in various settings.
\leavevmode\vadjust pre{\hypertarget{exm-var-est}{}}%
\begin{example}[Estimating population variance]\label{exm-var-est}
The population variance of a random variable is
\(\sigma^2 = \E[(X_i - \E[X_i])^2]\). To derive a plug-in estimator for
this quantity, we replace the inner \(\E[X_i]\) with \(\Xbar_n\) and the
outer expectation with another sample mean: \[
\widehat{\sigma}^2 = \frac{1}{n} \sum_{i=1}^n (X_i - \Xbar_n)^2.
\] This plug-in estimator differs from the standard sample variance,
which divides by \(n - 1\) rather than \(n\). This minor difference does
not matter in moderate to large samples.
\end{example}
\leavevmode\vadjust pre{\hypertarget{exm-cov-est}{}}%
\begin{example}[Estimating population covariance]\label{exm-cov-est}
Suppose we have two variables, \((X_i, Y_i)\). A natural quantity of
interest here is the population covariance between these variables, \[
\sigma_{xy} = \text{Cov}[X_i,Y_i] = \E[(X_i - \E[X_i])(Y_i-\E[Y_i])],
\] which has the plug-in estimator, \[
\widehat{\sigma}_{xy} = \frac{1}{n} \sum_{i=1}^n (X_i - \Xbar_n)(Y_i - \Ybar_n).
\]
\end{example}
\begin{tcolorbox}[enhanced jigsaw, title=\textcolor{quarto-callout-note-color}{\faInfo}\hspace{0.5em}{Notation alert}, breakable, titlerule=0mm, opacityback=0, rightrule=.15mm, bottomrule=.15mm, colframe=quarto-callout-note-color-frame, coltitle=black, colbacktitle=quarto-callout-note-color!10!white, bottomtitle=1mm, toptitle=1mm, colback=white, arc=.35mm, opacitybacktitle=0.6, toprule=.15mm, leftrule=.75mm, left=2mm]
Given the connection between the population mean and the sample mean,
you will sometimes see the \(\E_n[\cdot]\) operator used as a shorthand
for the sample average: \[
\E_n[r(X_i)] \equiv \frac{1}{n} \sum_{i=1}^n r(X_i).
\]
\end{tcolorbox}
Finally, plug-in estimation goes beyond just replacing population means
with sample means. We can derive estimators of the population quantiles
like the median with sample versions of those quantities. What unifies
all of these approaches is replacing the unknown population cdf, \(F\),
with the empirical cdf, \[
\widehat{F}_n(x) = \frac{\sum_{i=1}^n \mathbb{I}(X_i \leq x)}{n}.
\] For a more complete and technical treatment of these ideas, see
Wasserman (2004) Chapter 7.
\hypertarget{the-three-distributions-population-empirical-and-sampling}{%
\section{The three distributions: population, empirical, and
sampling}\label{the-three-distributions-population-empirical-and-sampling}}
Once we start to wade into estimation, there are several distributions
to keep track of, and things can quickly become confusing. Three
specific distributions are all related and easy to confuse, but keeping
them distinct is crucial.
The \textbf{population distribution} is the distribution of the random
variable, \(X_i\), which we have labeled \(F\) and is our target of
inference. Then there is the \textbf{empirical distribution}, which is
the distribution of the actual realizations of the random variables in
our samples (that is, the numbers in our data frame),
\(X_1, \ldots, X_n\). Because this is a random sample from the
population distribution and can serve as an estimator of \(F\), we
sometimes call this \(\widehat{F}_n\).
\textbf{Insert Sampling distribution figure here}
Separately from both is the \textbf{sampling distribution of an
estimator}, which is the probability distribution of
\(\widehat{\theta}_n\). It represents our uncertainty about our estimate
before we see the data. Remember that our estimator is itself a random
variable because it is a function of random variables: the data itself.
That is, we defined the estimator as
\(\widehat{\theta}_n = \theta(X_1, \ldots, X_n)\).
\leavevmode\vadjust pre{\hypertarget{exm-three-dist}{}}%
\begin{example}[Likert responses]\label{exm-three-dist}
Suppose \(X_i\) is the answer to a question, ``How much do you agree
with the following statement: Immigrants are a net positive for the
United States,'' with a \(X_i = 0\) being ``strongly disagree,''
\(X_i = 1\) being ``disagree,'' \(X_i = 2\) being ``neither agree nor
disagree,'' \(X_i = 3\) being ``agree,'' and \(X_i = 4\) being
``strongly agree.''
The population distribution describes the probability of randomly
selecting a person with each one of these values, \(\P(X_i = x)\). The
empirical distribution would be the fraction of our data taking each
value. And the sampling distribution of the sample mean, \(\Xbar_n\),
would be the distribution of the sample mean across repeated samples
from the population.
Suppose the population distribution was binomial with four trials and
probability of success \(p = 0.4\). We could generate one sample with
\(n = 10\) and thus one empirical distribution using \texttt{rbinom}:
\begin{Shaded}
\begin{Highlighting}[]
\NormalTok{my\_samp }\OtherTok{\textless{}{-}} \FunctionTok{rbinom}\NormalTok{(}\AttributeTok{n =} \DecValTok{10}\NormalTok{, }\AttributeTok{size =} \DecValTok{4}\NormalTok{, }\AttributeTok{prob =} \FloatTok{0.4}\NormalTok{)}
\NormalTok{my\_samp}
\end{Highlighting}
\end{Shaded}
\begin{verbatim}
[1] 1 2 1 3 3 0 2 3 2 1
\end{verbatim}
\begin{Shaded}
\begin{Highlighting}[]
\FunctionTok{table}\NormalTok{(my\_samp)}
\end{Highlighting}
\end{Shaded}
\begin{verbatim}
my_samp
0 1 2 3
1 3 3 3
\end{verbatim}
And we can generate one draw from the sampling distribution of
\(\Xbar_n\) by taking the mean of this sample:
\begin{Shaded}
\begin{Highlighting}[]
\FunctionTok{mean}\NormalTok{(my\_samp)}
\end{Highlighting}
\end{Shaded}
\begin{verbatim}
[1] 1.8
\end{verbatim}
But, if we had a different sample, it would have a different empirical
distribution and thus give us a different estimate of the sample mean:
\begin{Shaded}
\begin{Highlighting}[]
\NormalTok{my\_samp2 }\OtherTok{\textless{}{-}} \FunctionTok{rbinom}\NormalTok{(}\AttributeTok{n =} \DecValTok{10}\NormalTok{, }\AttributeTok{size =} \DecValTok{4}\NormalTok{, }\AttributeTok{prob =} \FloatTok{0.4}\NormalTok{)}
\FunctionTok{mean}\NormalTok{(my\_samp2) }
\end{Highlighting}
\end{Shaded}
\begin{verbatim}
[1] 1.6
\end{verbatim}
The sampling distribution is the distribution of these sample means
across repeated sampling.
\end{example}
\hypertarget{finite-sample-properties-of-estimators}{%
\section{Finite-sample properties of
estimators}\label{finite-sample-properties-of-estimators}}
As we discussed when we introduced estimators, their usefulness depends
on how well they help us learn about the quantity of interest. If we get
an estimate \(\widehat{\theta} = 1.6\), we would like to know that this
is ``close'' to the true parameter \(\theta\). The sampling distribution
is the key to answering these questions. Intuitively, we would like the
sampling distribution of \(\widehat{\theta}_n\) to be as tightly
clustered around the true as \(\theta\) as possible. Here, though, we
run into a problem: the sampling distribution depends on the population
distribution since it is about repeated samples of the data from that
distribution filtered through the function \(\theta()\). Since \(F\) is
unknown, this implies that the sampling distribution will also usually
be unknown.
Even though we cannot precisely pin down the entire sampling
distribution, we can use assumptions to derive specific properties of
the sampling distribution that will be useful in comparing estimators.
\hypertarget{bias}{%
\subsection{Bias}\label{bias}}
The first property of the sampling distribution concerns its central
tendency. In particular, we will define the \textbf{bias} (or
\textbf{estimation bias}) of estimator \(\widehat{\theta}\) for
parameter \(\theta\) as \[
\text{bias}[\widehat{\theta}] = \E[\widehat{\theta}] - \theta,
\] which is the difference between the mean of the estimator (across
repeated samples) and the true parameter. All else equal, we would like
estimation bias to be as small as possible. The smallest possible bias,
obviously, is 0, and we define an \textbf{unbiased estimator} as one
with \(\text{bias}[\widehat{\theta}] = 0\) or equivalently,
\(\E[\widehat{\theta}] = \theta\).
However, all else is not always equal, and unbiasedness is not a
property to become overly attached to. Many biased estimators have other
attractive properties, and many popular modern estimators are biased.
\leavevmode\vadjust pre{\hypertarget{exm-mean-unbiased}{}}%
\begin{example}[Unbiasedness of the sample
mean]\label{exm-mean-unbiased}
We can show that the sample mean is unbiased for the population mean
when the data is iid and \(\E|X| < \infty\). In particular, we simply
apply the rules of expectations: \[\begin{aligned}
\E\left[ \Xbar_n \right] &= \E\left[\frac{1}{n} \sum_{i=1}^n X_i\right] & (\text{definition of } \Xbar_n) \\
&= \frac{1}{n} \sum_{i=1}^n \E[X_i] & (\text{linearity of } \E)\\
&= \frac{1}{n} \sum_{i=1}^n \mu & (X_i \text{ identically distributed})\\
&= \mu.
\end{aligned}\] Notice that we only used the ``identically distributed''
part of iid. Independence is not needed.
\end{example}
\begin{tcolorbox}[enhanced jigsaw, title=\textcolor{quarto-callout-warning-color}{\faExclamationTriangle}\hspace{0.5em}{Warning}, breakable, titlerule=0mm, opacityback=0, rightrule=.15mm, bottomrule=.15mm, colframe=quarto-callout-warning-color-frame, coltitle=black, colbacktitle=quarto-callout-warning-color!10!white, bottomtitle=1mm, toptitle=1mm, colback=white, arc=.35mm, opacitybacktitle=0.6, toprule=.15mm, leftrule=.75mm, left=2mm]
Properties like unbiasedness might only hold for a subset of DGPs. For
example, we just showed that the sample mean is unbiased, but only when
the population mean is finite. There are probability distributions like
the Cauchy where the expected value diverges and is not finite. So we
are dealing with a restricted class of DGPs that rules out such
distributions. You may see this sometimes formalized by defining a class
\(\mathcal{F}\) of distributions, and unbiasedness might hold in that
class if it is unbiased for all \(F \in \mathcal{F}\).