Last updated: 22nd October 2014

The usual disclaimers apply. Please see help files for examples, data links, references and acknowledgements. For a wealth of data sources for development economics (micro, macro) please refer to my data website. Empirical illustrations using some of the below routines can be found in my own research papers. For an introduction to the panel time series field see my presentation at the Stata UK User Group Meeting. For feedback please email me at markus.eberhardt@nottingham.ac.uk

** ** NEW *Empirical Development Economics*, the new textbook I have contributed to is now published and available from Routledge and standard retailers. All the examples in the book can be replicated, with data and do-files available on a dedicated website: www.empiricalde.com.

** **** NEW **I've added the xtpedroni command by Tim Neal.

## Panel Time Series Tools

**xtmg**

**Estimating panel time series models with heterogeneous slopes **- ado, help, *Stata Journal *article, application

**Version: 1.0.2 - 4th January 2012 ****- in Stata: -ssc install xtmg**- (Using SSC will get you the previous version for the time being; use the above download links for the latest version)

This command implements the Pesaran and Smith (1995) Mean Group (MG) estimator, the Pesaran (2006) Common Correlated Effects Mean Group (CCEMG) estimator and the Augmented Mean Group (AMG) estimator introduced

here and discussed and tested

here. For these macro panel estimators the cross-panel average estimates can be reported as unweighted or outlier-robust means, where the latter is implemented via the

rreg command. Optionally the routine reports the group-specific regression results and produces residuals and predicted values based on these. The example in the helpfile links to a dataset (+ related working paper) and goes through all the options of the command. This code is applied in our

*REStat *paper on R&D spillovers. Other illustrations with data (including a

*Stata Journal* article) can be found

here.

### multipurt

**Investigating variable nonstationarity in macro panels **- ado, help

**Version: 1.0.****1 - 8th February 2011 ****- in Stata: -ssc install multipurt**-

This command runs the Maddala and Wu (1999) as well as the Pesaran (2007) panel unit root tests for multiple variables and lags. This is

__not__ a new command for these panel unit root tests but a convenient tool using the existing

xtfisher and

pescadf commands written by Scott Merryman and Piotr Lewandowski respectively (both commands need to be installed for multipurt to work). In the future this will hopefully also include the CIPSM panel unit root test by Pesaran, Smith and Yamagata (2009). The example in the helpfile links to a dataset (+ related working paper) and goes through all the options of the command. Further illustrations with data can be found

here.

### xtcd

**Investigating variable and residual cross-section dependence in macro panels **- ado, help

**Version: 1.0.0 - 5th February 2011**This
command implements the Pesaran (2004) CD test for cross-section
dependence in panel time-series data. The routine builds on the

xtcsd command by De Hoyos and Sarafidis (2006) but is

__not__ a
post-estimation command: xtcd can be applied to variables as well as to
residuals, provided the latter have been previously computed as a
separate variable series (using for instance the xtmg command). Furthermore, in the multipurt spirit up to 9 variable or residuals series can be tested together.
Further illustrations with data can be found

here.

**Please note:** This version and the one on SSC has a bug whereby the average number of observations per correlation as well as the balancedness/unbalancedness of the panel are wrong. This will be corrected in the forthcoming Mata version of the routine.

### xtectest

**Investigating heterogeneous panel cointegration with an error correction test **- ado-file, help-file

**Version: 1.0.0 still in planning**This command implements the error correction based cointegration test by Gengenbach, Urbain and Westerlund (2009), which builds on earlier work by Westerlund (2007). The test investigates error correction at the group-level (e.g. country) and can account for cross-section dependence.

A rough an ready approach is described here.### xtcipsm

**Investigating variable nonstationarity in macro panels with multiple unobserved factors **- ado-file, help-file

**Version: 1.0.0 ****still in planning**This command implements the Pesaran, Smith and Yamagata (2009) panel unit root test. It extends the cross sectionally augmented panel unit root test proposed by
Pesaran (2007) to the case of a multifactor error structure. The basic
idea is to exploit information regarding the unobserved factors that are
shared by other time series in addition to the variable under
consideration. The test procedure only requires specification of the
maximum number of factors, in contrast to other panel unit root tests
based on principal components that require in addition the estimation of
the number of factors as well as the factors themselves. A rough an ready approach is described here.

