*! version 1.0 27.05.2024

*! Lars Zeigermann

help mixlelast

Title

mixlelast -- Mixed logit sample elasticities and marginal
effects

Syntax

mixlelast
[if] [in]
,
alternatives(varname)[options]

options

Main
* alternatives(varname) use varname to identify alternatives

for(varname) compute elasticities/marginal effects for varname

marginaleffects compute marginal effects; default is elasticities

absolutechange(#) compute arc elasticities/marginal effects for an attribute change of #

percentchange(#) compute arc elasticities/marginal effects for an attribute change of # percent

dummy compute arc elasticities/marginal effects for a dummy change

weighted probability weighted sample elasticities/marginal effects; default is unweighted

nrep(#) set number of Halton draws to #

burn(#) drop # initial elements from Halton sequences

Reporting
nosd do not compute standard deviations

quietly suppress output

Heterogeneous Choice Sets
hettype(type) specifies aggregation type if choice sets are heterogeneous; type may be I, IIa or IIb. Default is I.

Krinsky-Robb Bootstrap
krobb(#) set number of repetitions for Krinksy-Robb bootstrap to #

krse(varname) compute standard errors; default is confidence intervals

krlevel(#) set confidence level; default is level(95)

krburn(#) drop # initial elements from Halton sequences for Krinsky-Robb bootstrap

kruserdraws use user-provided random numbers for Krinksy-Robb bootstrap

* alternatives(varname) is required.

Description

mixlelast is a post-estimation command for mixlogit (Hole 2007) that computes mixed logit samlpe elasticities and marginal
effects. It produces a matrix of dimension JxJ, where J is the number alternatives. Diagonal elements are direct effects, off-diagonal
elements are cross effects where each entry is the effect on the row alternative given an attribute change in the column alternative. Unless
the nosd option is specified, mixlelast reports standard deviations in addition to the average effects over all decision makers
in the sample.

mixlelast allows the user to compute elasticities/marginal effects for marginal attribute changes (point method), which is the
default, or for non-marginal changes (arc method). Non-marginal changes can be either be specified as a percentage or an absolute change. The
dummy option allows the user to obtain effects for dummy variables.

With heterogeneous choice sets, i.e. when alternatives are not identical across choice situations, the user can choose between different types of
aggregation, namely type I, IIa or IIb, see details below.

mixlelast further allows to obtain standard errors and confidence intervals computed by the Krinsky-Robb parametric bootstrap. For the Krinsky-Robb
parametric bootstrap, multiple vectors of coefficients are drawn from a multivariate normal distribution with mean and covariance as estimated
by mixlogit. For each draw, the JxJ matrix of elasticities/marginal effects is computed. The standards errors are then
the quare roots of the variances. Alternatively, confidence intervals on a user-specified confidence level can be obtained.

Options for mixlelast

Main

alternatives(varname) is required and specifies the variable identifying the alternatives.

for(varname) specifies the variable for which elasticities/marginal effects are calculated. The default is the first variable specifed in
mixlogit's rand() option. Elasticities/marginal effects can be computed for all fixed and random independent variables specified in
mixlogit.

marginaleffects allows the user to obtain marginal effects. The default is elasticities.

percentchange(#) allows the user to compute arc elasticities/marginal effects for an attribute change of # percent. This
option cannot be combined with absolutechange and dummy.

absolutechange(#) allows the user to compute arc elasticities/marginal effects for an absolute attribute change of #.
This option cannot be combined with [opt percentchange} and dummy.

dummy allows the user to compute arc elasticities/marginal effects for dummy variables.
This option cannot be combined with percentchange and absolutechange.

weighted specifies that probability weighted sample averages are calculated. The default is unweighted sample averages.

nrep(#) set number of Halton draws to #. The default is the number of draws specified in mixlogit, which has a default of 50 draws}.

burn(#) specifies the number of initials elements dropped then creating the Halton sequences. The default is burn(15).

Reporting

quietly suppresses the output. This might be useful if the number of alternatives and hence the output table is large. All results are
stored in r().

nosd prevents mixlelast from computing standard deviations. For large data sets with many alternatives, this saves significantly on
memory.

Heterogeneous Choice Sets

hettype(type) specifies the type of aggregation when choice sets are heterogeneous. Type may be I, IIa or IIb. The default is I.

type I: average over all decision makers in the sample, even if they do not have the respective alternative/s in their choice set.
(Note: individual effects are set to zero if the alternative/s were not present in the individual choice set)

type IIa: for direct effects, average over all individuals who have the respective alternative in their choice set. For cross effects
average over who have the row alternative in their choice set (not matter if the column alternative is in the decision maker's choice set
or not)

type IIb: for direct effects, see type IIa. For cross effects, consider only those decision makers who have both the row and the column
alternative in their choice set.

Krinsky-Robb Parametric Bootstrap

krobb(real) specifies the number of repetitions used in Krinsky-Robb parametric bootstrap to obtain standard errors or
confidence intervalls.

krse specifies that standard errors are displayed. The default is confidence intervals.

krlevel(#) set confidence level for Krinsky-Robb bootstrap. The default is level(95).

krburn(#) sets the number of initial values from the sequence dropped to #. The default is krburn(15).

kruserdraws allows the user to provide (pseudo-)random numbers in a Mata matric (mixl_KRUSERDRAWS). The matrix must have the number of
rows equal to the number coefficients in the model and the number of columns equal to the number of choice occasions times the number of
repititions. If kruserdraws is not specified, the default is Halton draws for up to 10 coefficients and random draws otherwise.

Examples

Load data with homogeneous choice sets

`"use choice_hom.dta, clear"'

Fit mixed logit model

`"mixlogit y brand quality, rand(price) group(gid) id(pid) "'

Obtain elasticities for a marginal change in price

`"mixlelast, alternatives(alt)"'

Compute probability-weighted elasticities without standard deviations

`"mixlelast, alternatives(alt) weighted nosd"'

Compute elasticities for an increase in quality of 1

`"mixlelast, alternatives(alt) for(quality) absolutechange(1)"'

Obtain marginal effects

`"mixlelast, altid(alt) marginal"'

Use Krinsky-Robb parametric bootstrap to get 90 percent confidence intervals with 500 repetitions

`"mixlelast, altid(alt) krobb(500) level(90)"'

Load data with heterogeneous choice set

`"use choice_het.ado, clear"'

Compute elasticities of type I (default)

`"mixlelast, altid(alt)"'

Obtain elasticities of type IIa

`"mixlelast, altid(alt) hettype(IIa)"'

Stored results

mixlelast saves the following results to r():

Scalars

r(N) number of observations

r(N_group) number of choice occasions

r(N_id) number of decision makers

r(N_alt) number of alternatives

r(het) 1 if heterogeneous choice sets, 0 otherwise

r(absolutechange) absolute change in attribute

r(percentchange) percentage change in attribute

r(marginal) 1 if marginal effects, 0 if elasticities

r(weighted) 1 if probability weighted, 0 otherwise

r(nosd) 1 if standard deviations suppressed, 0
otherwise

r(nrep) number of repetitions

r(burn) number of initial to drop when creating Halton
sequence

Macros

r(cmd) mixlelast

r(group) name of group() variable

r(id) name of id() variable

r(alternatives) name of variable identifying
alternatives

r(for) name of variable for which effects are computed

r(method) calculation method

r(change) type of change in for() variable

r(hettype) type of aggregation for heterogeneous choice
sets

r(title) title of output table

r(subtitle) subtitle of output table

r(krsubtitle) subtitle if Krinsky-Robb bootstrap

Matrices

r(mean) matrix of mean elasticities/marginal effects

r(sd) matrix of standard deviations

r(krse) matrix of standard errors if Krinsky-Robb
bootstrap

r(CI_upper) matrix of lower bounds of confidence
intervals if Krinsky-Robb bootstrap

r(CI_lower) matrix of upper bounds of confidence
intervals if Krinsky-Robb bootstrap

References

Hole, A. R. 2007.
Fitting Mixed
Logit Models by Using Maximum Simulated Likelihood.
Stata Journal 7: 388-401.

Krinsky I., and A. Robb. 1986. On Approximating the Statistical
Properties of Elasticities. Review of Economics and Statistics. 68(4):715-9.

Krinsky I., and A. Robb. 1990. On Approximating the Statistical
Properties of Elasticities: A Correction. Review of Economics and
Statistics. 72(1):189-90.

Revelt, D., and K. Train. 2000. Customer-specific Taste Parameters and Mixed
Logit: Households' Choice of Electricity Supplier. Working Paper, Department
of Economics, University of California, Berkeley.

Train, K. E. 2009. Discrete Choice Methods with Simulation.
Cambridge: Cambridge University Press.

Author

Lars Zeigermann, lars.zeigermann@posteo.de.

Acknowledgements

I would like to thank Anna Lu and Arne Risa Hole for very helpful
comments and suggestions. mixlelast builds on mixlpred (Hole
2007). All remaining errors are my own.