Home  /  Products  /  Features  /  Bayesian analysis
Order

Bayesian analysis

Fit Bayesian regression models using one of the Markov chain Monte Carlo (MCMC) methods. You can choose from a variety of supported models or even program your own. Extensive tools are available to check convergence, including multiple chains. Compute posterior mean estimates and credible intervals for model parameters and functions of model parameters. You can perform both interval- and model-based hypothesis testing. Compare models using Bayes factors. Compute model fit using posterior predictive p-values. Generate predictions. And much more.

Learn about Bayesian analysis and see examples of Bayesian features, including Bayesian econometrics, Bayesian model averaging (BMA), and Bayesian variable selection New.

See what's new in Bayesian analysis.

Also see an Overview example.

Estimation Updated

  • Thousands of built-in models, by combining
    • over 60 likelihood models, including univariate and multivariate normal, asymmetric Laplace New, logit, probit, ordered logit, ordered probit, Poisson ...
    • Many prior distributions, including normal, lognormal, multivariate normal, gamma, beta, Wishart ... Updated
    • Continuous, binary, ordinal, count, and survival outcomes
    • Univariate, multivariate, and multiple-equation models
    • Linear and nonlinear models
    • Continuous univariate, multivariate, and discrete priors
  • bayes: prefix Updated
    • Simply type bayes: in front of any of over 60 estimation commands to fit Bayesian regression models
    • Change any of the default priors
    • Change any of the simulation or sampling settings
    • Time-series operators
    • Control Panel lets you specify and fit models from an easy-to-use interface
  • Variable selection New
  • Multiple chains
  • Use GUI to fit models
  • Use command language to fit models
  • Time-series operators

Classes of models

Likelihood models

Prior distributions

  • Normal
  • Generalized (location-scale) t
  • Lognormal
  • Uniform
  • Gamma
  • Inverse gamma
  • Exponential
  • Laplace
  • Cauchy
  • Half-Cauchy New
  • Beta
  • Chi-squared
  • Rayleigh New
  • Pareto
  • Multivariate normal
  • Dirichlet
  • Wishart
  • Inverse Wishart
  • Bernoulli
  • Geometric
  • Discrete
  • Poisson
  • User-defined density
  • User-defined log density
  • Specialized priors

Add your own models Updated

  • Write your own programs to calculate likelihood function and choose built-in priors
  • Write your own programs to calculate posterior density directly
  • Use built-in adaptive MH sampling to simulate marginal posterior

Markov chain Monte Carlo (MCMC) methods

  • Adaptive Metropolis-Hastings (MH)
  • Hybrid MH (adaptive MH with Gibbs updates)
  • Full Gibbs sampling for some models Updated
  • Efficient sampling of random effects New
  • Bayesian predictions New

Simulation

Adaptive MH sampling

  • Blocking of parameters
  • Adaptation within each block
  • Diminishing adaptation
  • Random-effects parameters
  • Control scale and covariance of the proposal distribution
  • Control adaptation
    • Length of adaptation
    • Maximum and minimum numbers of adaptive iterations
    • Acceptance rate
    • Adaptation rate
    • Target acceptance rate
    • Acceptance rate tolerance

Starting values

  • Automatic
  • May specify for some or all parameters
  • May specify for some or all chains

Postestimation Selector

  • View and run all postestimation features for your command
  • Automatically updated as estimation commands are run

bayes4a_stcolor.svg

Tools to check MCMC convergence

Tools to check MCMC efficiency

  • Effective sample sizes
  • Autocorrelation times
  • Efficiencies
  • Compute any of the above for parameters or functions of parameters

Posterior summaries

MCSE estimation methods

  • using effective sample size
  • using batch means

Hypothesis testing

Predictions Updated

  • Generate predictions: simulate outcome values and their functions
  • Save all or a subset of predictions in a separate dataset
  • Save posterior summaries of predictions as variables in current dataset
  • Save a subset of MCMC replicates as variables in current dataset
  • Obtain graphical and posterior summaries, perform hypothesis tests, and more
  • Use built-in tools to create functions of predictions or write your own Mata functions and Stata programs
  • Generate replicated data for posterior predictive checks
  • Predictions for user-defined evaluators New

Model comparison

Model goodness of fit

  • Posterior predictive p-values
  • MCMC replicates
  • Predictions

Specialized postestimation

Save your MCMC and estimation results for future use

Factor variables

  • Automatically create indicators based on categorical variables
  • Form interactions among discrete and continuous variables
  • Include polynomial terms
Watch Introduction to Factor Variables in Stata tutorials

Additional resources

Watch Bayesian analysis in Stata
Watch Introduction to Bayesian analysis, part 1: The basic concepts
Watch Introduction to Bayesian analysis, part 2: MCMC and the Metropolis–Hastings algorithm
Watch bayes: prefix for fitting Bayesian regressions
Watch Bayesian linear regression using the bayes prefix
Watch Bayesian linear regression using the bayes prefix: How to specify custom priors
Watch Bayesian quantile regression with asymmetric Laplace distribution New
Watch Bayesian econometrics
Watch Bayesian dynamic stochastic general equilibrium models
Watch Bayesian dynamic forecasting
Watch Bayesian multilevel modeling
Watch Bayesian panel-data models
Watch Bayesian impulse–response functions and forecast error-variance decompositions
Watch Bayesian vector autoregressive models
Watch Bayesian variable selection for linear regression New

See New in Stata 19 to learn about what was added in Stata 19.