### xtbcis

**Testing for Panel Cointegration Using Common Correlated Effects Estimators **- ado-file, help-file

**Version: 1.0.0 ****still in planning**This commands implements the panel cointegration test by Banerjee and Carrion-i-Silvestre (2011). This runs a standard CIPS panel unit root test on some 'residuals' from a Pesaran (2006) CCEP model.

A rough an ready approach is described here. ### In planning

Time (and brain-power) permitting, I'm planning to have a stab at constructing Stata commands for the following panel time series procedures:

* The

**Bai et al (2009) **CupBC and CupFM estimators

* The

**Bai & Kao (2006) **estimator

* The

**Bai & Ng (2002) **procedure to determine relevant number of factors

* The

**Bai & Ng (2004) **PANIC attack

* The

**Pedroni (2004) **Group Mean FMOLS estimator

### Already coded by others

#### Useful tools (not just for macro panels)

* Nick Cox has written

xtpatternvar which gives you insights into the unbalancedness of the panel and which observations are missing. Missing observations are a common feature of macro panel data, so maybe also have a look at the paper by Ron Smith and Ali Tasiran on

'Random coefficients models of arms imports' in Economic Modelling, 2010, Vol.27(6).

#### Panel Unit Root Testing (PURT)

* The

**Breitung (2000)** panel unit root/stationarity test (

xtunitroot breitung) is implemented in Stata 11; requires a strongly balanced panel. Note that the help file for xtunitroot provides a nice overview of all the tests.

* The

**Hadri (2000)** panel unit root/stationarity test (

xtunitroot hadri) is implemented in Stata 11; requires a strongly balanced panel. Prior to this version you can use the command written by Kit Baum (

hadrilm).

* The

**Harris & Tzavalis (1999)** panel unit root/stationarity test (

xtunitroot ht) is implemented in Stata 11; requires a balanced panel.

* The

**Im, Pesaran & Shin (1997, 2003)** panel unit root/stationarity test (

ipshin) was coded by Fabian Bornhorst and Kit Baum; country series cannot have gaps. This is also implement in Stata 11 (

xtunitroot ips).

* The

**Levin, Lin & Chu (1992, 2002)** panel unit root/stationarity test (

levinlin) was coded by Fabian Bornhorst and Kit Baum; country series cannot have gaps. This is also implement in Stata 11 (

xtunitroot llc).

* The

**Maddala & Wu (1999)** panel unit root/stationarity test (

xtfisher) was coded by Scott Merryman. The option 'pp' implements the Phillips and Perron (1988) test at the country-level instead. Both of these options are also implement in Stata 11 (

xtunitroot fisher).

* The

**Pesaran (2006)** CIPS panel unit root/stationarity test (

pescadf) was coded by Piotr Lewandowski.

#### Cointegration Testing

* The seven

**Pedroni (1999)** residual based cointegration tests (first generation, i.e. limited allowance made for cross-section dependence, unless you assume [getting technical] that the unobservables are identical in thei impact across countries) was recently coded by Timothy Neal of UNSW as

xtpedroni (link is for the

*Stata Journal* article [

subscription required], but of course you can install xtpedroni from within Stata by typing - findit xtpedroni -). Consult the help files in Stata after installation for further details. Tim's got a nice paper in the *Economic Record* (subscription required) where he applies these and the estimators also included in the routine (see below).* The

**Westerlund (2007) **error-correction/cointegration test (

xtwest) was coded by Damiaan Persyn; it requires that the country series do not have gaps but as a very useful feature tells the user which country series violate this requirement.

#### Cross-section Dependence Testing

* The

**Pesaran (2004) **CD test for cross-section dependence was coded by Rafael E. De Hoyos and Vasilis Sarafidis (

xtcsd). This command operates as a post-estimation command following xtreg, fe or re. See

xtcd above for a more flexible procedure.

* A number of

**tools for spatial econometric analysis **including Moran's (1950) I statistic were written by Maurizio Pisati (this covers a number of commands, most conveniently found via -findit spatial- or for a description the

Stata Bulletin 60, sg162). A new set of spatial estimators for Stata (

spmlreg) has been developed by P. Wilner Jeanty, with David Drukker et al also chipping in rather substantially for cross-section analysis (

sppack). Note that for all spatial econometric analysis it is required that you specify a spatial weight matrix. The Pisati commands allow you to do so provided you have relevant data.

