help xtsur


xtsur -- One-way random effect estimation of seemingly-unrelated regressions (SUR) in unbalanced panel data set


Basic syntax

xtsur (depvar1 varlist1) (depvar2 varlist2) ...(depvarN varlistN) [if exp] [in range] [, level(#) onestep multistep tolerance(real 1e-6)]

Full syntax

xtsur ([eqname1:]depvar1a [depvar1b ...=]varlist1 ) ([eqname2:]depvar2a [depvar2b ...=]varlist2 ) ... ([eqnameN:]depvarNa [depvarNb ...=]varlistN ) [if exp] [in range] [, level(#) onestep multistep tolerance(real 1e-6)]


xtsur fits a many-equation seemingly-unrelated regression (SUR) model of the y1 variable on the x1 variables and the y2 variable on the x1 or x2 variables and etc..., using random effect estimators in the context of unbalanced panel data. The approach for this command is based on constructing a multistep (stepwise) algorithm using Generalized Least Squares (GLS) and the Maximum Likelihood (ML) procedures. The method is originally developed by Erik Biorn (JoE).

In order to run this command, tsset must be run to set the panel variable and time variable; see help tsset.

Consider the system of G equation model:

y_git = x_git * b_g + u_git i=1,...,N; t=1,...,Ti; g=1,...,G u_git = v_gi + e_git,


v_gi are unobserved individual-level effects in the gth equation;

e_git are the observation-specific errors in the gth equation;

x_git is a vector of strictly exogenous covariates (ones dependent on neither current nor past e_git) in the gth equation;

b_g are vectors of parameters to be estimated in the gth equation;

Observations in the unbalanced data set are observed in at least one and at most P periods, and let N_p denotes the number of individuals observed in p periods, where p = 1,...,P. Hence, we can rearranged the unbalaned data set in the way that the N_1 individuals observed once come first, the N_2 individuals observed twice come second, N_3 individuals observed three times come third, and etc. In this way, we can consider the set of N_1 individuals as a cross section, and the sets of N_p individuals where p = 2,...,P as balanced panels.

For each gth equation in the system, we can write the model as follows. Here, t is a sequence index, not a time index.

y_git = x_git * b_g + v_gi + e_git i=1,...,N; t=1,...,Ti; g=1,...,G

Observations in the unbalanced panel are rearranged into P balanced panels. In each balanced panel, all observations are observed with the same number of periods. Therefore, the model can be rewritten for each p in P:

y_i(p) = x_i(p) * b + e_p # v_i + e_i(p)


e_p is vector of ones (p x 1); # is the Kronecker direct product.

Using the overall within-individual and between-individual covariation matrices, Biorn (2004) derived the unbiased estimators of sigma_v and sigma_e for each balanced panel. Using those estimated covariance matrices, the GLS problem is considered by minimizing the usual sandwich form with respect to parameter estimates. We then obtain the beta GLS estimator (bGLS_p) for the individuals observed p times. The overall GLS estimator can be shown to be the function of bGLS_p and their variances V(bGLS_p) for p = 1,...,P. Please see Biorn (2004) for details.

In order to get the efficient estimator of the SUR system, the multistep (stepwise) Maximum Likelihood estimation is implemented. The multistep is the problem of two sub-problems: (a) maximizing the log likelihood with respect to beta parameters for given sigma_v and sigma_e, which is the same as the GLS part above, and (b) maximizing the log likelihood with respect to sigma_v and sigma_e for given beta parameters. The multistep algorithm jointly solves (a) and (b), and it will stop until convergence of the overall estimates.

For details of the estimation procedures and simulations for this command, xtsur, please refer to Minh Nguyen and Hoa Nguyen (2010).


level(#) specifies the confidence level, in percent, for confidence intervals of the coefficients; see help level. The default is 95.

multistep implements the multi-step algorithm where the estimated parameters are repeated until convergence from the multi-step ML and GLS procedures.

onestep implements the one-step algorithm where an overall GLS estimate is obtained. The default method is multistep.

tolerance(#) sets the convergence tolerance. The default tolerance is 1e-6.

Return values

Scalars e(N) number of complete observations in unbalanced panel data e(T) maximum number of time periods observed e(k_eq) number of equations e(N_g) number of unique units in groups e(g_min) minumum number of panels e(g_max) maximum number of panels e(tol) convergence tolerance e(cilevel) confidence interval level

Macros e(cmd) name of the command e(cmdline) full command typed e(method) estimation method e(title) title of regression e(version) version of the command e(properties)properties of estimation e(eqnames) equation names e(depvar) dependent variables e(exog) exogenous variables e(endog) endogenous variables e(tvar) time variable e(ivar) ID variable

Matrices e(b) estimated parameters e(V) variance-covariance of estimated parameters e(sigma_u) variance-covariance of random effects e(sigma_e) variance-covariance of error terms r(xtsur) structure of the unbalanced panel dataset

Functions e(sample) sample used in estimation


SUR model with 3 equations . use example.dta, clear . xtsur (y1 x1 x2 x3 x4) (y2 x4 x6 x7) (y3 x7 x9) . xtsur (y1 y2 y3 = x1 x2 x3 x4 x6 x7 x9), onestep . xtsur (y1 y2 = x1 x2 x3 x4 x6) (y3 x6 x7 x9)

SUR model with 2 global equation names . global eqn1 (y1 x1 x2 x3) . global eqn2 (y2 x4 x6 x7) . xtsur $eqn1 $eqn2

. xtsur (equname1: y1 x2 x3 x4) (equname2: y2 x3 x4)

. global eqn1 (equname1: y1 x2 x3 x4) . global eqn2 (equname2: y2 x3 x4) . xtsur $eqn1 $eqn2


Erik Biorn. 2004. Regression system for unbalanced panel data: a stepwise maximum likelihood procedure. Journal of Econometrics 122: 281-91. Minh Nguyen and Hoa Nguyen. 2010. Stata module: Estimation of system of regression equations with unbalanced panel data and random effects. Working Paper.


We would like to thank numerous people for their comments and suggestions. Among them are Brian Poi, Kit Baum and one anonymous reviewer. We also thank all users who feedback had led to steady improvement in xtsur.


Minh Cong Nguyen Enterprise Analysis Unit The World Bank, 2009

Hoa Bao Nguyen Ph.D. Candidate Economics Department Michigan State University East Lansing, MI Email:


This is version 1.0.4 released December 11, 2009.