Stata 15 help for xtgls

[XT] xtgls -- Fit panel-data models by using GLS


xtgls depvar [indepvars] [if] [in] [weight] [, options]

options Description ------------------------------------------------------------------------- Model noconstant suppress constant term panels(iid) use i.i.d. error structure panels(heteroskedastic) use heteroskedastic but uncorrelated error structure panels(correlated) use heteroskedastic and correlated error structure corr(independent) use independent autocorrelation structure corr(ar1) use AR1 autocorrelation structure corr(psar1) use panel-specific AR1 autocorrelation structure rhotype(calc) specify method to compute autocorrelation parameter; see Options for details; seldom used igls use iterated GLS estimator instead of two-step GLS estimator force estimate even if observations unequally spaced in time

SE nmk normalize standard error by N-k instead of N

Reporting level(#) set confidence level; default is level(95) display_options control columns and column formats, row spacing, line width, display of omitted variables and base and empty cells, and factor-variable labeling

Optimization optimize_options control the optimization process; seldom used

coeflegend display legend instead of statistics ------------------------------------------------------------------------- A panel variable must be specified. For correlation structures other than independent, a time variable must be specified. A time variable must also be specified if panels(correlated) is specified. Use xtset. indepvars may contain factor variables; see fvvarlist. depvar and indepvars may contain time-series operators; see tsvarlist. by and statsby are allowed; see prefix. aweights are allowed; see weight. coeflegend does not appear in the dialog box. See [XT] xtgls postestimation for features available after estimation.


Statistics > Longitudinal/panel data > Contemporaneous correlation > GLS regression with correlated disturbances


xtgls fits panel-data linear models by using feasible generalized least squares. This command allows estimation in the presence of AR(1) autocorrelation within panels and cross-sectional correlation and heteroskedasticity across panels.


+-------+ ----+ Model +------------------------------------------------------------

noconstant; see [R] estimation options.

panels(pdist) specifies the error structure across panels.

panels(iid) specifies a homoskedastic error structure with no cross-sectional correlation. This is the default.

panels(heteroskedastic) specifies a heteroskedastic error structure with no cross-sectional correlation.

panels(correlated) specifies a heteroskedastic error structure with cross-sectional correlation. If p(c) is specified, you must also specify a time variable (use xtset). The results will be based on a generalized inverse of a singular matrix unless T>=m (the number of periods is greater than or equal to the number of panels).

corr(corr) specifies the assumed autocorrelation within panels.

corr(independent) specifies that there is no autocorrelation. This is the default.

corr(ar1) specifies that, within panels, there is AR(1) autocorrelation and that the coefficient of the AR(1) process is common to all the panels. If c(ar1) is specified, you must also specify a time variable (use xtset).

corr(psar1) specifies that, within panels, there is AR(1) autocorrelation and that the coefficient of the AR(1) process is specific to each panel. psar1 stands for panel-specific AR(1). If c(psar1) is specified, a time variable must also be specified; use xtset.

rhotype(calc) specifies the method to be used to calculate the autocorrelation parameter:

regress regression using lags; the default dw Durbin-Watson calculation freg regression using leads nagar Nagar calculation theil Theil calculation tscorr time-series autocorrelation calculation

All the calculations are asymptotically equivalent and consistent; this is a rarely used option.

igls requests an iterated GLS estimator instead of the two-step GLS estimator for a nonautocorrelated model or instead of the three-step GLS estimator for an autocorrelated model. The iterated GLS estimator converges to the MLE for the corr(independent) models but does not for the other corr() models.

force specifies that estimation be forced even though the time variable is not equally spaced. This is relevant only for correlation structures that require knowledge of the time variable. These correlation structures require that observations be equally spaced so that calculations based on lags correspond to a constant time change. If you specify a time variable indicating that observations are not equally spaced, the (time dependent) model will not be fit. If you also specify force, the model will be fit, and it will be assumed that the lags based on the data ordered by the time variable are appropriate.

+----+ ----+ SE +---------------------------------------------------------------

nmk specifies that standard errors normalized by N-k, where k is the number of parameters estimated, rather than N, the number of observations. Different authors have used one or the other normalization. Greene (2018, 313) remarks that whether a degree-of-freedom correction improves the small-sample properties is an open question.

+-----------+ ----+ Reporting +--------------------------------------------------------

level(#); see [R] estimation options.

display_options: noci, nopvalues, noomitted, vsquish, noemptycells, baselevels, allbaselevels, nofvlabel, fvwrap(#), fvwrapon(style), cformat(%fmt), pformat(%fmt), sformat(%fmt), and nolstretch; see [R] estimation options.

+--------------+ ----+ Optimization +-----------------------------------------------------

optimize_options control the iterative optimization process. These options are seldom used.

iterate(#) specifies the maximum number of iterations. When the number of iterations equals #, the optimization stops and presents the current results, even if convergence has not been reached. The default is iterate(100).

tolerance(#) specifies the tolerance for the coefficient vector. When the relative change in the coefficient vector from one iteration to the next is less than or equal to #, the optimization process is stopped. tolerance(1e-7) is the default.

nolog suppress the display of the iteration log.

The following option is available with xtgls but is not shown in the dialog box:

coeflegend; see [R] estimation options.


Setup . webuse invest2 . xtset company time

Fit panel-data model with heteroskedasticity across panels . xtgls invest market stock, panels(hetero)

Correlation and heteroskedasticity across panels . xtgls invest market stock, panels(correlated)

Heteroskedasticity across panels and autocorrelation within panels . xtgls invest market stock, panels(hetero) corr(ar1)

Stored results

xtgls stores the following in e():

Scalars e(N) number of observations e(N_g) number of groups e(N_t) number of periods e(N_miss) number of missing observations e(n_cf) number of estimated coefficients e(n_cv) number of estimated covariances e(n_cr) number of estimated correlations e(df_pear) degrees of freedom for Pearson chi-squared e(chi2) chi-squared e(df) degrees of freedom e(g_min) smallest group size e(g_avg) average group size e(g_max) largest group size e(rank) rank of e(V) e(rc) return code

Macros e(cmd) xtgls e(cmdline) command as typed e(depvar) name of dependent variable e(ivar) variable denoting groups e(tvar) variable denoting time within groups e(coefftype) estimation scheme e(corr) correlation structure e(vt) panel option e(rhotype) type of estimated correlation e(wtype) weight type e(wexp) weight expression e(title) title in estimation output e(chi2type) Wald; type of model chi-squared test e(rho) rho e(properties) b V e(predict) program used to implement predict e(asbalanced) factor variables fvset as asbalanced e(asobserved) factor variables fvset as asobserved

Matrices e(b) coefficient vector e(Sigma) Sigma hat matrix e(V) variance-covariance matrix of the estimators

Functions e(sample) marks estimation sample


Greene, W. H. 2018. Econometric Analysis. 8th ed. New York: Pearson.

© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index