**[ME] meqrlogit postestimation** -- Postestimation tools for meqrlogit

__Postestimation commands__

The following postestimation commands are of special interest after
**meqrlogit**:

Command Description
-------------------------------------------------------------------------
**estat group** summarize the composition of the nested groups
**estat icc** estimate intraclass correlations
**estat recovariance** display the estimated random-effects covariance
matrices
**estat sd** display variance components as standard deviations
and correlations
-------------------------------------------------------------------------

The following standard postestimation commands are also available:

Command Description
-------------------------------------------------------------------------
**contrast** contrasts and ANOVA-style joint tests of estimates
**estat ic** Akaike's and Schwarz's Bayesian information criteria
(AIC and BIC)
**estat summarize** summary statistics for the estimation sample
**estat vce** variance-covariance matrix of the estimators (VCE)
**estimates** cataloging estimation results
**hausman** Hausman's specification test
**lincom** point estimates, standard errors, testing, and
inference for linear combinations of coefficients
**lrtest** likelihood-ratio test
**margins** marginal means, predictive margins, marginal effects,
and average marginal effects
**marginsplot** graph the results from margins (profile plots,
interaction plots, etc.)
**nlcom** point estimates, standard errors, testing, and
inference for nonlinear combinations of
coefficients
**predict** predictions, residuals, influence statistics, and
other diagnostic measures
**predictnl** point estimates, standard errors, testing, and
inference for generalized predictions
**pwcompare** pairwise comparisons of estimates
**test** Wald tests of simple and composite linear hypotheses
**testnl** Wald tests of nonlinear hypotheses
-------------------------------------------------------------------------

__Syntax for predict__

Syntax for obtaining estimated random effects and their standard errors

**predict** [*type*] *newvarsspec* [*if*] [*in*] **,** __ref__**fects** [**reses(***newvarsspec***)**
__relev__**el(***levelvar***)**]

Syntax for obtaining other predictions

**predict** [*type*] *newvar* [*if*] [*in*] [**,** *statistic* __nooff__**set** __fixed__**only**]

*newvarsspec* is *stub****** or *newvarlist*.

*statistic* Description
-------------------------------------------------------------------------
Main
**mu** mean response; the default
**xb** linear predictor for the fixed portion of the model only
**stdp** standard error of the fixed-portion linear prediction
__pea__**rson** Pearson residuals
__dev__**iance** deviance residuals
__ans__**combe** Anscombe residuals
-------------------------------------------------------------------------
These statistics are available both in and out of sample; type **predict**
*...* **if e(sample)** *...* if wanted only for the estimation sample.

__Menu for predict__

**Statistics > Postestimation**

__Description for predict__

**predict** creates a new variable containing predictions such as mean
responses; linear predictions; standard errors; and Pearson, deviance,
and Anscombe residuals.

__Options for predict__

+------+
----+ Main +-------------------------------------------------------------

**reffects** calculates posterior modal estimates of the random effects. By
default, estimates for all random effects in the model are
calculated. However, if the **relevel(***levelvar***)** option is specified,
then estimates for only level *levelvar* in the model are calculated.
For example, if **class**es are nested within **school**s, then typing

**. predict b*, reffects relevel(school)**

would yield random-effects estimates at the school level. You must
specify *q* new variables, where *q* is the number of random-effects
terms in the model (or level). However, it is much easier to just
specify *stub****** and let Stata name the variables *stub***1**, *stub***2**, ...,
*stubq* for you.

**reses(***newvarsspec***)** calculates standard errors for the random-effects
estimates. By default, standard errors for all random effects in the
model are calculated. However, if the **relevel(***levelvar***)** option is
specified, then standard errors for only level *levelvar* in the model
are calculated; see the **reffects** option.

You must specify *q* new variables, where *q* is the number of
random-effects terms in the model (or level). However, it is much
easier to just specify *stub****** and let Stata name the variables *stub***1**,
*stub***2**, ..., *stubq* for you. The new variables will have the same
storage type as the corresponding random-effects variables.

