Using Stata for Principles of Econometrics, Fourth Edition
Total Page:16
File Type:pdf, Size:1020Kb
Using Stata For Principles of Econometrics, Fourth Edition i ii Using Stata For Principles of Econometrics, Fourth Edition LEE C. ADKINS Oklahoma State University R. CARTER HILL Louisiana State University JOHN WILEY & SONS, INC New York / Chichester / Weinheim / Brisbane / Singapore / Toronto iii Lee Adkins dedicates this work to his lovely and loving wife, Kathy Carter Hill dedicates this work to Stan Johnson and George Judge ACQUISITIONS EDITOR Xxxxxx Xxxxxxxx MARKETING MANAGER Xxxxxx Xxxxxxxx PRODUCTION EDITOR Xxxxxx Xxxxxxxx PHOTO EDITOR Xxxxxx Xxxxxxxx ILLUSTRATION COORDINATOR Xxxxxx Xxxxxxxx This book was set in Times New Roman and printed and bound by.XXXXXX XXXXXXXXXX. The cover was printed by.XXXXXXXX XXXXXXXXXXXX This book is printed on acid-free paper. ∞ The paper in this book was manufactured by a mill whose forest management programs include sustained yield harvesting of its timberlands. Sustained yield harvesting principles ensure that the numbers of trees cut each year does not exceed the amount of new growth. Copyright John Wiley & Sons, Inc. All rights reserved. No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form or by any means, electronic, mechanical, photocopying, recording, scanning or otherwise, except as permitted under Sections 107 or 108 of the 1976 United States Copyright Act, without either the prior written permission of the Publisher, or authorization through payment of the appropriate per-copy fee to the Copyright Clearance Center, 222 Rosewood Drive, Danvers, MA 01923, (508) 750-8400, fax (508) 750- 4470. Requests to the Publisher for permission should be addressed to the Permissions Department, John Wiley & Sons, Inc., 605 Third Avenue, New York, NY 10158-0012, (212) 850-6011, fax (212) 850-6008, E- Mail: [email protected]. ISBN 0-471-xxxxx-x Printed in the United States of America 10 9 8 7 6 5 4 3 2 1 iv PREFACE This book is a supplement to Principles of Econometrics, 4th Edition by R. Carter Hill, William E. Griffiths and Guay C. Lim (Wiley, 2011), hereinafter POE4. This book is not a substitute for the textbook, nor is it a stand alone computer manual. It is a companion to the textbook, showing how to perform the examples in the textbook using Stata Release 11. This book will be useful to students taking econometrics, as well as their instructors, and others who wish to use Stata for econometric analysis. Stata is a very powerful program that is used in a wide variety of academic disciplines. The website is http://www.stata.com. There you will find a great deal of documentation. One great and visual resource is at UCLA: http://www.ats.ucla.edu/stat/stata/. We highly recommend this website. In addition to this computer manual for Stata, there are similar manuals and support for the software packages EViews, Excel, Gretl and Shazam. In addition, all the data for POE4 in various formats, including Stata, are available at http://www.wiley.com/college/hill. Individual Stata data files, errata for this manual and the textbook can be found at http://www.principlesofeconometrics.com/. The chapters in this book parallel the chapters in POE4. Thus, if you seek help for the examples in Chapter 11 of the textbook, check Chapter 11 in this book. However within a Chapter the sections numbers in POE4 do not necessarily correspond to the Stata manual sections. Data files and other resources for POE4 can be found at http://www.stata.com/texts/s4poe4. We welcome comments on this book, and suggestions for improvement. We would like to acknowledge the help of the Stata Corporation, and in particular Bill Rising, for answering many of our questions and improving our prose and code. Lee C. Adkins Department of Economics Oklahoma State University Stillwater, OK 74078 [email protected] R. Carter Hill Economics Department Louisiana State University Baton Rouge, LA 70803 [email protected] . v BRIEF CONTENTS 1. Introducing Stata 1 2. Simple Linear Regression 53 3. Interval Estimation and Hypothesis Testing 103 4. Prediction, Goodness of Fit and Modeling Issues 123 5. Multiple Linear Regression 160 6. Further Inference in the Multiple Regression Model 181 7. Using Indicator Variables 211 8. Heteroskedasticity 247 9. Regression with Time-Series Data: Stationary Variables 269 10. Random Regressors and Moment Based Estimation 319 11. Simultaneous Equations Models 357 12. Regression with Time-Series Data: Nonstationary Variables 385 13. Vector Error Correction and Vector Autoregressive Models 407 14. Time-Varying Volatility and ARCH Models 426 15. Panel Data Models 442 16. Qualitative and Limited Dependent Variable Models 489 A. Review of Math Essentials 547 B. Review of Probability Concepts 555 C. Review of Statistical Inference 574 vi builder 34 CONTENTS 1.14.3 Dropping or keeping variables and observations 35 1.14.4 Using arithmetic operators 38 CHAPTER 1 Introducing Stata 1 1.14.5 Using Stata math 1.1 Starting Stata 2 functions 38 1.2 The opening display 2 1.15 Using Stata density functions 39 1.3 Exiting Stata 3 1.15.1 Cumulative distribution 1.4 Stata data files for Principles of functions 39 Econometrics 3 1.15.2 Inverse cumulative distribution 1.4.1 A working directory 4 functions 40 1.5 Opening Stata data files 5 1.16 Using and displaying scalars 41 1.5.1 The use command 5 1.16.1 Example of standard normal 1.5.2 Using the toolbar 6 cdf 41 1.5.3 Using files on the internet 6 1.16.2 Example of t-distribution tail- 1.5.4 Locating book files on the cdf 42 internet 7 1.16.3 Example computing percentile 1.6 The variables window 7 of the standard normal 42 1.6.1 Using the data editor for a 1.16.4 Example computing percentile single label 7 of the t-distribution 42 1.6.2 Using the data utility for a 1.17 A scalar dialog box 43 single label 8 1.18 Using factor variables 45 1.6.3 Using variables manager 9 1.18.1 Creating indicator variables 1.7 Describing data and obtaining summary using a logical operator 47 statistics 11 1.18.2 Creating indicator variables 1.8 The Stata help system 12 using tabulate 48 1.8.1 Using keyword search 13 Key Terms 49 1.8.2 Using command search 14 Chapter 1 Do-file 50 1.8.3 Opening a dialog box 15 1.8.4 Complete documentation in CHAPTER 2 Simple Linear Regression Stata manuals 16 53 1.9 Stata command syntax 16 2.1 The food expenditure data 53 1.9.1 Syntax of summarize 16 2.1.1 Starting a new problem 54 1.9.2 Learning syntax using the 2.1.2 Starting a log file 54 review window 17 2.1.3 Opening a Stata data file 54 1.10 Saving your work 20 2.1.4 Browsing and listing the 1.10.1 Copying and pasting 20 data 55 1.10.2 Using a log file 21 2.2 Computing summary statistics 57 1.11 Using the data browser 25 2.3 Creating a scatter diagram 58 1.12.1 Histograms 25 2.3.1 Enhancing the plot 60 1.12.2 Scatter diagrams 28 2.4 Regression 62 1.13 Using Stata Do-files 29 2.4.1 Fitted values and 1.14 Creating and managing variables 32 residuals 63 1.14.1 Creating (generating) 2.4.2 Computing an elasticity 66 new variables 32 2.4.3 Plotting the fitted regression 1.14.2 Using the expression line 69 vii combinations of 2.4.4 Estimating the variance of the parameters 113 error term 70 Appendix 3A Graphical tools 114 2.4.5 Viewing estimated variances Appendix 3B Monte Carlo simulation 116 and covariance 71 Key Terms 119 2.5 Using Stata to obtain predicted Chapter 3 Do-file 119 values 73 2.5.1 Saving the Stata data file 74 CHAPTER 4 Prediction, Goodness-of-Fit 2.6 Estimating nonlinear relationships 75 and Modeling Issues 123 2.6.1 A quadratic model 75 4.1 Least squares prediction 123 2.6.2 A log-linear model 80 4.1.1 Editing the data 124 2.7 Regression with indicator variables 84 4.1.2 Estimate the regression and Appendix 2A Average marginal effects 89 obtain postestimation 2A.1 Elasticity in a linear results 124 relationship 89 4.1.3 Creating the prediction 2A.2 Elasticity in a quadratic interval 125 relationship 91 4.2 Measuring goodness-of-fit 126 2A.3 Slope in a log-linear 4.2.1 Correlations and R2 127 model 92 4.3 The effects of scaling and transforming Appendix 2B A simulation experiment 93 the data 128 Key Terms 96 4.3.1 The linear-log functional Chapter 2 Do-file 97 form 129 4.3.2 Plotting the fitted linear-log CHAPTER 3 Interval Estimation and model 131 Hypothesis Testing 103 4.3.3 Editing graphs 132 3.1 Interval estimates 103 4.4 Analyzing the residuals 134 3.1.1 Critical values from the t- 4.4.1 The Jarque-Bera test 135 distribution 104 4.4.2 Chi-square distribution critical 3.1.2 Creating an interval values 136 estimate 105 4.4.3 Chi-square distribution p- 3.2 Hypothesis tests 106 values 137 3.2.1 Right-tail test of 4.5 Polynomial models 137 significance 106 4.5.1 Estimating and checking the 3.2.2 Right-tail test of an economic linear relationship 138 hypothesis 108 4.5.2 Estimating and checking a 3.2.3 Left-tail test of an economic cubic relationship 141 hypothesis 109 4.5.3 Estimating a log-linear yield 3.2.4 Two-tail test of an economic growth model 143 hypothesis 109 4.6 Estimating a log-linear wage 3.3 p-values 110 equation 144 3.3.1 p-value of a right-tail 4.6.1 The log-linear model 145 test 111 4.6.2 Calculating wage 3.3.2 p-value of a left-tail test 112 predictions 148 3.3.3 p-value for a two-tail 4.6.3 Constructing wage plots 149 test 112 4.6.4 Generalized R2 150 3.3.4 p-values in Stata output 113 4.6.5 Prediction intervals in the log- 3.3.5 Testing and estimating linear linear model 150 viii 4.7 A log-log model 151 CHAPTER 7 Using Indicator Variables Key Terms 154 211 Chapter 4 Do-file 154 7.1 Indicator variables 211 7.1.1 Creating indicator