**[R] asmixlogit** -- Alternative-specific mixed logit regression

__Syntax__

**asmixlogit** *depvar* [*indepvars*] [*if*] [*in*] [*weight*]**,** __c__**ase(***caseid***)**
[*options*]

*depvar* equal to 1 identifies the outcome or chosen alternative, whereas a
0 indicates the alternatives that were not chosen. Only one
alternative may be chosen for each case.

*indepvars* specifies the alternative-specific covariates that have fixed
coefficients.

*options* Description
-------------------------------------------------------------------------
Model
* __c__**ase(***caseid***)** use variable *caseid* to identify cases
* __alt__**ernatives(***altvar***)** use *altvar* to identify the alternatives
available for each case
__casev__**ars(***varlist***)** case-specific variables
__nocons__**tant** suppress the alternative-specific
constant terms
__r__**andom(***varlist*[**,** *distribution*]**)** specify variables that are to have
random coefficients and the
coefficients' distribution
__const__**raints(***constraints***)** apply specified linear constraints
__col__**linear** keep collinear variables

Model 2
__corr__**metric(***metric***)** correlation metric for correlated
random coefficients
__base__**alternative(***#*|*lbl*|*str***)** alternative used for normalizing
location
**altwise** use alternativewise deletion instead of
casewise deletion

SE/Robust
**vce(***vcetype***)** *vcetype* may be **oim**, __r__**obust**, __cl__**uster**
*clustvar*, **opg**, __boot__**strap**, or
__jack__**knife**

Reporting
__l__**evel(***#***)** set confidence level; default is
**level(95)**
__nocnsr__**eport** do not display constraints
*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(***seqspec***)** specify point set for Monte Carlo
integration
__intp__**oints(***#***)** specify number of points in each
sequence
__intb__**urn(***#***)** specify starting index in the
Hammersley or Halton sequence
__ints__**eed(***#***)** specify random-number seed for
pseudorandom sequence
**favor(speed**|**space)** favor speed or space when generating
integration points

Maximization
*maximize_options* control the maximization process;
seldom used

__coefl__**egend** display legend instead of statistics
-------------------------------------------------------------------------

*metric* Description
-------------------------------------------------------------------------
**correlation** standard deviation and correlation; the
default
**covariance** variance and covariance
**cholesky** Cholesky factor
-------------------------------------------------------------------------

*distribution* Description
-------------------------------------------------------------------------
__n__**ormal** Gaussian-distributed random
coefficients; the default
__corr__**elated** correlated Gaussian-distributed random
coefficients
__ln__**ormal** lognormal distributed random
coefficients
__tn__**ormal** truncated normal distributed random
coefficients
__u__**niform** uniform distributed random coefficients
__tr__**iangle** triangular distributed random
coefficients
-------------------------------------------------------------------------

*seqspec* is

*seqtype* [**,** **antithetics** | **mantithetics**]

*seqtype* Description
-------------------------------------------------------------------------
**hammersley** Hammersley point set; the default
**halton** Halton point set
**random** uniform pseudorandom point set
-------------------------------------------------------------------------

* **case(***casevar***)** is required. **alternatives(***altvar***)** is required to
estimate alternative-specific constants or if case-specific variables
are specified.
*indepvars* and *varlist* may contain factor variables; see fvvarlist.
**bootstrap**, **by**, **jackknife**, **statsby**, and **svy** are allowed; see prefix.
Weights are not allowed with the **bootstrap** prefix.
**vce()** and weights are not allowed with the **svy** prefix.
**fweight**s, **iweight**s, and **pweight**s are allowed; see weights.
**coeflegend** does not appear in the dialog box.
See **[R] asmixlogit postestimation** for features available after
estimation.

__Menu__

**Statistics > Categorical outcomes > Mixed logit model**

__Description__

**asmixlogit** fits an alternative-specific mixed logit model, also known as
a mixed multinomial logit model or random-parameter logit model, that
uses random coefficients to model the correlation of choices across
alternatives. The random coefficients are on variables that vary across
both cases and alternatives known as alternative-specific variables. The
correlation of choices across alternatives relaxes the independence of
irrelevant alternatives (IIA) property imposed by the conventional
multinomial logit model fit by **mlogit** and the alternative-specific
conditional logit model fit by **asclogit**.

__Options__

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

**case(***caseid***)** specifies the variable that identifies each case. This
variable identifies the individuals or entities making a choice.
**case()** is required.

**alternatives(***altvar***)** specifies the variable that identifies the
alternatives for each case. The number of alternatives can vary with
each case. **alternatives()** is required to estimate
alternative-specific constants or if case-specific variables are
specified in **casevars()**.

**casevars(***varlist***)** specifies the case-specific variables that are constant
for each **case()**. If there are a maximum of A alternatives, there
will be A-1 sets of coefficients associated with **casevars()**.

**noconstant** suppresses the A-1 alternative-specific constant terms.

**random(***varlist* [**,** *distribution*]**)** specifies the alternative-specific
variables that are to have random coefficients and optionally the
assumed distribution of the random coefficients. The default
distribution is **normal**, meaning Gaussian-distributed random
coefficients. *distribution* may also be **correlated**, **lnormal**, **tnormal**,
**uniform**, or **triangle**. **random()** may be specified more than once to
specify different sets of variables that correspond to different
coefficient distributions.

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

+---------+
----+ Model 2 +----------------------------------------------------------

**corrmetric(***metric***)** specifies the estimation metric for correlated random
coefficients. **corrmetric(correlation)**, the default, estimates the
standard deviations and correlations of the random coefficients.
**corrmetric(covariance)** estimates variances and covariances, and
**corrmetric(cholesky)** estimates Cholesky factors. **corrmetric()** is
allowed only when **random(***varlist***,** **correlated)** is specified.

**basealternative(***#*|*lbl*|*str***)** specifies the alternative used to normalize
the latent-variable location (also referred to as the level of
utility). The base alternative may be specified as a number, label,
or string. The default is the most frequent alternative. This
option is ignored if neither alternative-specific constants nor
case-specific variables are specified.

**altwise** specifies that alternativewise deletion be used when marking out
observations due to missing values in your variables. The default is
to use casewise deletion; that is, the entire group of observations
making up a case is deleted if any missing values are encountered.
This option does not apply to observations that are marked out by the
**if** or **in** qualifier or the **by** prefix.

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

**vce(***vcetype***)** specifies the type of standard error reported, which
includes types that are derived from asymptotic theory (**oim**, **opg**),
that are robust to some kinds of misspecification (**robust**), that
allow for intragroup correlation (**cluster** *clustvar*), and that use
bootstrap or jackknife methods (**bootstrap**, **jackknife**); see **[R]**
*vce_option*.

Specifying **vce(robust)** is equivalent to specifying **vce(cluster**
*caseid***)**.

If specifying **vce(bootstrap)** or **vce(jackknife)**, you must also specify
**basealternative()**.

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

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

*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(***seqtype* [**,** **antithetics** | **mantithetics**]**)** specifies the method of
generating the point sets used in the Monte Carlo integration.
**intmethod(hammersley)**, the default, uses the Hammersley sequence;
**intmethod(halton)** uses the Halton sequence; and **intmethod(random)**
uses a sequence of uniform random numbers.

**antithetics** and **mantithetics** specify that a unidimensional antithetic
sequence or a multidimensional antithetic sequence, respectively,
be generated instead of the standard implementation of the
requested *seqtype*. These methods improve the accuracy of the
Monte Carlo integration at the cost of additional computation
time; see *Methods and formulas*.

**intpoints(***#***)** specifies the number of raw points to use in the Monte Carlo
integration. The default number of points is a function of model
complexity and integration method. If **intmethod(hammersley)** or
**intmethod(halton)** is used and there are r uncorrelated random
coefficients in the model, the default is 50 x floor(sqrt{r}). If
there are also correlated random coefficients in the model and c is
the number of correlation parameters, another 50 x floor(sqrt{c})
points are added. If **intmethod(random)** is used, the number of points
is the above times 5. Larger values of **intpoints()** provide better
approximations of the log likelihood at the cost of additional
computation time.

**intburn(***#***)** specifies where in the Hammersley or Halton sequence to start,
which helps reduce the correlation between the sequences of each
dimension. The default is to discard the first n initial elements
from each sequence, where n is the largest prime used to generate the
sequences. This option may not be specified with **intmethod(random)**.

**intseed(***#***)** specifies the seed to use for generating uniform pseudorandom
sequences. This option may be specified only with **intmethod(random)**.
*#* must be an integer between 0 and 2^{31}-1. The default is to use
the current seed value from Stata's uniform random-number generator;
see **[R] set seed**.

**favor(speed**|**space)** instructs **asmixlogit** to favor either speed or space
when generating the integration points. **favor(speed)** is the default.
When favoring speed, the integration points are generated once and
stored in memory, thus increasing the speed of evaluating the
likelihood. This speed increase can be seen when there are many
cases or when the user specifies a large number of integration points
in **intpoints(***#***)**. When favoring space, the integration points are
generated repeatedly with each likelihood evaluation.

+--------------+
----+ 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**. These options are seldom used.

Setting the optimization type to **technique(bhhh)** resets the default
*vcetype* to **vce(opg)**.

The following option is available with **asmixlogit** but is not shown in the
dialog box:

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

__Examples__

Setup
**. webuse inschoice**

Mixed logit model with a fixed coefficient for **premium** and random
coefficients for **deductible**
**. asmixlogit choice premium, case(id) alternatives(insurance)**
**random(deductible)**

Mixed logit model with correlated random coefficients for **premium** and
**deductible**
**. asmixlogit choice, case(id) alternatives(insurance)**
**random(deductible premium, correlated)**

__Stored results__

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

Scalars
**e(N)** number of observations
**e(N_case)** number of cases
**e(k)** number of parameters
**e(k_alt)** number of alternatives
**e(k_casevars)** number of case-specific variables
**e(k_eq)** number of equations in **e(b)**
**e(k_eq_model)** number of equations in overall model test
**e(df_m)** model degrees of freedom
**e(ll)** log simulated-likelihood
**e(N_clust)** number of clusters
**e(const)** constant indicator
**e(intpoints)** number of raw integration points
**e(lsequence)** length of each integration sequence
**e(intburn)** starting sequence index
**e(chi2)** chi-squared
**e(p)** model test p-value
**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(alt_min)** minimum number of alternatives
**e(alt_avg)** average number of alternatives
**e(alt_max)** maximum number of alternatives
**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)** **asmixlogit**
**e(cmdline)** command as typed
**e(depvar)** name of dependent variable
**e(casevars)** case-specific variables
**e(case)** variable defining cases
**e(altvar)** variable defining alternatives
**e(alteqs)** alternative equation names
**e(alt***#***)** alternative labels
**e(base)** base alternative
**e(corrmetric)** correlation metric for correlated random
coefficients
**e(wtype)** weight type
**e(wexp)** weight expression
**e(title)** title in estimation output
**e(clustvar)** name of cluster variable
**e(chi2type)** type of 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(intmethod)** technique used to generate sequences
**e(sequence)** type of sequences
**e(mc_rngstate)** random-number state used
**e(user)** name of likelihood-evaluator program
**e(technique)** maximization technique
**e(properties)** **b V**
**e(predict)** program used to implement **predict**
**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(V)** variance-covariance matrix of the estimators
**e(V_modelbased)** model-based variance

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