#### Spatial Econometric Methods

* A number of

**tools for spatial econometric analysis **including
Moran's (1950) I statistic were written by Maurizio Pisati (this covers a
number of commands, most conveniently found via -findit spatial-; for
a description see

Stata Bulletin 60, sg162, free access). A new set of spatial estimators for Stata (

spmlreg)
has recently been created by P. Wilner Jeanty, with Stata's David Drukker et al also
chipping in rather substantially for cross-section analysis (

sppack).
Note that for all spatial econometric analysis it is required that you
specify a spatial weight matrix. The Pisati commands allow you to do so
provided you have relevant data. Further spatial commands in Stata include

spagg (something to do with dyadic data),

spautoc (Moran and Geary measures of spatial correlation),

spgrid (creating two-dimensional grids),

sphdist (spherical distance),

splagvar (create spatial lags and other tools),

spmon (monadic data),

spseudor2 (create measure for goodness-of-fit),

spspc and

spundir (more dyadic data tools),

spwmatfill and

spwmatrix (tools for creation/import/export of spatial weight matrices).

Franzese, Hays and Kachi (2010) also have

code for their m-star estimator (multiparametric spatiotemporal autoregressive model).

* There are some new resources for spatial econometrics provided in the form of a

talk by Maurizio Pisati at the 2012 German Stata Users Group, as well as two

talks to be given at the Spanish Stata User Group meeting later this year (September 2012). In general it's worth your time looking through the

materials for past meetings.

The cross-section version of the aforementioned m-star estimator has also been coded by Emad Abd Elmessih Shehata and

Sahra Khaleel A. Mickaiel in form of the spmstardh command, and by the former author for the panel in form of the

spmstarxt command.

* Federico Belotti, Gordon Hughes and Andrea Piano Mortari have created a suite of fixed and random-effects spatial models for balanced panel data in form of the

xsmle command. This includes Spatial Autoregressive Model (SAR), Spatial Error Model (SEM), Spatial Durbin Model (SDM), Spatial Autoregressive Model with Autoregressive Disturbances (SAC), Generalized Spatial Random-effects Model (GSPRE). The command can compute direct, indirect and total spatial effects (LeSage, 2008) and can also transform the data to accommodate fixed effects. With the -mi- prefix command this estimator can also be used for unbalanced panels.

** NEW ** *

Marinho Bertanha and Petra Moser have developed a methodology to allow for spatial dependence (defined via a weight matrix/coordinates) in the analysis of count data. Their paper 'Spatial Errors in Count Data Regressions' is available here, Stata and Matlab code can be downloaded as well.

#### Panel Time Series Estimators

* The

**Kao & Chiang (2000)** Dynamic OLS (DOLS) estimator for Cointegrated
Panel Data with homogeneous covariance structure was recently coded in
Stata by Diallo Ibrahima Amadou (CERDI) as

xtdolshm; you will also need to install

ltimbimata.
Both can be found via -ssc install- or -findit- in Stata. Make sure you have the latest version of this command, since Diallo has recently ironed out a bug related to the computation of the confidence intervals.

*Also: email him rather than me if you have any questions about this command!** The

**Swamy (1970)** Random Coefficient Model (RCM) estimator is implemented in Stata (

xtrc). The special edition of

*Economic Modelling *on P.A.V.B Swamy should be useful for anybody using the RCM estimator: Volume 27, Issue 6, November 2010.

** NEW ** * Timothy Neal of UNSW has coded

xtpedroni (link is for the *Stata Journal* article [subscription required], but of course you can install xtpedroni from within Stata by typing - findit xtpedroni -), which implements the **Pedroni (2001)** Group Mean DOLS estimator. Tim's got a nice paper in the *Economic Record* (subscription required) where he applies this estimator.## Firm-level Productivity Analysis

'Untested Assumptions and Data Slicing: A Critical Review of Firm-Level Production Function Estimators' with Christian Helmers. The Stata and R code for this paper will be posted here in due course. Since we're working on a book manuscript on firm-level productivity analysis (with Ralf Martin) there'll be a dedicated website with all the code through the publishers Oxford University Press, most likely some time after Summer 2013. If you're keen to use our ACF code... read the paper and/or wait till then.