The **reffects** and **reses()** options often generate multiple new
variables at once. When this occurs, the random effects (or standard
errors) contained in the generated variables correspond to the order
in which the variance components are listed in the output of
**meqrlogit**. Still, examining the variable labels of the generated
variables (with the **describe** command, for instance) can be useful in
deciphering which variables correspond to which terms in the model.

**relevel(***levelvar***)** specifies the level in the model at which predictions
for random effects and their standard errors are to be obtained.
*levelvar* is the name of the model level and is either the name of the
variable describing the grouping at that level or is **_all**, a special
designation for a group comprising all the estimation data.

**mu**, the default, calculates the predicted mean. By default, this is
based on a linear predictor that includes both the fixed effects and
the random effects, and the predicted mean is conditional on the
values of the random effects. Use the **fixedonly** option (see below)
if you want predictions that include only the fixed portion of the
model, that is, if you want random effects set to 0.

**xb** calculates the linear prediction based on the estimated fixed effects
(coefficients) in the model. This is equivalent to fixing all random
effects in the model to their theoretical (prior) mean value of 0.

**stdp** calculates the standard error of the fixed-effects linear predictor.

**pearson** calculates Pearson residuals. Pearson residuals large in
absolute value may indicate a lack of fit. By default, residuals
include both the fixed portion and the random portion of the model.
The **fixedonly** option modifies the calculation to include the fixed
portion only.

**deviance** calculates deviance residuals. Deviance residuals are
recommended by McCullagh and Nelder (1989) as having the best
properties for examining the goodness of fit of a GLM. They are
approximately normally distributed if the model is correctly
specified. They may be plotted against the fitted values or against
a covariate to inspect the model's fit. By default, residuals
include both the fixed portion and the random portion of the model.
The **fixedonly** option modifies the calculation to include the fixed
portion only.

**anscombe** calculates Anscombe residuals, which are designed to closely
follow a normal distribution. By default, residuals include both the
fixed portion and the random portion of the model. The **fixedonly**
option modifies the calculation to include the fixed portion only.

**nooffset** is relevant only if you specified **offset(***varname***)** with
**meqrlogit**. It modifies the calculations made by **predict** so that they
ignore the offset variable; the linear prediction is treated as xb
rather than xb + offset.

**fixedonly** modifies predictions to include only the fixed portion of the
model, equivalent to setting all random effects equal to 0; see the
**mu** option.

__Syntax for margins__

**margins** [*marginlist*] [**,** *options*]

**margins** [*marginlist*] **,** __pr__**edict(***statistic *...**)** [*options*]

*statistic* Description
-------------------------------------------------------------------------
**xb** linear predictor for the fixed portion of the model
only; the default
__ref__**fects** not allowed with **margins**
**reses** not allowed with **margins**
**mu** not allowed with **margins**
**stdp** not allowed with **margins**
__pea__**rson** not allowed with **margins**
__dev__**iance** not allowed with **margins**
__ans__**combe** not allowed with **margins**
-------------------------------------------------------------------------

Statistics not allowed with **margins** are functions of stochastic
quantities other than **e(b)**.

For the full syntax, see **[R] margins**.

__Menu for margins__

**Statistics > Postestimation**

__Description for margins__

**margins** estimates margins of response for linear predictions.

__Examples__

---------------------------------------------------------------------------
Setup
**. webuse bangladesh**
**. meqrlogit c_use urban age child* || district: urban,**
**covariance(unstructured)**

Random-effects covariance matrix for level **district**
**. estat recovariance**

Random-effects correlation matrix for level **district**
**. estat recovariance, correlation**

Predictions of random effects
**. predict re_urban re_cons, reffects**

Compute conditional intraclass correlation
**. estat icc**

---------------------------------------------------------------------------
Setup
**. webuse towerlondon, clear**
**. meqrlogit dtlm difficulty i.group || family: || subject:**

Summarize composition of nested groups
**. estat group**

Predicted probabilities, incorporating random effects
**. predict p**

Predicted probabilities, ignoring subject and family effects
**. predict p_fixed, fixedonly**

Compute residual intraclass correlations
**. estat icc**

---------------------------------------------------------------------------

__Reference__

McCullagh, P., and J. A. Nelder. 1989. *Generalized Linear Models*. 2nd
ed. London: Chapman & Hall/CRC.