**[ME] menbreg** -- Multilevel mixed-effects negative binomial regression

__Syntax__

**menbreg** *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 random effects among the values of a factor variable

*levelvar***:** **R.***varname*

*levelvar* 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
__nocons__**tant** suppress constant term from the fixed-effects
equation
__exp__**osure(***varname_e***)** include ln(*varname_e*) in model with
coefficient constrained to 1
__off__**set(***varname_o***)** include *varname_o* in model with coefficient
constrained to 1
-------------------------------------------------------------------------

*re_options* Description
-------------------------------------------------------------------------
Model
__cov__**ariance(***vartype***)** variance-covariance structure of the random
effects
__nocons__**tant** suppress constant term from the random-effects
equation
__fw__**eight(***varname***)** frequency weights at higher levels
__iw__**eight(***varname***)** importance weights at higher levels
__pw__**eight(***varname***)** sampling weights at higher levels
-------------------------------------------------------------------------

*options* Description
-------------------------------------------------------------------------
Model
__d__**ispersion(***dispersion***)** parameterization of the conditional
overdispersion; *dispersion* may be **mean**
(default) or **constant**
__const__**raints(***constraints***)** apply specified linear constraints
__col__**linear** keep collinear variables

SE/Robust
**vce(***vcetype***)** *vcetype* may be **oim**, __r__**obust**, or __cl__**uster**
*clustvar*

