** STATA Program racd9p6.do by Colin Cameron ** Based on stpanel.do October 1999 (with more lags here) ********** CREATE OUTPUT FILE clear capture log close log using racd9p6.log, replace di "racd9p6.do by Colin Cameron: Stata panel regression example" ********** DESCRIPTION * * This program uses Stata to do panel data analysis for chapter 9 p.308-9 * A.C. Cameron and Pravin K. Trivedi (1998), * REGRESSION ANALYSIS OF COUNT DATA, * Econometric Society Monograph No.30, Cambridge University Press. * In the book only fixed effects estimates are given. * Here random effects estimates are also given for several models, * all with current and lagged R&D and varying according to * Plus - time-invariant regressors and constant * - constant * - time-invariant regressors and no constant * - no constant * The Stata program here is unsuccessful in estimating random effects with time invariant regressors * The Stata results here are the same as Gauss programs racd9p5.gau * which estimates random effects with no constant and no time-invariane regressors * The Stata program here gives same results as Limdep for Poisson FE and RE * and different results to Limdep for negative binomial FE and RE * (which suggests Limdep is wrong since Gauss gives same results as Stata) * ERRATA: Columns 1 and 2 of RACD Table 9.1 p.309 are wrong * Correct answers given below. * To run you need file * racd9d2.asc * in your directory ********** DATA DESCRIPTION * * The original data is from * Bronwyn Hall, Zvi Griliches, and Jerry Hausman (1986), * "Patents and R&D: Is There a Lag?", * International Economic Review, 27, 265-283. * File racd9d2.asc (same as patr7079.dat) has data on 346 firms * There are 4 lines per firm, with 25 variables * Time-invariant: CUSIP,ARDSSIC,SCISECT,LOGK,SUMPAT, * Time-varying X: LOGR70,LOGR71,LOGR72, ....., LOGR77,LOGR78,LOGR79 * Time-varying Y: PAT70,PAT71,PAT72, ....., PAT77,PAT78,PAT79 * in the format: * I7,I3,I2,5F12.6/6F12.6/6F12.6/5F12.6/ * where * CUSIP Compustat's identifying number for the firm (Committee on * Uniform Security Identification Procedures number). * ARDSIC A two-digit code for the applied R&D industrial classification * (roughly that in Bound, Cummins, Griliches, Hall, and Jaffe, in * the Griliches R&D, Patents, and Productivity volume). * SCISECT Dummy equal to one for firms in the scientific sector. * LOGK The logarithm of the book value of capital in 1972. * SUMPAT The sum of patents applied for between 1972-1979. * LOGR70- The logarithm of R&D spending during the year (in 1972 dollars). * LOGR79 * PAT70- The number of patents applied for during the year that were * PAT79 eventually granted. * In the RACD book chapter 9 pages 308-9 * SCISECT is called DSCI * LOGK is called Ln size ********** MEMORY MANAGEMENT * set maxvar 100 width 1000 * If need more memory then in Stata give command help memory ********** READ DATA * * The data are in ascii file racd9d2.asc * This is a data set of 1730 lines (5 lines for each firm) with 18 variables * OBSNO,YEAR,CUSIP,ARDSSIC,SCISECT,LOGK,SUMPAT * PAT,PAT1,PAT2,PAT3,PAT4 * LOGR,LOGR1,LOGR2,LOGR3,LOGR4,LOGR5 * * Read in using Infile: FREE FORMAT WITHOUT DICTIONARY * As there is space between each observation data is also space-delimited * free format and then there is no need for a dictionary file * The following command spans more that one line so use /* and */ infile OBSNO YEAR CUSIP ARDSSIC SCISECT LOGK SUMPAT PAT PAT1 /* */ PAT2 PAT3 PAT4 LOGR LOGR1 LOGR2 LOGR3 LOGR4 LOGR5 using racd9d2.asc gen id = OBSNO label variable id "id" gen dyear2 = 0 replace dyear2 = 1 if YEAR == 2 gen dyear3 = 0 replace dyear3 = 1 if YEAR == 3 gen dyear4 = 0 replace dyear4 = 1 if YEAR == 4 gen dyear5 = 0 replace dyear5 = 1 if YEAR == 5 describe summarize /***** CROSS_SECTION MODELS *****/ * (0) Poisson Cross-section with Poisson standard errors poisson PAT LOGR LOGR1 LOGR2 LOGR3 LOGR4 LOGR5 dyear2 dyear3 dyear4 dyear5 LOGK SCISECT poisson PAT LOGR LOGR1 LOGR2 LOGR3 LOGR4 LOGR5 dyear2 dyear3 dyear4 dyear5 poisson PAT LOGR LOGR1 LOGR2 LOGR3 LOGR4 LOGR5 dyear2 dyear3 dyear4 dyear5 LOGK SCISECT, noconstant poisson PAT LOGR LOGR1 LOGR2 LOGR3 LOGR4 LOGR5 dyear2 dyear3 dyear4 dyear5, noconstant /***** COUNT DATA PANEL MODELS *****/ /* FIXED EFFECTS */ * (1) Poisson fixed effects xtpois PAT LOGR LOGR1 LOGR2 LOGR3 LOGR4 LOGR5 dyear2 dyear3 dyear4 dyear5, fe i(id) * (2) Negative binomial fixed effects xtnbreg PAT LOGR LOGR1 LOGR2 LOGR3 LOGR4 LOGR5 dyear2 dyear3 dyear4 dyear5, fe i(id) /* RANDOM EFFECTS These are done in four ways - with the time-invariant regressors and intercept (LOGK which is ln(SIE) and SCISECT which is DSCI) - with the intercept but otherwise no time-invariant regressors - with the time-invariant regressors and no intercept (LOGK which is ln(SIE) and SCISECT which is DSCI) - without the intercept (so can then compare with the Gauss results from racd9p5.gau) */ * (3A) Poisson random effects with constant & time invariant regressors xtpois PAT LOGR LOGR1 LOGR2 LOGR3 LOGR4 LOGR5 dyear2 dyear3 dyear4 dyear5 LOGK SCISECT, re i(id) * (3B) Poisson random effects with constant xtpois PAT LOGR LOGR1 LOGR2 LOGR3 LOGR4 LOGR5 dyear2 dyear3 dyear4 dyear5, re i(id) * (3C) Poisson random effects without constant & with time invariant regressors xtpois PAT LOGR LOGR1 LOGR2 LOGR3 LOGR4 LOGR5 dyear2 dyear3 dyear4 dyear5 LOGK SCISECT, noconstant re i(id) * (3D) Poisson random effects without constant xtpois PAT LOGR LOGR1 LOGR2 LOGR3 LOGR4 LOGR5 dyear2 dyear3 dyear4 dyear5, noconstant re i(id) * (4A) Negative binomial random effects with constant and time invariant regressors xtnbreg PAT LOGR LOGR1 LOGR2 LOGR3 LOGR4 LOGR5 dyear2 dyear3 dyear4 dyear5 LOGK SCISECT, re i(id) * (4B) Negative binomial random effects with constant xtnbreg PAT LOGR LOGR1 LOGR2 LOGR3 LOGR4 LOGR5 dyear2 dyear3 dyear4 dyear5, re i(id) * (4C) Negative binomial random effects without constant & with time invariant regressors xtnbreg PAT LOGR LOGR1 LOGR2 LOGR3 LOGR4 LOGR5 dyear2 dyear3 dyear4 dyear5 LOGK SCISECT, noconstant re i(id) * (4D) Negative binomial random effects without constant xtnbreg PAT LOGR LOGR1 LOGR2 LOGR3 LOGR4 LOGR5 dyear2 dyear3 dyear4 dyear5, noconstant re i(id) ********** CLOSE OUTPUT log close