|
|
xiii | |
|
|
xv | |
Preface |
|
xvii | |
Preface to the Original Book |
|
xix | |
|
|
1 | (37) |
|
|
3 | (4) |
|
|
7 | (1) |
|
1.3 Introduction to R and the tidyverse |
|
|
8 | (25) |
|
1.3.1 Arithmetic Operations: R as a Calculator |
|
|
9 | (1) |
|
|
10 | (1) |
|
|
11 | (2) |
|
|
13 | (2) |
|
|
15 | (2) |
|
|
17 | (3) |
|
1.3.7 Data Files: Loading and Subsetting |
|
|
20 | (7) |
|
|
27 | (1) |
|
1.3.9 Data Frames: Summarizing |
|
|
28 | (2) |
|
|
30 | (1) |
|
1.3.11 Loading Data in Other Formats |
|
|
31 | (1) |
|
1.3.12 Programming and Learning Tips |
|
|
32 | (1) |
|
|
33 | (1) |
|
|
34 | (4) |
|
1.5.1 Bias in Self-Reported Turnout |
|
|
34 | (1) |
|
1.5.2 Understanding World Population Dynamics |
|
|
35 | (3) |
|
|
38 | (50) |
|
2.1 Racial Discrimination in the Labor Market |
|
|
38 | (7) |
|
|
45 | (11) |
|
2.2.1 Logical Values and Operators |
|
|
46 | (2) |
|
2.2.2 Relational Operators |
|
|
48 | (1) |
|
|
49 | (4) |
|
2.2.4 Simple Conditional Statements |
|
|
53 | (1) |
|
|
53 | (3) |
|
2.3 Causal Effects and the Counterfactual |
|
|
56 | (2) |
|
2.4 Randomized Controlled Trials |
|
|
58 | (7) |
|
2.4.1 The Role of Randomization |
|
|
59 | (1) |
|
2.4.2 Social Pressure and Voter Turnout |
|
|
60 | (5) |
|
2.5 Observational Studies |
|
|
65 | (10) |
|
2.5.1 Minimum Wage and Unemployment |
|
|
65 | (3) |
|
|
68 | (3) |
|
2.5.3 Before-and-After and Difference-in-Differences Designs |
|
|
71 | (4) |
|
2.6 Descriptive Statistics for a Single Variable |
|
|
75 | (6) |
|
|
75 | (3) |
|
|
78 | (3) |
|
|
81 | (1) |
|
|
82 | (6) |
|
2.8.1 Efficacy of Small Class Size in Early Education |
|
|
82 | (2) |
|
2.8.2 Changing Minds on Gay Marriage |
|
|
84 | (1) |
|
2.8.3 Success of Leader Assassination as a Natural Experiment |
|
|
85 | (3) |
|
|
88 | (56) |
|
3.1 Measuring Civilian Victimization during Wartime |
|
|
88 | (5) |
|
3.2 Handling Missing Data in R |
|
|
93 | (3) |
|
3.3 Visualizing the Univariate Distribution |
|
|
96 | (10) |
|
|
97 | (3) |
|
|
100 | (3) |
|
|
103 | (2) |
|
3.3.4 Printing and Saving Graphs |
|
|
105 | (1) |
|
|
106 | (8) |
|
3.4.1 The Role of Randomization |
|
|
107 | (4) |
|
3.4.2 Nonresponse and Other Sources of Bias |
|
|
111 | (3) |
|
3.5 Measuring Political Polarization |
|
|
114 | (2) |
|
3.6 Summarizing Bivariate Relationships |
|
|
116 | (8) |
|
|
116 | (4) |
|
|
120 | (4) |
|
3.7 Quantile-Quantile Plot |
|
|
124 | (4) |
|
|
128 | (8) |
|
|
128 | (2) |
|
|
130 | (1) |
|
3.8.3 The k-Means Algorithm |
|
|
131 | (5) |
|
|
136 | (1) |
|
|
137 | (7) |
|
3.10.1 Changing Minds on Gay Marriage: Revisited |
|
|
137 | (2) |
|
3.10.2 Political Efficacy in China and Mexico |
|
|
139 | (2) |
|
3.10.3 Voting in the United Nations General Assembly |
|
|
141 | (3) |
|
|
144 | (72) |
|
4.1 Predicting Election Outcomes |
|
|
144 | (18) |
|
|
145 | (3) |
|
4.1.2 General Conditional Statements in R |
|
|
148 | (4) |
|
|
152 | (10) |
|
|
162 | (26) |
|
4.2.1 Facial Appearance and Election Outcomes |
|
|
162 | (3) |
|
4.2.2 Correlation and Scatter Plots |
|
|
165 | (1) |
|
|
166 | (7) |
|
4.2.4 Regression towards the Mean |
|
|
173 | (1) |
|
4.2.5 Merging Data Sets in R |
|
|
174 | (7) |
|
|
181 | (7) |
|
4.3 Regression and Causation |
|
|
188 | (1) |
|
4.4 Randomized Experiments |
|
|
188 | (21) |
|
4.4.1 Regression with Multiple Predictors |
|
|
191 | (6) |
|
4.4.2 Heterogeneous Treatment Effects |
|
|
197 | (6) |
|
4.4.3 Regression Discontinuity Design |
|
|
203 | (6) |
|
|
209 | (1) |
|
|
209 | (7) |
|
4.6.1 Prediction Based on Betting Markets |
|
|
209 | (2) |
|
4.6.2 Election and Conditional Cash Transfer Program in Mexico |
|
|
211 | (3) |
|
4.6.3 Government Transfer and Poverty Reduction in Brazil |
|
|
214 | (2) |
|
|
216 | (63) |
|
|
216 | (22) |
|
5.1.1 The Disputed Authorship of The Federalist Papers |
|
|
216 | (5) |
|
5.1.2 Document-Term Matrix |
|
|
221 | (2) |
|
|
223 | (9) |
|
5.1.4 Authorship Prediction |
|
|
232 | (3) |
|
|
235 | (3) |
|
|
238 | (17) |
|
5.2.1 Marriage Network in Renaissance Florence |
|
|
238 | (2) |
|
5.2.2 Undirected Graph and Centrality Measures |
|
|
240 | (5) |
|
5.2.3 Twitter-Following Network |
|
|
245 | (2) |
|
5.2.4 Directed Graph and Centrality |
|
|
247 | (8) |
|
|
255 | (17) |
|
5.3.1 The 1854 Cholera Outbreak in London |
|
|
256 | (2) |
|
|
258 | (6) |
|
5.3.3 US Presidential Elections |
|
|
264 | (4) |
|
5.3.4 Expansion of Walmart |
|
|
268 | (2) |
|
|
270 | (2) |
|
|
272 | (1) |
|
|
273 | (6) |
|
5.5.1 Analyzing the Preambles of Constitutions |
|
|
273 | (2) |
|
5.5.2 International Trade Network |
|
|
275 | (2) |
|
5.5.3 Mapping US Presidential Election Results over Time |
|
|
277 | (2) |
|
|
279 | (78) |
|
|
279 | (12) |
|
6.1.1 Frequentist versus Bayesian |
|
|
279 | (2) |
|
6.1.2 Definition and Axioms |
|
|
281 | (3) |
|
|
284 | (3) |
|
6.1.4 Sampling with and without Replacement |
|
|
287 | (2) |
|
|
289 | (2) |
|
6.2 Conditional Probability |
|
|
291 | (30) |
|
6.2.1 Conditional, Marginal, and Joint Probabilities |
|
|
291 | (10) |
|
|
301 | (6) |
|
|
307 | (2) |
|
6.2.4 Predicting Race Using Surname and Residence Location |
|
|
309 | (12) |
|
6.3 Random Variables and Probability Distributions |
|
|
321 | (21) |
|
|
321 | (1) |
|
6.3.2 Bernoulli and Uniform Distributions |
|
|
321 | (4) |
|
6.3.3 Binomial Distribution |
|
|
325 | (3) |
|
6.3.4 Normal Distribution |
|
|
328 | (7) |
|
6.3.5 Expectation and Variance |
|
|
335 | (4) |
|
6.3.6 Predicting Election Outcomes with Uncertainty |
|
|
339 | (3) |
|
6.4 Large Sample Theorems |
|
|
342 | (8) |
|
6.4.1 The Law of Large Numbers |
|
|
342 | (3) |
|
6.4.2 The Central Limit Theorem |
|
|
345 | (5) |
|
|
350 | (1) |
|
|
350 | (7) |
|
6.6.1 The Mathematics of Enigma |
|
|
350 | (2) |
|
6.6.2 A Probability Model for Betting Market Election Prediction |
|
|
352 | (2) |
|
6.6.3 Election Fraud in Russia |
|
|
354 | (3) |
|
|
357 | (89) |
|
|
357 | (33) |
|
7.1.1 Unbiasedness and Consistency |
|
|
358 | (8) |
|
|
366 | (5) |
|
7.1.3 Confidence Interval |
|
|
371 | (7) |
|
7.1.4 Margin of Error and Sample Size Calculation in Polls |
|
|
378 | (5) |
|
7.1.5 Analysis of Randomized Controlled Trials |
|
|
383 | (3) |
|
7.1.6 Analysis Based on Student's t-Distribution |
|
|
386 | (4) |
|
|
390 | (28) |
|
7.2.1 Tea-Tasting Experiment |
|
|
390 | (4) |
|
7.2.2 The General Framework |
|
|
394 | (3) |
|
|
397 | (7) |
|
|
404 | (5) |
|
7.2.5 Pitfalls of Hypothesis Testing |
|
|
409 | (2) |
|
|
411 | (7) |
|
7.3 Linear Regression Model with Uncertainty |
|
|
418 | (21) |
|
7.3.1 Linear Regression as a Generative Model |
|
|
418 | (5) |
|
7.3.2 Unbiasedness of Estimated Coefficients |
|
|
423 | (3) |
|
7.3.3 Standard Errors of Estimated Coefficients |
|
|
426 | (2) |
|
7.3.4 Inference about Coefficients |
|
|
428 | (4) |
|
7.3.5 Inference about Predictions |
|
|
432 | (7) |
|
|
439 | (1) |
|
|
439 | (7) |
|
7.5.1 Sex Ratio and the Price of Agricultural Crops in China |
|
|
439 | (2) |
|
7.5.2 Filedrawer and Publication Bias in Academic Research |
|
|
441 | (2) |
|
7.5.3 Analysis of the 1933 German Election during the Weimar Republic |
|
|
443 | (3) |
|
|
446 | (3) |
General Index |
|
449 | (6) |
R Index |
|
455 | |