## Stata 15 help for bayes_meologit

```
[BAYES] bayes: meologit -- Bayesian multilevel ordered logistic regression

Syntax

bayes [, bayesopts] : meologit depvar fe_equation [|| re_equation]
[|| re_equation ...] [, options]

where the syntax of fe_equation is

[indepvars] [if] [in] [weight] [, fe_options]

and the syntax of re_equation is one of the following:

for random coefficients and intercepts

levelvar: [varlist] [, re_options]

for a random effect among the values of a factor variable

levelvar: R.varname

levelvar either is a variable identifying the group structure for the
random effects at that level or is _all, representing one group
comprising all observations.

fe_options               Description
-------------------------------------------------------------------------
Model
offset(varname)        include varname in model with coefficient
constrained to 1
-------------------------------------------------------------------------

re_options               Description
-------------------------------------------------------------------------
Model
covariance(vartype)    variance-covariance structure of the random
effects; only structures independent,
identity, and unstructured supported
noconstant             suppress constant term from the random-effects
equation
-------------------------------------------------------------------------

options                  Description
-------------------------------------------------------------------------
Model
collinear              keep collinear variables

Reporting
or                     report odds ratios
notable                suppress coefficient table
nogroup                suppress table summarizing groups
display_options        control spacing, line width, and base and empty
cells

level(#)               set credible level; default is level(95)
-------------------------------------------------------------------------
indepvars may contain factor variables; see fvvarlist.
depvar, indepvars, and varlist may contain time-series operators; see
tsvarlist.
fweights are allowed; see weight.
bayes: meologit, level() is equivalent to bayes, clevel(): meologit.
For a detailed description of options, see Options in [ME] meologit.

bayesopts                       Description
-------------------------------------------------------------------------
Priors
* 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)
* iwishartprior(# [...])        specify degrees of freedom and,
optionally, scale matrix of default
inverse-Wishart prior for unstructured
random-effects covariance

prior(priorspec)              prior for model parameters; this option
may be repeated
dryrun                        show model summary without estimation

Simulation
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
restubs(restub1 restub2 ...)  specify stubs for random-effects
parameters for all levels

Blocking
* blocksize(#)                  maximum block size; default is
blocksize(50)
block(paramref[, blockopts])  specify a block of model parameters; this
option may be repeated
blocksummary                  display block summary

* noblocking                    do not block parameters by default

Initialization
initial(initspec)             initial values for model parameters
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

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
* or                            report coefficients as odds ratios
eform[(string)]               report exponentiated coefficients and,
optionally, label as string
remargl                       compute log marginal likelihood
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
nomesummary                   suppress multilevel-structure summary
[no]dots                      suppress dots or display dots every 100
iterations and iteration numbers every
1,000 iterations; default is dots
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
melabel                       display estimation table using the same
row labels as meologit
nogroup                       suppress table summarizing groups
notable                       suppress estimation table
title(string)                 display string as title above the table
of parameter estimates
display_options               control spacing, line width, and base and
empty cells

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() can be repeated.
priorspec and paramref are defined in [BAYES] bayesmh.
paramref may contain factor variables; see fvvarlist.
See [BAYES] bayesian postestimation for features available after
estimation.
Model parameters are regression coefficients {depvar:indepvars},
cutpoints {cut1}, {cut2}, and so on, random effects {rename}, and
either variance components {rename:sigma2} or, if option
covariance(unstructured) is specified, matrix parameter
{restub:Sigma,matrix}; see Likelihood model in [BAYES] bayes for how
renames and restub are defined.  Use the dryrun option to see the
definitions of model parameters prior to estimation.
Flat priors, flat, are used by default for cutpoints.
For a detailed description of bayesopts, see Options in [BAYES] bayes.

Statistics > Multilevel mixed-effects models > Bayesian regression >
Ordered logistic regression

Description

bayes: meologit fits a Bayesian multilevel ordered logistic regression to
an ordinal outcome; see [BAYES] bayes and [ME] meologit for details.

Examples

Setup
. webuse tvsfpors
. keep if school < 500

Fit Bayesian two-level ordered logit regression using default priors
. bayes: meologit thk prethk cc##tv || school:

Display odds ratios instead of coefficients
. bayes, or

In addition to the main model parameters, display results for random
effects corresponding to school codes 193 through 199
. bayes, showreffects({U0[(193/199).school]})

Check MCMC convergence for the main model parameters
. bayesgraph diagnostics _all

Check MCMC convergence for the first, 10th, and 15th random effects
. bayesgraph diagnostics {U0[1 10 15]}

Plot histograms of posterior distributions of the first 12 random effects
on one graph
. bayesgraph histogram {U0[1/12]}, byparm

Display estimation results using meologit's parameter labels and compute
log marginal likelihood on replay
. bayes, melabel remargl

Save MCMC results on replay
. bayes, saving(mymcmc)

Fit Bayesian three-level ordered logit regression, specifying a standard
deviation of 10 instead of 100 of the default normal priors for the
regression coefficients and using a smaller MCMC size of 1,000 instead of
the default of 10,000
. bayes, normalprior(10) mcmcsize(1000): meologit thk prethk cc##tv
|| school: || class:

Stored results

See Stored results in [BAYES] bayesmh.

```