help xtreg dialog: xtreg
also see: xtreg postestimation
-------------------------------------------------------------------------------
Title
[XT] xtreg -- Fixed-, between-, and random-effects, and
population-averaged linear models
Syntax
GLS random-effects (RE) model
xtreg depvar [indepvars] [if] [in] [, re RE_options]
Between-effects (BE) model
xtreg depvar [indepvars] [if] [in] , be [BE_options]
Fixed-effects (FE) model
xtreg depvar [indepvars] [if] [in] [weight] , fe [FE_options]
ML random-effects (MLE) model
xtreg depvar [indepvars] [if] [in] [weight] , mle [MLE_options]
Population-averaged (PA) model
xtreg depvar [indepvars] [if] [in] [weight] , pa [PA_options]
RE_options description
-------------------------------------------------------------------------
Model
re use random-effects estimator; the default
sa use Swamy-Arora estimator of the variance
components
SE/Robust
vce(vcetype) vcetype may be conventional, robust, cluster
clustvar, bootstrap, or jackknife
Reporting
level(#) set confidence level; default is level(95)
theta report theta
display_options control spacing and display of omitted variables
and base and empty cells
+ coeflegend display coefficients' legend instead of coefficient
table
-------------------------------------------------------------------------
+ coeflegend does not appear in the dialog box.
BE_options description
-------------------------------------------------------------------------
Model
be use between-effects estimator
wls use weighted least squares
SE
vce(vcetype) vcetype may be conventional, bootstrap, or
jackknife
Reporting
level(#) set confidence level; default is level(95)
display_options control spacing and display of omitted variables
and base and empty cells
+ coeflegend display coefficients' legend instead of coefficient
table
-------------------------------------------------------------------------
+ coeflegend does not appear in the dialog box.
FE_options description
-------------------------------------------------------------------------
Model
fe use fixed-effects estimator
SE/Robust
vce(vcetype) vcetype may be conventional, robust, cluster
clustvar, bootstrap, or jackknife
Reporting
level(#) set confidence level; default is level(95)
display_options control spacing and display of omitted variables
and base and empty cells
+ coeflegend display coefficients' legend instead of coefficient
table
-------------------------------------------------------------------------
+ coeflegend does not appear in the dialog box.
MLE_options description
-------------------------------------------------------------------------
Model
noconstant suppress constant term
mle use ML random-effects estimator
SE
vce(vcetype) vcetype may be oim, bootstrap, or jackknife
Reporting
level(#) set confidence level; default is level(95)
display_options control spacing and display of omitted variables
and base and empty cells
Maximization
maximize_options control the maximization process; seldom used
+ coeflegend display coefficients' legend instead of coefficient
table
-------------------------------------------------------------------------
+ coeflegend does not appear in the dialog box.
PA_options description
-------------------------------------------------------------------------
Model
noconstant suppress constant term
pa use population-averaged estimator
offset(varname) include varname in model with coefficient
constrained to 1
Correlation
corr(correlation) within-group correlation structure
force estimate even if observations unequally spaced in
time
SE/Robust
vce(vcetype) vcetype may be conventional, robust, bootstrap, or
jackknife
nmp use divisor N-P instead of the default N
rgf multiply the robust variance estimate by
(N-1)/(N-P)
scale(parm) override the default scale parameter; parm may be
x2, dev, phi, or #
Reporting
level(#) set confidence level; default is level(95)
display_options control spacing and display of omitted variables
and base and empty cells
Optimization
optimize_options control the optimization process; seldom used
+ coeflegend display coefficients' legend instead of coefficient
table
-------------------------------------------------------------------------
+ coeflegend does not appear in the dialog box.
correlation description
-------------------------------------------------------------------------
exchangeable exchangeable
independent independent
unstructured unstructured
fixed matname user-specified
ar # autoregressive of order #
stationary # stationary of order #
nonstationary # nonstationary of order #
-------------------------------------------------------------------------
A panel variable must be specified. For xtreg, pa, correlation structures
other than exchangeable and independent require that a time variable
also be 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, fweights, and pweights are allowed for the fixed-effects model.
iweights, fweights, and pweights are allowed for the
population-averaged model. iweights are allowed for the
maximum-likelihood random-effects (MLE) model. Weights must be
constant within panel.
See [XT] xtreg postestimation for features available after estimation.
Menu
Statistics > Longitudinal/panel data > Linear models > Linear regression
(FE, RE, PA, BE)
Description
xtreg fits cross-sectional time-series regression models. In particular,
xtreg with the be option fits random-effects models by using the between
regression estimator; with the fe option, it fits fixed-effects models
(by using the within regression estimator); and with the re option, it
fits random-effects models by using the GLS estimator (producing a
matrix-weighted average of the between and within results). See [XT]
xtdata for a faster way to fit fixed- and random-effects models.
Options for RE model
+-------+
----+ Model +------------------------------------------------------------
re, the default, requests the GLS random-effects estimator.
sa specifies that the small-sample Swamy-Arora estimator individual-level
variance component be used instead of the default consistent
estimator.
+-----------+
----+ SE/Robust +--------------------------------------------------------
vce(vcetype) specifies the type of standard error reported, which
includes types that are derived from asymptotic theory, that are
robust to some kinds of misspecification, that allow for intragroup
correlation, and that use bootstrap or jackknife methods; see [XT]
vce_options.
vce(conventional), the default, uses the conventionally derived
variance estimator for generalized least-squares regression.
Specifying vce(robust) is equivalent to specifying vce(cluster
panelvar); see xtreg, re in Methods and formulas.
+-----------+
----+ Reporting +--------------------------------------------------------
level(#); see [R] estimation options.
theta specifies that the output should include the estimated value of
theta used in combining the between and fixed estimators. For
balanced data, this is a constant, and for unbalanced data, a summary
of the values is presented in the header of the output.
display_options: noomitted, vsquish, noemptycells, baselevels,
allbaselevels; see [R] estimation options.
The following option is available with xtreg but is not shown in the
dialog box:
coeflegend; see [R] estimation options.
Options for BE model
+-------+
----+ Model +------------------------------------------------------------
be requests the between regression estimator.
wls specifies that, for unbalanced data, weighted least squares be used
rather than the default OLS. Both methods produce consistent
estimates.
+----+
----+ SE +---------------------------------------------------------------
vce(vcetype) specifies the type of standard error reported, which
includes types that are derived from asymptotic theory and that use
bootstrap or jackknife methods; see [XT] vce_options.
vce(conventional), the default, uses the conventionally derived
variance estimator for generalized least squares regression.
+-----------+
----+ Reporting +--------------------------------------------------------
level(#); see [R] estimation options.
display_options: noomitted, vsquish, noemptycells, baselevels,
allbaselevels; see [R] estimation options.
The following option is available with xtreg but is not shown in the
dialog box:
coeflegend; see [R] estimation options.
Options for FE model
+-------+
----+ Model +------------------------------------------------------------
fe requests the fixed-effects (within) regression estimator.
+-----------+
----+ SE/Robust +--------------------------------------------------------
vce(vcetype) specifies the type of standard error reported, which
includes types that are derived from asymptotic theory, that are
robust to some kinds of misspecification, that allow for intragroup
correlation, and that use bootstrap or jackknife methods; see [XT]
vce_options.
vce(conventional), the default, uses the conventionally derived
variance estimator for generalized least squares regression.
Specifying vce(robust) is equivalent to specifying vce(cluster
panelvar); see xtreg, fe in Methods and formulas.
+-----------+
----+ Reporting +--------------------------------------------------------
level(#); see [R] estimation options.
display_options: noomitted, vsquish, noemptycells, baselevels,
allbaselevels; see [R] estimation options.
The following option is available with xtreg but is not shown in the
dialog box:
coeflegend; see [R] estimation options.
Options for MLE model
+-------+
----+ Model +------------------------------------------------------------
noconstant; see [R] estimation options.
mle requests the maximum-likelihood random-effects estimator.
+----+
----+ SE +---------------------------------------------------------------
vce(vcetype) specifies the type of standard error reported, which
includes types that are derived from asymptotic theory and that use
bootstrap or jackknife methods; see [XT] vce_options.
+-----------+
----+ Reporting +--------------------------------------------------------
level(#); see [R] estimation options.
display_options: noomitted, vsquish, noemptycells, baselevels,
allbaselevels; see [R] estimation options.
+--------------+
----+ Maximization +-----------------------------------------------------
maximize_options: iterate(#), [no]log, trace, tolerance(#),
ltolerance(#), from(init_specs); see [R] maximize. These options are
seldom used.
The following option is available with xtreg but is not shown in the
dialog box:
coeflegend; see [R] estimation options.
Options for PA model
+-------+
----+ Model +------------------------------------------------------------
noconstant; see [R] estimation options.
pa requests the population-averaged estimator. For linear regression,
this is the same as a random-effects estimator (both interpretations
hold).
xtreg, pa is equivalent to xtgee, family(gaussian) link(id)
corr(exchangeable), which are all the defaults for the xtgee command.
xtreg, pa allows all the relevant xtgee options such as robust.
Whether you use xtreg, pa or xtgee makes no difference. See [XT]
xtgee.
offset(varname); see [R] estimation options.
+-------------+
----+ Correlation +------------------------------------------------------
corr(correlation), force; see [R] estimation options.
+-----------+
----+ SE/Robust +--------------------------------------------------------
vce(vcetype) specifies the type of standard error reported, which
includes types that are derived from asymptotic theory, that are
robust to some kinds of misspecification, and that use bootstrap or
jackknife methods; see [XT] vce_options.
vce(conventional), the default, uses the conventionally derived
variance estimator for generalized least squares regression.
nmp; see [XT] vce_options.
rgf specifies that the robust variance estimate is multiplied by
(N-1)/(N-P), where N is the total number of observations and P is the
number of coefficients estimated. This option can be used with
family(gaussian) only when robust is either specified or implied by
the use of pweights. Using this option implies that the robust
variance estimate is not invariant to the scale of any weights used.
scale(x2|dev|phi|#); see [XT] vce_options.
+-----------+
----+ Reporting +--------------------------------------------------------
level(#); see [R] estimation options.
display_options: noomitted, vsquish, noemptycells, baselevels,
allbaselevels; 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 the convergence tolerance has not been
reached. The default value of iterate() is 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-6) is the default.
nolog suppress the display of the iteration log.
trace specifies that the current estimates should be printed at each
iteration.
The following option is available with xtreg but is not shown in the
dialog box:
coeflegend; see [R] estimation options.
Examples
Setup
. webuse nlswork
. xtset idcode
Between-effects model
. xtreg ln_w grade age c.age#c.age ttl_exp c.ttl_exp#c.ttl_exp tenure
c.tenure#c.tenure 2.race not_smsa south, be
Additional setup if not using factor variables
. generate age2 = age^2
. generate ttl_exp2 = ttl_exp^2
. generate tenure2 = tenure^2
. generate byte black = (race==2)
Between-effects model same as above, but not using factor variables
. xtreg ln_w grade age* ttl_exp* tenure* black not_smsa south, be
Fixed-effects model
. xtreg ln_w grade age c.age#c.age ttl_exp c.ttl_exp#c.ttl_exp tenure
c.tenure#c.tenure 2.race not_smsa south, fe
Fixed-effects model with robust variance
. xtreg ln_w grade age c.age#c.age ttl_exp c.ttl_exp#c.ttl_exp tenure
c.tenure#c.tenure 2.race not_smsa south, fe vce(robust)
Random-effects model
. xtreg ln_w grade age c.age#c.age ttl_exp c.ttl_exp#c.ttl_exp tenure
c.tenure#c.tenure 2.race not_smsa south, re theta
Random-effects model using maximum likelihood estimator
. xtreg ln_w grade age c.age#c.age ttl_exp c.ttl_exp#c.ttl_exp tenure
c.tenure#c.tenure 2.race not_smsa south, mle
Population-averaged model
. xtreg ln_w grade age c.age#c.age ttl_exp c.ttl_exp#c.ttl_exp tenure
c.tenure#c.tenure 2.race not_smsa south, pa
Saved results
xtreg, re saves the following in e():
Scalars
e(N) number of observations
e(N_g) number of groups
e(df_m) model degrees of freedom
e(g_min) smallest group size
e(g_avg) average group size
e(g_max) largest group size
e(Tcon) 1 if T is constant
e(sigma) ancillary parameter (gamma, lnormal)
e(sigma_u) panel-level standard deviation
e(sigma_e) standard deviation of epsilon_it
e(r2_w) R-squared within model
e(r2_o) R-squared overall model
e(r2_b) R-squared between model
e(N_clust) number of clusters
e(chi2) chi-squared
e(rho) rho
e(thta_min) minimum theta
e(thta_5) theta, 5th percentile
e(thta_50) theta, 50th percentile
e(thta_95) theta, 95th percentile
e(thta_max) maximum theta
e(rmse) root mean squared error of GLS regression
e(Tbar) harmonic mean of group sizes
e(rank) rank of e(V)
Macros
e(cmd) xtreg
e(cmdline) command as typed
e(depvar) name of dependent variable
e(ivar) variable denoting groups
e(model) re
e(clustvar) name of cluster variable
e(chi2type) Wald; type of model chi-squared test
e(vce) vcetype specified in vce()
e(vcetype) title used to label Std. Err.
e(sa) Swamy-Arora estimator of the variance components
(sa only)
e(properties) b V
e(predict) program used to implement predict
e(marginsnotok) predictions disallowed by margins
e(asbalanced) factor variables fvset as asbalanced
e(asobserved) factor variables fvset as asobserved
Matrices
e(b) coefficient vector
e(bf) coefficient vector for fixed-effects model
e(theta) theta
e(V) variance-covariance matrix of the estimators
e(VCEf) VCE for fixed-effects model
Functions
e(sample) marks estimation sample
xtreg, be saves the following in e():
Scalars
e(N) number of observations
e(N_g) number of groups
e(mss) model sum of squares
e(df_m) model degrees of freedom
e(rss) residual sum of squares
e(df_r) residual degrees of freedom
e(ll) log likelihood
e(ll_0) log likelihood, constant-only model
e(g_min) smallest group size
e(g_avg) average group size
e(g_max) largest group size
e(Tcon) 1 if T is constant
e(r2) R-squared
e(r2_a) adjusted R-squared
e(r2_w) R-squared within model
e(r2_o) R-squared overall model
e(r2_b) R-squared between model
e(F) F statistic
e(rmse) root mean squared error
e(Tbar) harmonic mean of group sizes
e(rank) rank of e(V)
Macros
e(cmd) xtreg
e(cmdline) command as typed
e(depvar) name of dependent variable
e(ivar) variable denoting groups
e(model) be
e(title) title in estimation output
e(vce) vcetype specified in vce()
e(vcetype) title used to label Std. Err.
e(properties) b V
e(predict) program used to implement predict
e(marginsok) predictions allowed by margins
e(marginsnotok) predictions disallowed by margins
e(asbalanced) factor variables fvset as asbalanced
e(asobserved) factor variables fvset as asobserved
Matrices
e(b) coefficient vector
e(V) variance-covariance matrix of the estimators
Functions
e(sample) marks estimation sample
xtreg, fe saves the following in e():
Scalars
e(N) number of observations
e(N_g) number of groups
e(mss) model sum of squares
e(df_m) model degrees of freedom
e(rss) residual sum of squares
e(df_r) residual degrees of freedom
e(tss) total sum of squares
e(g_min) smallest group size
e(g_avg) average group size
e(g_max) largest group size
e(Tcon) 1 if T is constant
e(sigma) ancillary parameter (gamma, lnormal)
e(corr) corr(u_i, Xb)
e(sigma_u) panel-level standard deviation
e(sigma_e) standard deviation of epsilon_it
e(r2) R-squared
e(r2_a) adjusted R-squared
e(r2_w) R-squared within model
e(r2_o) R-squared overall model
e(r2_b) R-squared between model
e(ll) log likelihood
e(ll_0) log likelihood, constant-only model
e(N_clust) number of clusters
e(rho) rho
e(F) F statistic
e(F_f) F for u_i=0
e(df_a) degrees of freedom for absorbed effect
e(df_b) numerator degrees of freedom F statistic
e(rmse) root mean squared error
e(Tbar) harmonic mean of group sizes
e(rank) rank of e(V)
Macros
e(cmd) xtreg
e(cmdline) command as typed
e(depvar) name of dependent variable
e(ivar) variable denoting groups
e(model) fe
e(wtype) weight type
e(wexp) weight expression
e(clustvar) name of cluster variable
e(vce) vcetype specified in vce()
e(vcetype) title used to label Std. Err.
e(properties) b V
e(predict) program used to implement predict
e(marginsnotok) predictions disallowed by margins
e(asbalanced) factor variables fvset as asbalanced
e(asobserved) factor variables fvset as asobserved
Matrices
e(b) coefficient vector
e(V) variance-covariance matrix of the estimators
Functions
e(sample) marks estimation sample
xtreg, mle saves the following in e():
Scalars
e(N) number of observations
e(N_g) number of groups
e(k_eq_skip) identifies which equations should not be reported
in the coefficient table
e(df_m) model degrees of freedom
e(g_min) smallest group size
e(g_avg) average group size
e(g_max) largest group size
e(sigma_u) panel-level standard deviation
e(sigma_e) standard deviation of epsilon_it
e(ll) log likelihood
e(ll_0) log likelihood, constant-only model
e(ll_c) log likelihood, comparison model
e(chi2) chi-squared
e(chi2_c) chi-squared for comparison test
e(rho) rho
e(rank) rank of e(V)
Macros
e(cmd) xtreg
e(cmdline) command as typed
e(depvar) name of dependent variable
e(ivar) variable denoting groups
e(model) ml
e(wtype) weight type
e(wexp) weight expression
e(title) title in estimation output
e(vce) vcetype specified in vce()
e(vcetype) title used to label Std. Err.
e(chi2type) Wald or LR; type of model chi-squared test
e(chi2_ct) Wald or LR; type of model chi-squared test
corresponding to e(chi2_c)
e(distrib) Gaussian; the distribution of the RE
e(diparm#) display transformed parameter #
e(crittype) optimization criterion
e(properties) b V
e(predict) program used to implement predict
e(marginsnotok) predictions disallowed by margins
e(asbalanced) factor variables fvset as asbalanced
e(asobserved) factor variables fvset as asobserved
Matrices
e(b) coefficient vector
e(V) variance-covariance matrix of the estimators
Functions
e(sample) marks estimation sample
xtreg, pa saves the following in e():
Scalars
e(N) number of observations
e(N_g) number of groups
e(df_m) model degrees of freedom
e(chi2) chi-squared
e(df_pear) degrees of freedom for Pearson chi-squared
e(chi2_dev) chi-squared test of deviance
e(chi2_dis) chi-squared test of deviance dispersion
e(deviance) deviance
e(dispers) deviance dispersion
e(phi) scale parameter
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(tol) target tolerance
e(dif) achieved tolerance
e(rc) return code
Macros
e(cmd) xtgee
e(cmd2) xtreg
e(cmdline) command as typed
e(depvar) name of dependent variable
e(ivar) variable denoting groups
e(model) pa
e(family) Gaussian
e(link) identity; link function
e(corr) correlation structure
e(scale) x2, dev, phi, or #; scale parameter
e(disp) deviance dispersion
e(wtype) weight type
e(wexp) weight expression
e(offset) offset
e(chi2type) Wald; type of model chi-squared test
e(vce) vcetype specified in vce()
e(vcetype) title used to label Std. Err.
e(robust_prolog) program to prepare estimates for linearized VCE
computations
e(robust_epilog) program to finalize estimates after linearized VCE
computations
e(crittype) optimization criterion
e(properties) b V
e(predict) program used to implement predict
e(marginsnotok) predictions disallowed by margins
e(asbalanced) factor variables fvset as asbalanced
e(asobserved) factor variables fvset as asobserved
Matrices
e(b) coefficient vector
e(R) estimated working correlation matrix
e(V) variance-covariance matrix of the estimators
e(V_modelbased) model-based variance
Functions
e(sample) marks estimation sample
Also see
Manual: [XT] xtreg
Help: [XT] xtreg postestimation;
[XT] xtgee, [XT] xtgls, [XT] xtivreg, [XT] xtmixed, [XT]
xtregar, [R] areg, [TS] prais, [R] regress