Last updated: 3rd May 2013

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.

** **** NEW **I've added some new material for spatial econometric analysis.

For feedback please email me at markus.eberhardt@nottingham.ac.uk

## 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.

** NEW ** 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.

** NEW ** 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.

** NEW ** 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

**Mark & Sul (2003) **Panel DOLS

* The

**Pedroni (1999, 2004) **cointegration tests

* 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

**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.

** NEW ** 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.

** NEW ** 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.

#### 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.

## 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.