Reporting
__l__**evel(***#***)** set confidence level; default is **level(95)**
**irr** report fixed-effects coefficients as
incidence-rate ratios
__nocnsr__**eport** do not display constraints
__notab__**le** suppress coefficient table
__nohead__**er** suppress output header
__nogr__**oup** suppress table summarizing groups
*display_options* control columns and column formats, row
spacing, line width, display of omitted
variables and base and empty cells, and
factor-variable labeling

Integration
__intm__**ethod(***intmethod***)** integration method
__intp__**oints(***#***)** set the number of integration (quadrature)
points for all levels; default is
**intpoints(7)**

Maximization
*maximize_options* control the maximization process; seldom used

__startv__**alues(***svmethod***)** method for obtaining starting values
__startg__**rid**[**(***gridspec***)**] perform a grid search to improve starting
values
__noest__**imate** do not fit the model; show starting values
instead
**dnumerical** use numerical derivative techniques
__coefl__**egend** display legend instead of statistics
-------------------------------------------------------------------------

*vartype* Description
-------------------------------------------------------------------------
__ind__**ependent** one unique variance parameter per random
effect, all covariances 0; the default
unless the **R.** notation is used
__exc__**hangeable** equal variances for random effects, and one
common pairwise covariance
__id__**entity** equal variances for random effects, all
covariances 0; the default if the **R.**
notation is used
__un__**structured** all variances and covariances to be distinctly
estimated
__fix__**ed(***matname***)** user-selected variances and covariances
constrained to specified values; the
remaining variances and covariances
unrestricted
__pat__**tern(***matname***)** user-selected variances and covariances
constrained to be equal; the remaining
variances and covariances unrestricted
-------------------------------------------------------------------------

*intmethod* Description
-------------------------------------------------------------------------
__mv__**aghermite** mean-variance adaptive Gauss-Hermite
quadrature; the default unless a crossed
random-effects model is fit
__mc__**aghermite** mode-curvature adaptive Gauss-Hermite
quadrature
__gh__**ermite** nonadaptive Gauss-Hermite quadrature
__lap__**lace** Laplacian approximation; the default for
crossed random-effects models
-------------------------------------------------------------------------

*indepvars* may contain factor variables; see fvvarlist.
*depvar*, *indepvars*, and *varlist* may contain time-series operators; see
tsvarlist.
**bayes**, **by**, and **svy** are allowed; see prefix. For more details, see
**[BAYES] bayes: menbreg**.
**vce()** and weights are not allowed with the **svy** prefix.
**fweight**s, **iweight**s, and **pweight**s are allowed; see weight. Only one type
of weight may be specified. Weights are not supported under the
Laplacian approximation or for crossed models.
**startvalues()**, **startgrid**, **noestimate**, **dnumerical**, and **coeflegend** do not
appear in the dialog box.
See **[ME] menbreg postestimation** for features available after estimation.

__Menu__

**Statistics > Multilevel mixed-effects models** **> Negative binomial**
**regression**

__Description__

**menbreg** fits mixed-effects negative binomial models to count data. The
conditional distribution of the response given the random effects is
assumed to follow a Poisson-like process, except that the variation is
greater than that of a true Poisson process.

__Options__

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

**noconstant** suppresses the constant (intercept) term and may be specified
for the fixed-effects equation and for any of or all the
random-effects equations.

**exposure(***varname_e***)** specifies a variable that reflects the amount of
exposure over which the *depvar* events were observed for each
observation; ln(*varname_e*) is included in the fixed-effects portion
of the model with coefficient constrained to be 1.

**offset(***varname_o***)** specifies that *varname_o* be included in the
fixed-effects portion of the model with the coefficient constrained
to be 1.

**covariance(***vartype***)** specifies the structure of the covariance matrix for
the random effects and may be specified for each random-effects
equation. *vartype* is one of the following: **independent**,
**exchangeable**, **identity**, **unstructured**, **fixed(***matname***)**, or
**pattern(***matname***)**.

**covariance(independent)** covariance structure allows for a distinct
variance for each random effect within a random-effects equation
and assumes that all covariances are 0. The default is
**covariance(independent)** unless a crossed random-effects model is
fit, in which case the default is **covariance(identity)**.

**covariance(exchangeable)** structure specifies one common variance for
all random effects and one common pairwise covariance.

**covariance(identity)** is short for "multiple of the identity"; that
is, all variances are equal and all covariances are 0.

**covariance(unstructured)** allows for all variances and covariances to
be distinct. If an equation consists of p random-effects terms,
the unstructured covariance matrix will have p(p+1)/2 unique
parameters.

**covariance(fixed(***matname***))** and **covariance(pattern(***matname***))**
covariance structures provide a convenient way to impose
constraints on variances and covariances of random effects. Each
specification requires a *matname* that defines the restrictions
placed on variances and covariances. Only elements in the lower
triangle of *matname* are used, and row and column names of *matname*
are ignored. A missing value in *matname* means that a given
element is unrestricted. In a **fixed(***matname***)** covariance
structure, (co)variance (i,j) is constrained to equal the value
specified in the i,jth entry of *matname*. In a **pattern(***matname***)**
covariance structure, (co)variances (i,j) and (k,l) are
constrained to be equal if *matname*[i,j] = *matname*[k,l].

**fweight(***varname***)** specifies frequency weights at higher levels in a
multilevel model, whereas frequency weights at the first level (the
observation level) are specified in the usual manner, for example,
**[fw=***fwtvar1***]**. *varname* can be any valid Stata variable name, and you
can specify **fweight()** at levels two and higher of a multilevel model.
For example, in the two-level model

**. me**... *fixed_portion* **[fw = wt1]** **|| school:** ... **, fweight(wt2)**
...

the variable **wt1** would hold the first-level (the observation-level)
frequency weights, and **wt2** would hold the second-level (the
school-level) frequency weights.

**iweight(***varname***)** specifies importance weights at higher levels in a
multilevel model, whereas importance weights at the first level (the
observation level) are specified in the usual manner, for example,
**[iw=***iwtvar1***]**. *varname* can be any valid Stata variable name, and you
can specify **iweight()** at levels two and higher of a multilevel model.
For example, in the two-level model

**. me**... *fixed_portion* **[iw = wt1]** **|| school:** ... **, iweight(wt2)**
...

the variable **wt1** would hold the first-level (the observation-level)
importance weights, and **wt2** would hold the second-level (the
school-level) importance weights.

**pweight(***varname***)** specifies sampling weights at higher levels in a
multilevel model, whereas sampling weights at the first level (the
observation level) are specified in the usual manner, for example,
**[pw=***pwtvar1***]**. *varname* can be any valid Stata variable name, and you
can specify **pweight()** at levels two and higher of a multilevel model.
For example, in the two-level model

**. me**... *fixed_portion* **[pw = wt1]** **|| school:** ... **, pweight(wt2)**
...

variable **wt1** would hold the first-level (the observation-level)
sampling weights, and **wt2** would hold the second-level (the
school-level) sampling weights.

**dispersion(mean**|**constant)** specifies the parameterization of the
conditional overdispersion given random effects. **dispersion(mean)**,
the default, yields a model where the conditional overdispersion is a
function of the conditional mean given random effects. For example,
in a two-level model, the conditional overdispersion is equal to 1 +
alpha*exp(xb). **dispersion(constant)** yields a model where the
conditional overdispersion is constant and is equal to 1 + delta.
alpha and delta are the respective conditional overdispersion
parameters.

**constraints(***constraints***)**, **collinear**; see **[R] estimation options**.

+-----------+
----+ SE/Robust +--------------------------------------------------------

**vce(***vcetype***)** specifies the type of standard error reported, which
includes types that are derived from asymptotic theory (**oim**), that
are robust to some kinds of misspecification (**robust**), and that allow
for intragroup correlation (**cluster** *clustvar*); see **[R] ***vce_option*.
If **vce(robust)** is specified, robust variances are clustered at the
highest level in the multilevel model.

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

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

**irr** reports estimated fixed-effects coefficients transformed to
incidence-rate ratios, that is, exp(b) rather than b. Standard
errors and confidence intervals are similarly transformed. This
option affects how results are displayed, not how they are estimated
or stored. **irr** may be specified either at estimation or upon replay.

**nocnsreport**; see **[R] estimation options**.

**notable** suppresses the estimation table, either at estimation or upon
replay.

**noheader** suppresses the output header, either at estimation or upon
replay.

**nogroup** suppresses the display of group summary information (number of
groups, average group size, minimum, and maximum) from the output
header.

*display_options*: **noci**, __nopv__**alues**, __noomit__**ted**, **vsquish**, __noempty__**cells**,
__base__**levels**, __allbase__**levels**, __nofvlab__**el**, **fvwrap(***#***)**, **fvwrapon(***style***)**,
**cformat(***%fmt***)**, **pformat(%***fmt***)**, **sformat(%***fmt***)**, and **nolstretch**; see **[R]**
**estimation options**.

+-------------+
----+ Integration +------------------------------------------------------

**intmethod(***intmethod***)** specifies the integration method to be used for the
random-effects model. **mvaghermite** performs mean-variance adaptive
Gauss-Hermite quadrature; **mcaghermite** performs mode-curvature
adaptive Gauss-Hermite quadrature; **ghermite** performs nonadaptive
Gauss-Hermite quadrature; and **laplace** performs the Laplacian
approximation, equivalent to mode-curvature adaptive Gaussian
quadrature with one integration point.

The default integration method is **mvaghermite** unless a crossed
random-effects model is fit, in which case the default integration
method is **laplace**. The Laplacian approximation has been known to
produce biased parameter estimates; however, the bias tends to be
more prominent in the estimates of the variance components rather
than in the estimates of the fixed effects.

For crossed random-effects models, estimation with more than one
quadrature point may be prohibitively intensive even for a small
number of levels. For this reason, the integration method defaults
to the Laplacian approximation. You may override this behavior by
specifying a different integration method.

**intpoints(***#***)** sets the number of integration points for quadrature. The
default is **intpoints(7)**, which means that seven quadrature points are
used for each level of random effects. This option is not allowed
with **intmethod(laplace)**.

The more integration points, the more accurate the approximation to
the log likelihood. However, computation time increases as a
function of the number of quadrature points raised to a power
equaling the dimension of the random-effects specification. In
crossed random-effects models and in models with many levels or many
random coefficients, this increase can be substantial.

+--------------+
----+ Maximization +-----------------------------------------------------

*maximize_options*: __dif__**ficult**, __tech__**nique(***algorithm_spec***)**, __iter__**ate(***#***)**,
[__no__]__lo__**g**, __tr__**ace**, __grad__**ient**, **showstep**, __hess__**ian**, __showtol__**erance**,
__tol__**erance(***#***)**, __ltol__**erance(***#***)**, __nrtol__**erance(***#***)**, __nonrtol__**erance**, and
**from(***init_specs***)**; see **[R] maximize**. Those that require special
mention for **menbreg** are listed below.

**from()** accepts a properly labeled vector of initial values or a list
of coefficient names with values. A list of values is not allowed.

The following options are available with **menbreg** but are not shown in the
dialog box:

**startvalues(***svmethod***)**, **startgrid**[**(***gridspec***)**], **noestimate**, and **dnumerical**;
see **[ME] meglm**.

**coeflegend**; see **[R] estimation options**.

__Remarks on using sampling weights__

Sampling weights are treated differently in multilevel models than they
are in standard models such as OLS regression. In a multilevel model,
observation-level weights are not indicative of overall inclusion.
Instead, they indicate inclusion conditional on the corresponding cluster
being included at the next highest-level of sampling.

For example, if you include only observation-level weights in a two-level
model, sampling with equal probabilities at level two is assumed, and
this may or may not be what you intended. If the sampling at level two
is weighted, then including only level-one weights can lead to biased
results even if weighting at level two has been incorporated into the
level-one weight variable. For example, it is a common practice to
multiply conditional weights from multiple levels into one overall
weight. By contrast, weighted multilevel analysis requires the component
weights from each level of sampling.

Even if you specify sampling weights at all model levels, the scale of
sampling weights at lower levels can affect your estimated parameters in
a multilevel model. That is, not only do the relative sizes of the
weights at lower levels matter, the scale of these weights matters also.

In general, exercise caution when using sampling weights; see *Survey data*
in *Remarks and examples* of **[ME] meglm** for more information.

__Examples__

Setup
**. webuse melanoma**

Three-level random-intercept model
**. menbreg deaths c.uv##c.uv, exposure(expected) || nation: || region:**

Same as above but with coefficients reported as incidence rates
**. menbreg, irr**

__Stored results__

**menbreg** stores the following in **e()**:

Scalars
**e(N)** number of observations
**e(k)** number of parameters
**e(k_dv)** number of dependent variables
**e(k_eq)** number of equations in **e(b)**
**e(k_eq_model)** number of equations in overall model test
**e(k_f)** number of fixed-effects parameters
**e(k_r)** number of random-effects parameters
**e(k_rs)** number of variances
**e(k_rc)** number of covariances
**e(df_m)** model degrees of freedom
**e(ll)** log likelihood
**e(N_clust)** number of clusters
**e(chi2)** chi-squared
**e(p)** p-value for model test
**e(ll_c)** log likelihood, comparison model
**e(chi2_c)** chi-squared, comparison test
**e(df_c)** degrees of freedom, comparison test
**e(p_c)** p-value for comparison test
**e(rank)** rank of **e(V)**
**e(ic)** number of iterations
**e(rc)** return code
**e(converged)** **1** if converged, **0** otherwise

Macros
**e(cmd)** **meglm**
**e(cmd2)** **menbreg**
**e(cmdline)** command as typed
**e(depvar)** name of dependent variable
**e(wtype)** weight type
**e(wexp)** weight expression (first-level weights)
**e(fweight***k***)** **fweight** variable for *k*th highest level, if
specified
**e(iweight***k***)** **iweight** variable for *k*th highest level, if
specified
**e(pweight***k***)** **pweight** variable for *k*th highest level, if
specified
**e(covariates)** list of covariates
**e(ivars)** grouping variables
**e(model)** **nbreg**
**e(title)** title in estimation output
**e(link)** **log**
**e(family)** **nbinomial**
**e(clustvar)** name of cluster variable
**e(dispersion)** **mean** or **constant**
**e(offset)** offset
**e(intmethod)** integration method
**e(n_quad)** number of integration points
**e(chi2type)** **Wald**; type of model chi-squared
**e(vce)** *vcetype* specified in **vce()**
**e(vcetype)** title used to label Std. Err.
**e(opt)** type of optimization
**e(which)** **max** or **min**; whether optimizer is to perform
maximization or minimization
**e(ml_method)** type of **ml** method
**e(user)** name of likelihood-evaluator program
**e(technique)** maximization technique
**e(datasignature)** the checksum
**e(datasignaturevars)** variables used in calculation of checksum
**e(properties)** **b V**
**e(estat_cmd)** program used to implement **estat**
**e(predict)** program used to implement **predict**
**e(marginsnotok)** predictions disallowed by **margins**
**e(marginswtype)** weight type for **margins**
**e(marginswexp)** weight expression for **margins**
**e(asbalanced)** factor variables **fvset** as **asbalanced**
**e(asobserved)** factor variables **fvset** as **asobserved**

Matrices
**e(b)** coefficient vector
**e(Cns)** constraints matrix
**e(ilog)** iteration log (up to 20 iterations)
**e(gradient)** gradient vector
**e(N_g)** group counts
**e(g_min)** group-size minimums
**e(g_avg)** group-size averages
**e(g_max)** group-size maximums
**e(V)** variance-covariance matrix of the estimators
**e(V_modelbased)** model-based variance

Functions
**e(sample)** marks estimation sample