Stata 15 help for mecloglog

```
[ME] mecloglog -- Multilevel mixed-effects complementary log-log regression

Syntax

mecloglog 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
noconstant               suppress constant term from the fixed-effects
equation
offset(varname)          include varname in model with coefficient
constrained to 1
asis                     retain perfect predictor variables
-------------------------------------------------------------------------

re_options                 Description
-------------------------------------------------------------------------
Model
covariance(vartype)      variance-covariance structure of the random
effects
noconstant               suppress constant term from the random-effects
equation
fweight(varname)         frequency weights at higher levels
iweight(varname)         importance weights at higher levels
pweight(varname)         sampling weights at higher levels
-------------------------------------------------------------------------

options                    Description
-------------------------------------------------------------------------
Model
binomial(varname|#)      set binomial trials if data are in binomial
form
constraints(constraints) apply specified linear constraints
collinear                keep collinear variables

SE/Robust
vce(vcetype)             vcetype may be oim, robust, or cluster
clustvar

Reporting
level(#)                 set confidence level; default is level(95)
eform                    report exponentiated coefficients
nocnsreport              do not display constraints
notable                  suppress coefficient table
nogroup                  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
intmethod(intmethod)     integration method
intpoints(#)             set the number of integration (quadrature)
points for all levels; default is
intpoints(7)

Maximization
maximize_options         control the maximization process; seldom used

startvalues(svmethod)    method for obtaining starting values
startgrid[(gridspec)]    perform a grid search to improve starting
values
noestimate               do not fit the model; show starting values
dnumerical               use numerical derivative techniques
coeflegend               display legend instead of statistics
-------------------------------------------------------------------------

vartype                    Description
-------------------------------------------------------------------------
independent                one unique variance parameter per random
effect, all covariances 0; the default
unless the R. notation is used
exchangeable               equal variances for random effects, and one
common pairwise covariance
identity                   equal variances for random effects, all
covariances 0; the default if the R.
notation is used
unstructured               all variances and covariances to be distinctly
estimated
fixed(matname)             user-selected variances and covariances
constrained to specified values; the
remaining variances and covariances
unrestricted
pattern(matname)           user-selected variances and covariances
constrained to be equal; the remaining
variances and covariances unrestricted
-------------------------------------------------------------------------

intmethod                  Description
-------------------------------------------------------------------------
quadrature; the default unless a crossed
random-effects model is fit
laplace                    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: mecloglog.
vce() and weights are not allowed with the svy prefix.
fweights, iweights, and pweights 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] mecloglog postestimation for features available after
estimation.

Statistics > Multilevel mixed-effects models > Complementary log-log
regression

Description

mecloglog fits mixed-effects models for binary or binomial responses.
The conditional distribution of the response given the random effects is
assumed to be Bernoulli, with probability of success determined by the
inverse complementary log-log function.

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.

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

asis forces retention of perfect predictor variables and their
associated, perfectly predicted observations and may produce
instabilities in maximization; see [R] probit.

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.

binomial(varname|#) specifies that the data are in binomial form; that
is, depvar records the number of successes from a series of binomial
trials.  This number of trials is given either as varname, which
allows this number to vary over the observations, or as the constant
#.  If binomial() is not specified (the default), depvar is treated
as Bernoulli, with any nonzero, nonmissing values indicating positive
responses.

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.

eform reports exponentiated coefficients and corresponding standard
errors and confidence intervals.  This option 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.

replay.

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

display_options:  noci, nopvalues, noomitted, vsquish, noemptycells,
baselevels, allbaselevels, nofvlabel, 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; and laplace performs the Laplacian
approximation, equivalent to mode-curvature adaptive Gaussian

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:  difficult, technique(algorithm_spec), iterate(#),
[no]log, trace, gradient, showstep, hessian, showtolerance,
tolerance(#), ltolerance(#), nrtolerance(#), nonrtolerance, and
from(init_specs); see [R] maximize.  Those that require special
mention for mecloglog 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 mecloglog 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

Examples

---------------------------------------------------------------------------
Setup

Two-level random-intercept model, analogous to xtcloglog
. mecloglog c_use urban age child* || district:

Two-level random-intercept and random-coefficient model
. mecloglog c_use urban age child* || district: urban

Two-level random-intercept and random-coefficient model, correlated
random effects
. mecloglog c_use urban age child* || district: urban, cov(unstruct)

---------------------------------------------------------------------------
Setup
. webuse towerlondon

Three-level nested model, subject nested within family
. mecloglog dtlm difficulty i.group || family: || subject:

---------------------------------------------------------------------------
Setup
. webuse fifeschool
. gen byte attain_gt_6 = attain > 6

Two-way crossed random effects
. mecloglog attain_gt_6 sex || _all:R.sid || pid:
---------------------------------------------------------------------------

Stored results

mecloglog 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)                 mecloglog
e(cmdline)              command as typed
e(depvar)               name of dependent variable
e(wtype)                weight type
e(wexp)                 weight expression (first-level weights)
e(fweightk)             fweight variable for kth highest level, if
specified
e(iweightk)             iweight variable for kth highest level, if
specified
e(pweightk)             pweight variable for kth highest level, if
specified
e(covariates)           list of covariates
e(ivars)                grouping variables
e(model)                cloglog
e(title)                title in estimation output
e(family)               bernoulli or binomial
e(clustvar)             name of cluster variable
e(offset)               offset
e(binomial)             binomial number of trials
e(intmethod)            integration method
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(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

```