Preface....11
Introduction....13
Getting Started....13
Software....13
Python Scripts....14
Modules ....18
File Names and the Working Directory....19
Errors and Warnings....19
Other Resources....20
Objects in Python....21
Variables....21
Objects in Python....21
Objects in numpy....25
Objects in pandas....29
External Data....33
Data Sets in the Examples....33
Import and Export of Data Files....34
Data from other Sources....36
Base Graphics with matplotlib....37
Basic Graphs....37
Customizing Graphs with Options....39
Overlaying Several Plots....40
Exporting to a File....41
Descriptive Statistics....43
Discrete Distributions: Frequencies and Contingency Tables....43
Continuous Distributions: Histogram and Density....48
Empirical Cumulative Distribution Function (ECDF)....50
Fundamental Statistics....52
Probability Distributions....54
Discrete Distributions....54
Continuous Distributions....57
Cumulative Distribution Function (CDF)....57
Random Draws from Probability Distributions....60
Confidence Intervals and Statistical Inference....62
Confidence Intervals....62
t Tests....65
p Values....67
Advanced Python....70
Conditional Execution....70
Loops....70
Functions....71
Object Orientation....72
Outlook....76
Monte Carlo Simulation....76
Finite Sample Properties of Estimators....76
Asymptotic Properties of Estimators....79
Simulation of Confidence Intervals and t Tests....80
Regression Analysis with Cross-Sectional Data....85
The Simple Regression Model....87
Simple OLS Regression....87
Coefficients, Fitted Values, and Residuals....92
Goodness of Fit....95
Nonlinearities....98
Regression through the Origin and Regression on a Constant....99
Expected Values, Variances, and Standard Errors....101
Monte Carlo Simulations....104
One Sample....104
Many Samples....106
Violation of SLR.4 ....108
Violation of SLR.5 ....109
Multiple Regression Analysis: Estimation....111
Multiple Regression in Practice....111
OLS in Matrix Form....117
Ceteris Paribus Interpretation and Omitted Variable Bias....120
Standard Errors, Multicollinearity, and VIF....122
Multiple Regression Analysis: Inference....125
The t Test....125
General Setup....125
Standard Case....126
Other Hypotheses....128
Confidence Intervals....131
Linear Restrictions: F-Tests....133
Multiple Regression Analysis: OLS Asymptotics....137
Simulation Exercises....137
Normally Distributed Error Terms....137
Non-Normal Error Terms....138
(Not) Conditioning on the Regressors....142
LM Test....145
Multiple Regression Analysis: Further Issues....147
Model Formulae....147
Data Scaling: Arithmetic Operations Within a Formula....147
Standardization: Beta Coefficients....148
Logarithms....150
Quadratics and Polynomials....150
Hypothesis Testing....152
Interaction Terms....153
Prediction....154
Confidence and Prediction Intervals for Predictions....154
Effect Plots for Nonlinear Specifications....157
Multiple Regression Analysis with Qualitative Regressors....161
Linear Regression with Dummy Variables as Regressors....161
Boolean Variables....164
Categorical Variables....165
ANOVA Tables....167
Breaking a Numeric Variable Into Categories....169
Interactions and Differences in Regression Functions Across Groups....171
Heteroscedasticity....175
Heteroscedasticity-Robust Inference....175
Heteroscedasticity Tests....178
Weighted Least Squares....181
More on Specification and Data Issues....187
Functional Form Misspecification....187
Measurement Error....190
Missing Data and Nonrandom Samples....194
Outlying Observations....198
Least Absolute Deviations (LAD) Estimation....200
Regression Analysis with Time Series Data....201
Basic Regression Analysis with Time Series Data....203
Static Time Series Models....203
Time Series Data Types in Python....204
Equispaced Time Series in Python....204
Irregular Time Series in Python....207
Other Time Series Models....209
Finite Distributed Lag Models....209
Trends....211
Seasonality....212
Further Issues in Using OLS with Time Series Data....215
Asymptotics with Time Series....215
The Nature of Highly Persistent Time Series....220
Differences of Highly Persistent Time Series....223
Regression with First Differences....223
Serial Correlation and Heteroscedasticity in Time Series Regressions....227
Testing for Serial Correlation of the Error Term....227
FGLS Estimation....232
Serial Correlation-Robust Inference with OLS....233
Autoregressive Conditional Heteroscedasticity....234
Advanced Topics....237
Pooling Cross-Sections Across Time: Simple Panel Data Methods....239
Pooled Cross-Sections....239
Difference-in-Differences....240
Organizing Panel Data....243
First Differenced Estimator....244
Advanced Panel Data Methods....249
Fixed Effects Estimation....249
Random Effects Models....250
Dummy Variable Regression and Correlated Random Effects....254
Robust (Clustered) Standard Errors....257
Instrumental Variables Estimation and Two Stage Least Squares....259
Instrumental Variables in Simple Regression Models....259
More Exogenous Regressors....261
Two Stage Least Squares....264
Testing for Exogeneity of the Regressors....266
Testing Overidentifying Restrictions....267
Instrumental Variables with Panel Data....269
Simultaneous Equations Models....271
Setup and Notation....271
Estimation by 2SLS....272
Outlook: Estimation by 3SLS....273
Limited Dependent Variable Models and Sample Selection Corrections....275
Binary Responses....275
Linear Probability Models....275
Logit and Probit Models: Estimation....277
Inference....280
Predictions....281
Partial Effects....283
Count Data: The Poisson Regression Model....286
Corner Solution Responses: The Tobit Model....289
Censored and Truncated Regression Models....291
Sample Selection Corrections....296
Advanced Time Series Topics....299
Infinite Distributed Lag Models....299
Testing for Unit Roots....301
Spurious Regression....302
Cointegration and Error Correction Models....305
Forecasting....305
Carrying Out an Empirical Project....309
Working with Python Scripts....309
Logging Output in Text Files....311
Formatted Documents with Jupyter Notebook....312
Getting Started....312
Cells....312
Markdown Basics....313
Appendices....319
Python Scripts....321
Scripts Used in Chapter 01....321
Scripts Used in Chapter 02....344
Scripts Used in Chapter 03....353
Scripts Used in Chapter 04....357
Scripts Used in Chapter 05....359
Scripts Used in Chapter 06....362
Scripts Used in Chapter 07....367
Scripts Used in Chapter 08....371
Scripts Used in Chapter 09....375
Scripts Used in Chapter 10....381
Scripts Used in Chapter 11....384
Scripts Used in Chapter 12....388
Scripts Used in Chapter 13....393
Scripts Used in Chapter 14....396
Scripts Used in Chapter 15....400
Scripts Used in Chapter 16....405
Scripts Used in Chapter 17....406
Scripts Used in Chapter 18....415
Scripts Used in Chapter 19....419
Bibliography....420
List of Wooldridge (2019) Examples....423
Index....425