0% found this document useful (0 votes)
36 views

Bayesbayesxtreg

This document provides information about the bayes: xtreg command in Stata, which fits a Bayesian panel-data random-effects linear regression model. It allows the user to specify prior distributions and simulation settings. The command uses Markov chain Monte Carlo methods such as Gibbs sampling to estimate the model parameters. Stored results include identifiers for groups and the distribution of random effects.

Uploaded by

BelaynehYitayew
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views

Bayesbayesxtreg

This document provides information about the bayes: xtreg command in Stata, which fits a Bayesian panel-data random-effects linear regression model. It allows the user to specify prior distributions and simulation settings. The command uses Markov chain Monte Carlo methods such as Gibbs sampling to estimate the model parameters. Stored results include identifiers for groups and the distribution of random effects.

Uploaded by

BelaynehYitayew
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Title stata.

com
bayes: xtreg — Bayesian random-effects linear model

Description Quick start Menu Syntax


Remarks and examples Stored results Methods and formulas Also see

Description
bayes: xtreg fits a Bayesian panel-data random-effects linear regression to a continuous outcome;
see [BAYES] bayes and [XT] xtreg for details.

Quick start
Bayesian random-effects linear regression of y on x1 and x2 with random intercepts by id (after
xtseting on panel variable id), using default normal priors for regression coefficients and default
inverse-gamma priors for the error variance and for the variance of random intercepts
bayes: xtreg y x1 x2
Use a standard deviation of 10 instead of 100 for the default normal priors
bayes, normalprior(10): xtreg y x1 x2
Use a shape of 1 and a scale of 2 instead of values of 0.01 for the default inverse-gamma prior
bayes, igammaprior(1 2): xtreg y x1 x2
Use uniform priors for the slopes and a normal prior for the intercept
bayes, prior({y: x1 x2}, uniform(-10,10)) ///
prior({y: cons}, normal(0,10)): xtreg y x1 x2
Save simulation results to simdata.dta, and use a random-number seed for reproducibility
bayes, saving(simdata) rseed(123): xtreg y x1 x2
Specify 20,000 Markov chain Monte Carlo (MCMC) samples, set length of the burn-in period to 5,000,
and request that a dot be displayed every 500 simulations
bayes, mcmcsize(20000) burnin(5000) dots(500): xtreg y x1 x2
In the above, request that the 90% highest posterior density (HPD) credible interval be displayed
instead of the default 95% equal-tailed credible interval
bayes, clevel(90) hpd
Use Gibbs sampling for all parameters, including random effects
bayes, gibbs: xtreg y x1 x2
Also see Quick start in [BAYES] bayes and Quick start in [XT] xtreg.

Menu
Statistics > Longitudinal/panel data > Bayesian regression > Linear regression

1
2 bayes: xtreg — Bayesian random-effects linear model

Syntax
         
bayes , bayesopts : xtreg depvar indepvars if in , options

