Transcription of Principles of Econometrics with R - Bookdown
1 Principles of Econometrics with R. Constantin Colonescu 2016-09-01. 2. Contents . 5. 1 Introduction 7. The RStudio Screen .. 8. How to Open a Data File .. 9. Creating Graphs .. 10. An R Cheat Sheet .. 11. 2 The Simple Linear Regression Model 13. The General Model .. 13. Example: Food Expenditure versus Income .. 15. Estimating a Linear Regression .. 15. Prediction with the Linear Regression Model .. 18. Repeated Samples to Assess Regression Coefficients .. 19. Estimated Variances and Covariance of Regression Coefficients.
2 20. Non-Linear Relationships .. 20. Using Indicator Variables in a Regression .. 24. Monte Carlo Simulation .. 25. 3 Interval Estimation and Hypothesis Testing 29. The Estimated Distribution of Regression Coefficients .. 29. Confidence Interval in General .. 30. Example: Confidence Intervals in the food Model .. 31. Confidence Intervals in Repeated Samples .. 32. Hypothesis Tests .. 33. The p-Value .. 38. Testing Linear Combinations of Parameters .. 39. 4 Prediction, R-squared, and Modeling 43. Forecasting (Predicting a Particular Value).
3 43. Goodness-of-Fit .. 47. Linear-Log Models .. 49. 3. 4 CONTENTS. Residuals and Diagnostics .. 51. Polynomial Models .. 55. Log-Linear Models .. 56. The Log-Log Model .. 61. 5 The Multiple Regression Model 65. The General Model .. 65. Example: Big Andy's Hamburger Sales .. 66. Interval Estimation in Multiple Regression .. 71. Hypothesis Testing in Multiple Regression .. 73. Polynomial Regression Models .. 76. Interaction Terms in Linear Regression .. 78. Goodness-of-Fit in Multiple Regression .. 81.
4 6 Further Inference in Multiple Regression 83. Joint Hypotheses and the F-statistic .. 83. Testing Simultaneous Hypotheses .. 84. Omitted Variable Bias .. 88. Irrelevant Variables .. 90. Model Selection Criteria .. 91. Collinearity .. 94. Prediction and Forecasting .. 96. 7 Using Indicator Variables 97. Factor Variables .. 97. Examples .. 98. Comparing Two Regressions: the Chow Test .. 101. Indicator Variables in Log-Linear Models .. 103. The Linear Probability Model .. 103. Treatment Effects .. 105.
5 The Difference-in-Differences Estimator .. 109. Using Panel Data .. 112. R Practicum .. 115. 8 Heteroskedasticity 119. Spotting Heteroskedasticity in Scatter Plots .. 120. Heteroskedasticity Tests .. 121. Heteroskedasticity-Consistent Standard Errors .. 125. GLS: Known Form of Variance .. 127. Grouped Data .. 129. GLS: Unknown Form of Variance .. 131. Heteroskedasticity in the Linear Probability Model .. 133. CONTENTS 5. 9 Time-Series: Stationary Variables 135. An Overview of Time Series Tools in R.
6 136. Finite Distributed Lags .. 136. Serial Correlation .. 138. Estimation with Serially Correlated Errors .. 145. Nonlinear Least Squares Estimation .. 147. A More General Model .. 149. Autoregressive Models .. 150. Forecasting .. 152. Multiplier Analysis .. 156. 10 Random Regressors 159. The Instrumental Variables (IV) Method .. 159. Specification Tests .. 163. 11 Simultaneous Equations Models 167. 12 Time Series: Nonstationarity 175. AR(1), the First-Order Autoregressive Model .. 176. Spurious Regression.
7 179. Unit Root Tests for Stationarity .. 182. Cointegration .. 188. The Error Correction Model .. 189. 13 VEC and VAR Models 193. VAR and VEC Models .. 193. Estimating a VEC Model .. 194. Estimating a VAR Model .. 197. Impulse Responses and Variance Decompositions .. 202. 14 Time-Varying Volatility and ARCH Models 205. The ARCH Model .. 206. The GARCH Model .. 210. 15 Panel Data Models 215. Organizing the Data as a Panel .. 216. The Pooled Model .. 216. The Fixed Effects Model .. 218. The Random Effects Model.
8 221. Grunfeld's Investment Example .. 224. 16 Qualitative and LDV Models 231. The Linear Probability Model .. 231. The Probit Model .. 232. 6 CONTENTS. The Transportation Example .. 232. The Logit Model for Binary Choice .. 234. Multinomial Logit .. 237. The Conditional Logit Model .. 238. Ordered Choice Models .. 241. Models for Count Data .. 242. The Tobit, or Censored Data Model .. 243. Heckit, or Sample Selection Model .. 245. References 249.. 7. 8 CONTENTS. Chapter 1. Introduction rm(list=ls()) # Caution: this clears the Environment library( Bookdown ).
9 Library(PoEdata). library(knitr). library(xtable). library(printr). library(stargazer). library(rmarkdown). Although this manual is self-contained, it can be used as a supplementary resource for the Principles of Econometrics textbook by Carter Hill, William Griffiths and Guay Lim, 4-th edition (Hill, Griffiths, and Lim 2011). The following list gives some of the R packages that are used in this book more frequently: devtools (Wickham and Chang 2016). PoEdata (Colonescu 2016). knitr (Xie 2016b). Bookdown (Xie 2016a).
10 Xtable (Dahl 2016). printr (Xie 2014). stargazer (Hlavac 2015). rmarkdown (Allaire et al. 2016). The function install_git from the package devtools installs packages such as PoEdata from the GitHub web site. Here is the code that installs devtools and Bookdown : 9. 10 CHAPTER 1. INTRODUCTION. Figure : The four quadrants of an RStudio screen ("devtools"). devtools::install_git(. " "). The computing environment for using R (R Development Core Team 2008) is RStudio (RStudio Team 2015). You need to install on your computer the following resources: R ( ).