Stata Longitudinal data panel data reference manual 14.pdf - STATA LONGITUDINAL-DATA\/PANEL-DATA REFERENCE MANUAL RELEASE 14 \u00ae A Stata Press Publication

Stata Longitudinal data panel data reference manual 14.pdf...

This preview shows page 1 out of 551 pages.

You've reached the end of your free preview.

Want to read all 551 pages?

Unformatted text preview: STATA LONGITUDINAL-DATA/PANEL-DATA REFERENCE MANUAL RELEASE 14 ® A Stata Press Publication StataCorp LLC College Station, Texas ® c 1985–2015 StataCorp LLC Copyright All rights reserved Version 14 Published by Stata Press, 4905 Lakeway Drive, College Station, Texas 77845 Typeset in TEX ISBN-10: 1-59718-171-4 ISBN-13: 978-1-59718-171-6 This manual is protected by copyright. All rights are reserved. No part of this manual may be reproduced, stored in a retrieval system, or transcribed, in any form or by any means—electronic, mechanical, photocopy, recording, or otherwise—without the prior written permission of StataCorp LLC unless permitted subject to the terms and conditions of a license granted to you by StataCorp LLC to use the software and documentation. No license, express or implied, by estoppel or otherwise, to any intellectual property rights is granted by this document. StataCorp provides this manual “as is” without warranty of any kind, either expressed or implied, including, but not limited to, the implied warranties of merchantability and fitness for a particular purpose. StataCorp may make improvements and/or changes in the product(s) and the program(s) described in this manual at any time and without notice. The software described in this manual is furnished under a license agreement or nondisclosure agreement. The software may be copied only in accordance with the terms of the agreement. It is against the law to copy the software onto DVD, CD, disk, diskette, tape, or any other medium for any purpose other than backup or archival purposes. c 1979 by Consumers Union of U.S., The automobile dataset appearing on the accompanying media is Copyright Inc., Yonkers, NY 10703-1057 and is reproduced by permission from CONSUMER REPORTS, April 1979. Stata, , Stata Press, Mata, , and NetCourse are registered trademarks of StataCorp LLC. Stata and Stata Press are registered trademarks with the World Intellectual Property Organization of the United Nations. NetCourseNow is a trademark of StataCorp LLC. Other brand and product names are registered trademarks or trademarks of their respective companies. For copyright information about the software, type help copyright within Stata. The suggested citation for this software is StataCorp. 2015. Stata: Release 14 . Statistical Software. College Station, TX: StataCorp LLC. Contents intro . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Introduction to longitudinal-data/panel-data manual xt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Introduction to xt commands 1 2 quadchk . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Check sensitivity of quadrature approximation 9 vce options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Variance estimators 20 xtabond . . . . . . . . . . . . . . . . . . . . . . . . . Arellano–Bond linear dynamic panel-data estimation 24 xtabond postestimation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Postestimation tools for xtabond 44 xtcloglog . . . . . . . . . . . . . . . . . . . . Random-effects and population-averaged cloglog models 48 xtcloglog postestimation . . . . . . . . . . . . . . . . . . . . . . . . . . . Postestimation tools for xtcloglog 63 xtdata . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Faster specification searches with xt data 68 xtdescribe . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Describe pattern of xt data 75 xtdpd . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Linear dynamic panel-data estimation 80 xtdpd postestimation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Postestimation tools for xtdpd 100 xtdpdsys . . . . . . . . . . . Arellano–Bover/Blundell–Bond linear dynamic panel-data estimation 106 xtdpdsys postestimation . . . . . . . . . . . . . . . . . . . . . . . . . . . . Postestimation tools for xtdpdsys 116 xtfrontier . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Stochastic frontier models for panel data 121 xtfrontier postestimation . . . . . . . . . . . . . . . . . . . . . . . . . . . Postestimation tools for xtfrontier 134 xtgee . . . . . . . . . . . . . . . . . . . . . . . . Fit population-averaged panel-data models by using GEE 138 xtgee postestimation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Postestimation tools for xtgee 158 xtgls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Fit panel-data models by using GLS 168 xtgls postestimation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Postestimation tools for xtgls 179 xthtaylor . . . . . . . . . . . . . . . . . . . . . Hausman–Taylor estimator for error-components models 182 xthtaylor postestimation . . . . . . . . . . . . . . . . . . . . . . . . . . . . Postestimation tools for xthtaylor 195 xtintreg . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Random-effects interval-data regression models 200 xtintreg postestimation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Postestimation tools for xtintreg 209 xtivreg . . . . . . . . . Instrumental variables and two-stage least squares for panel-data models 214 xtivreg postestimation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Postestimation tools for xtivreg 238 xtline . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Panel-data line plots 241 xtlogit . . . . . . . . . . . . . . Fixed-effects, random-effects, and population-averaged logit models 246 xtlogit postestimation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Postestimation tools for xtlogit 265 xtnbreg . . . . Fixed-effects, random-effects, & population-averaged negative binomial models 270 i ii Contents xtnbreg postestimation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Postestimation tools for xtnbreg 284 xtologit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Random-effects ordered logistic models 289 xtologit postestimation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Postestimation tools for xtologit 300 xtoprobit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Random-effects ordered probit models 304 xtoprobit postestimation . . . . . . . . . . . . . . . . . . . . . . . . . . . . Postestimation tools for xtoprobit 314 xtpcse . . . . . . . . . . . . . . . . . . . . . . . . . . Linear regression with panel-corrected standard errors 318 xtpcse postestimation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Postestimation tools for xtpcse 329 xtpoisson . . . . . . . . . Fixed-effects, random-effects, and population-averaged Poisson models 332 xtpoisson postestimation . . . . . . . . . . . . . . . . . . . . . . . . . . . Postestimation tools for xtpoisson 355 xtprobit . . . . . . . . . . . . . . . . . . . . . . . . Random-effects and population-averaged probit models 361 xtprobit postestimation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Postestimation tools for xtprobit 381 xtrc . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Random-coefficients model 386 xtrc postestimation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Postestimation tools for xtrc 394 xtreg . . . . . . . . Fixed-, between-, and random-effects and population-averaged linear models 397 xtreg postestimation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Postestimation tools for xtreg 429 xtregar . . . . . . . . . . . . . Fixed- and random-effects linear models with an AR(1) disturbance 438 xtregar postestimation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Postestimation tools for xtregar 454 xtset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Declare data to be panel data 457 xtstreg . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Random-effects parametric survival models 472 xtstreg postestimation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Postestimation tools for xtstreg 483 xtsum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Summarize xt data 488 xttab . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Tabulate xt data 491 xttobit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Random-effects tobit models 495 xttobit postestimation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Postestimation tools for xttobit 504 xtunitroot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Panel-data unit-root tests 510 Glossary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 541 Subject and author index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 545 Cross-referencing the documentation When reading this manual, you will find references to other Stata manuals. For example, [U] 26 Overview of Stata estimation commands [R] regress [D] reshape The first example is a reference to chapter 26, Overview of Stata estimation commands, in the User’s Guide; the second is a reference to the regress entry in the Base Reference Manual; and the third is a reference to the reshape entry in the Data Management Reference Manual. All the manuals in the Stata Documentation have a shorthand notation: [GSM] [GSU] [GSW] [U] [R] [BAYES] [D] [FN] [G] [IRT] [XT] [ME] [MI] [MV] [PSS] [P] [SEM] [SVY] [ST] [TS] [TE] [I] Getting Started with Stata for Mac Getting Started with Stata for Unix Getting Started with Stata for Windows Stata User’s Guide Stata Base Reference Manual Stata Bayesian Analysis Reference Manual Stata Data Management Reference Manual Stata Functions Reference Manual Stata Graphics Reference Manual Stata Item Response Theory Reference Manual Stata Longitudinal-Data/Panel-Data Reference Manual Stata Multilevel Mixed-Effects Reference Manual Stata Multiple-Imputation Reference Manual Stata Multivariate Statistics Reference Manual Stata Power and Sample-Size Reference Manual Stata Programming Reference Manual Stata Structural Equation Modeling Reference Manual Stata Survey Data Reference Manual Stata Survival Analysis Reference Manual Stata Time-Series Reference Manual Stata Treatment-Effects Reference Manual: Potential Outcomes/Counterfactual Outcomes Stata Glossary and Index [M] Mata Reference Manual iii Title intro — Introduction to longitudinal-data/panel-data manual Description Also see Description This manual documents the xt commands and is referred to as [XT] in cross-references. Following this entry, [XT] xt provides an overview of the xt commands. The other parts of this manual are arranged alphabetically. If you are new to Stata’s xt commands, we recommend that you read the following sections first: [XT] xt [XT] xtset [XT] xtreg Introduction to xt commands Declare a dataset to be panel data Fixed-, between-, and random-effects, and population-averaged linear models Stata is continually being updated, and Stata users are always writing new commands. To find out about the latest cross-sectional time-series features, type search panel data after installing the latest official updates; see [R] update. Also see [U] 1.3 What’s new [R] intro — Introduction to base reference manual 1 Title xt — Introduction to xt commands Description Remarks and examples References Also see Description The xt series of commands provides tools for analyzing panel data (also known as longitudinal data or in some disciplines as cross-sectional time series when there is an explicit time component). Panel datasets have the form xit , where xit is a vector of observations for unit i and time t. The particular commands (such as xtdescribe, xtsum, and xtreg) are documented in alphabetical order in the entries that follow this entry. If you do not know the name of the command you need, try browsing the second part of this description section, which organizes the xt commands by topic. The next section, Remarks and examples, describes concepts that are common across commands. The xtset command sets the panel variable and the time variable; see [XT] xtset. Most xt commands require that the panel variable be specified, and some require that the time variable also be specified. Once you xtset your data, you need not do it again. The xtset information is stored with your data. If you have previously tsset your data by using both a panel and a time variable, these settings will be recognized by xtset, and you need not xtset your data. If your interest is in general time-series analysis, see [U] 26.19 Models with time-series data and the Time-Series Reference Manual. If your interest is in multilevel mixed-effects models, see [U] 26.21 Multilevel mixed-effects models and the Multilevel Mixed-Effects Reference Manual. Setup xtset Declare data to be panel data Data management and exploration tools xtdescribe Describe pattern of xt data xtsum Summarize xt data xttab Tabulate xt data xtdata Faster specification searches with xt data xtline Panel-data line plots Linear regression estimators xtreg Fixed-, between-, and random-effects, and population-averaged linear models xtregar Fixed- and random-effects linear models with an AR(1) disturbance xtgls Panel-data models by using GLS xtpcse Linear regression with panel-corrected standard errors xthtaylor Hausman–Taylor estimator for error-components models xtfrontier Stochastic frontier models for panel data xtrc Random-coefficients regression xtivreg Instrumental variables and two-stage least squares for panel-data models 2 xt — Introduction to xt commands Unit-root tests xtunitroot 3 Panel-data unit-root tests Dynamic panel-data estimators xtabond Arellano–Bond linear dynamic panel-data estimation xtdpd Linear dynamic panel-data estimation xtdpdsys Arellano–Bover/Blundell–Bond linear dynamic panel-data estimation Censored-outcome estimators xttobit Random-effects tobit models xtintreg Random-effects interval-data regression models Binary-outcome xtlogit xtprobit xtcloglog estimators Fixed-effects, random-effects, and population-averaged logit models Random-effects and population-averaged probit models Random-effects and population-averaged cloglog models Ordinal-outcome estimators xtologit Random-effects ordered logistic models xtoprobit Random-effects ordered probit models Count-data estimators xtpoisson Fixed-effects, random-effects, and population-averaged Poisson models xtnbreg Fixed-effects, random-effects, & population-averaged negative binomial models Survival-time estimators xtstreg Random-effects parametric survival models Generalized estimating equations estimator xtgee Population-averaged panel-data models by using GEE Utility quadchk Check sensitivity of quadrature approximation Remarks and examples Consider having data on n units — individuals, firms, countries, or whatever — over T periods. The data might be income and other characteristics of n persons surveyed each of T years, the output and costs of n firms collected over T months, or the health and behavioral characteristics of n patients collected over T years. In panel datasets, we write xit for the value of x for unit i at time t. The xt commands assume that such datasets are stored as a sequence of observations on (i, t, x). For a discussion of panel-data models, see Baltagi (2013), Greene (2012, chap. 11), Hsiao (2014), and Wooldridge (2010). Cameron and Trivedi (2010) illustrate many of Stata’s panel-data estimators. For an introduction to linear, nonlinear, and dynamic panel-data analysis in Stata, we offer NetCourse 471, Introduction to Panel Data Using Stata; see . 4 xt — Introduction to xt commands Example 1 If we had data on pulmonary function (measured by forced expiratory volume, or FEV) along with smoking behavior, age, sex, and height, a piece of the data might be . list in 1/6, separator(0) divider 1. 2. 3. 4. 5. 6. pid yr_visit fev age sex height smokes 1071 1071 1071 1072 1072 1072 1991 1992 1993 1991 1992 1993 1.21 1.52 1.32 1.33 1.18 1.19 25 26 28 18 20 21 1 1 1 1 1 1 69 69 68 71 71 71 0 0 0 1 1 0 The xt commands need to know the identity of the variable identifying patient, and some of the xt commands also need to know the identity of the variable identifying time. With these data, we would type . xtset pid yr_visit If we resaved the data, we need not respecify xtset. Technical note Panel data stored as shown above are said to be in the long form. Perhaps the data are in the wide form with 1 observation per unit and multiple variables for the value in each year. For instance, a piece of the pulmonary function data might be pid 1071 1072 sex 1 1 fev91 1.21 1.33 fev92 1.52 1.18 fev93 1.32 1.19 age91 25 18 age92 26 20 age93 28 21 Data in this form can be converted to the long form by using reshape; see [D] reshape. Example 2 Data for some of the periods might be missing. That is, we have panel data on i = 1, . . . , n and t = 1, . . . , T , but only Ti of those observations are defined. With such missing periods — called unbalanced data — a piece of our pulmonary function data might be . list in 1/6, separator(0) divider 1. 2. 3. 4. 5. 6. pid yr_visit fev age sex height smokes 1071 1071 1071 1072 1072 1073 1991 1992 1993 1991 1993 1991 1.21 1.52 1.32 1.33 1.19 1.47 25 26 28 18 21 24 1 1 1 1 1 0 69 69 68 71 71 64 0 0 0 1 0 0 Patient ID 1072 is not observed in 1992. The xt commands are robust to this problem. xt — Introduction to xt commands 5 Technical note In many of the entries in [XT], we will use data from a subsample of the NLSY data (Center for Human Resource Research 1989) on young women aged 14 – 26 years in 1968. Women were surveyed in each of the 21 years 1968–1988, except for the six years 1974, 1976, 1979, 1981, 1984, and 1986. We use two different subsets: nlswork.dta and union.dta. For nlswork.dta, our subsample is of 4,711 women in years when employed, not enrolled in school and evidently having completed their education, and with wages in excess of $1/hour but less than $700/hour. . use , clear (National Longitudinal Survey. Young Women 14-26 years of age in 1968) . describe Contains data from obs: 28,534 National Longitudinal Survey. Young Women 14-26 years of age in 1968 vars: 21 27 Nov 2014 08:14 size: 941,622 variable name idcode year birth_yr age race msp nev_mar grade collgrad not_smsa c_city south ind_code occ_code union wks_ue ttl_exp tenure hours wks_work ln_wage storage type int byte byte byte byte byte byte byte byte byte byte byte byte byte byte byte float float int int float Sorted by: idcode year display format %8.0g %8.0g %8.0g %8.0g %8.0g %8.0g %8.0g %8.0g %8.0g %8.0g %8.0g %8.0g %8.0g %8.0g %8.0g %8.0g %9.0g %9.0g %8.0g %8.0g %9.0g value label racelbl variable label NLS ID interview year birth year age in current year race 1 if married, spouse present 1 if never married current grade completed 1 if college graduate 1 if not SMSA 1 if central city 1 if south industry of employment occupation 1 if union weeks unemployed last year total work experience job tenure, in years usual hours worked weeks worked last year ln(wage/GNP deflator) 6 xt — Introduction to xt commands . summarize Variable Obs Mean Std. Dev. Min Max idcode year birth_yr age race 28,534 28,534 28,534 28,510 28,534 2601.284 77.95865 48.08509 29.04511 1.303392 1487.359 6.383879 3.012837 6.700584 .4822773 1 68 41 14 1 5159 88 54 46 3 msp nev_mar grade collgrad not_smsa 28,518 28,518 28,532 28,534 28,526 .6029175 .2296795 12.53259 .1680451 .2824441 .4893019 ...
View Full Document

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern

Stuck? We have tutors online 24/7 who can help you get unstuck.
A+ icon
Ask Expert Tutors You can ask You can ask You can ask (will expire )
Answers in as fast as 15 minutes