options Description
Model
noconstant suppress constant term
Reporting
display options control spacing, line width, and base and empty cells
level(#) set credible level; default is level(95)
A panel variable must be specified; see [XT] xtset.
indepvars may contain factor variables; see [U] 11.4.3 Factor variables.
depvar and indepvars may contain time-series operators; see [U] 11.4.4 Time-series varlists.
bayes: xtreg, level() is equivalent to bayes, clevel(): xtreg.
For a detailed description of options, see Options in [XT] xtreg.

bayesopts Description
Priors

gibbs specify Gibbs sampling; available only with normal priors for
regression coefficients and an inverse-gamma prior for variance

normalprior(#) specify standard deviation of default normal priors for regression
coefficients; default is normalprior(100)

igammaprior(# #) specify shape and scale of default inverse-gamma prior for
variance components; default is igammaprior(0.01 0.01)
prior(priorspec) prior for model parameters; this option may be repeated
dryrun show model summary without estimation
Simulation
nchains(#) number of chains; default is to simulate one chain
mcmcsize(#) MCMC sample size; default is mcmcsize(10000)
burnin(#) burn-in period; default is burnin(2500)
thinning(#) thinning interval; default is thinning(1)
rseed(#) random-number seed
exclude(paramref ) specify model parameters to be excluded from the simulation results
Blocking
 
block(paramref , blockopts ) specify a block of model parameters; this option may be repeated
blocksummary display block summary
Initialization
initial(initspec) specify initial values for model parameters with a single chain
init#(initspec) specify initial values for #th chain; requires nchains()
initall(initspec) specify initial values for all chains; requires nchains()
nomleinitial suppress the use of maximum likelihood estimates as starting values
initrandom specify random initial values
initsummary display initial values used for simulation

noisily display output from the estimation command during initialization
bayes: xtreg — Bayesian random-effects linear model 3

Adaptation
adaptation(adaptopts) control the adaptive MCMC procedure
scale(#) initial multiplier for scale factor; default is scale(2.38)
covariance(cov) initial proposal covariance; default is the identity matrix
Reporting
clevel(#) set credible interval level; default is clevel(95)
hpd display HPD credible intervals instead of the default equal-tailed
  credible intervals
eform (string) report exponentiated coefficients and, optionally, label as string
remargl compute log marginal-likelihood; suppressed by default
batch(#) specify length of block for batch-means calculations;
  default is batch(0)
saving(filename , replace ) save simulation results to filename.dta
nomodelsummary suppress model summary
chainsdetail display detailed simulation summary for each chain
 
no dots suppress dots or display dots every 100 iterations and iteration
  numbers every 1,000 iterations; default is nodots
dots(#
  , every(#) ) display dots as simulation is performed
no show(paramref ) specify model parameters to be excluded from or included in
  the output
showreffects (reref ) specify that all or a subset of random-effects parameters be included
in the output
notable suppress estimation table
noheader suppress output header
title(string) display string as title above the table of parameter estimates
display options control spacing, line width, and base and empty cells
Advanced
search(search options) control the search for feasible initial values
corrlag(#) specify maximum autocorrelation lag; default varies
corrtol(#) specify autocorrelation tolerance; default is corrtol(0.01)

Starred options are specific to the bayes prefix; other options are common between bayes and bayesmh.
Options prior() and block() may be repeated.
priorspec and paramref are defined in [BAYES] bayesmh.
paramref may contain factor variables; see [U] 11.4.3 Factor variables.
collect is allowed; see [U] 11.1.10 Prefix commands.
See [U] 20 Estimation and postestimation commands for more capabilities of estimation commands.
Model parameters are regression coefficients {depvar:indepvars}, error variance {sigma2}, random effects {U[panelvar]}
or simply {U}, and random-effects variance {var U}. Use the dryrun option to see the definitions of model
parameters prior to estimation.
For a detailed description of bayesopts, see Options in [BAYES] bayes.

Remarks and examples stata.com


For a general introduction to Bayesian analysis, see [BAYES] Intro. For a general introduction to
Bayesian estimation using adaptive Metropolis–Hastings and Gibbs algorithms, see [BAYES] bayesmh.
For remarks and examples specific to the bayes prefix, see [BAYES] bayes. For details about the
estimation command, see [XT] xtreg.
4 bayes: xtreg — Bayesian random-effects linear model

For a simple example of the bayes prefix, see Introductory example in [BAYES] bayes. Also see
Panel-data models in [BAYES] bayes.

Stored results
See Stored results in [BAYES] bayes. In addition, bayes: xtreg also stores the following results:
Macros
e(ivar) variable denoting groups
e(redistrib) distribution of random effects

Methods and formulas


See Methods and formulas in [BAYES] bayesmh.

Also see
[BAYES] bayes — Bayesian regression models using the bayes prefix
[XT] xtreg — Fixed-, between-, and random-effects and population-averaged linear models
[BAYES] Bayesian postestimation — Postestimation tools for bayesmh and the bayes prefix
[BAYES] Bayesian estimation — Bayesian estimation commands
[BAYES] Bayesian commands — Introduction to commands for Bayesian analysis
[BAYES] Intro — Introduction to Bayesian analysis
[BAYES] Glossary

You might also like