help bayesmixedlogitwtp (SJ14-3: st0001)

Title

bayesmixedlogitwtp -- Bayesian mixed logit model in WTP space

Syntax

bayesmixedlogitwtp
depvar
[indepvars] [if] [in],
group(varname)
identifier(varname)
price(varname)
rand(varlist)
[draws(#)
drawsrandom(#)
drawsfixed(#)
burn(#)
thin(#)
araterandom(#)
aratefixed(#)
samplerrandom(string)
samplerfixed(string)
dampparmfixed(#)
dampparmrandom(#)
from(rowvector)
fromvariance(matrix)
jumble
noisy
saving(filename)
replace
append
indsave(string)
indkeep(#)
indwide
replaceind
appendind]

Description

bayesmixedlogitwtp can be used to fit mixed logit models using Bayesian
methods in willingness-to-pay (WTP) space.
bayesmixedlogitwtp functions in the same way as bayesmixedlogit; the command
produces draws from the
posterior parameter distribution and then presents summary and other
statistics describing the results of the drawing. Detailed analysis of
the draws is left to the discretion of the user.

Implementation of bayesmixedlogitwtp is essentially the same as bayesmixedlogit,
(if not
installed, search online)
following the methods described in Train (2009, chap. 12),
and mechanics described in Baker (2014). A
diffuse prior for the mean values of the random coefficients is assumed,
and the prior distribution on the covariance matrix of random
coefficients is taken to be an identity inverse Wishart. bayesmixedlogitwtp
uses the Mata routines amcmc() (if not
installed, search online) for adaptive Markov chain
Monte Carlo sampling from the posterior distribution of individual level
coefficients and fixed coefficients. The data setup for
bayesmixedlogitwtp is the same as for clogit. Much of the syntax
follows that used by Hole (2007) in development of the command
mixlogit and mixlogitwtp.

The defining characteristic of the WTP-space mixed logit model
is normalization of coefficients using the
(random) coefficient on a designated price variable, as described in Train and Weeks (2005), Scarpa, Thiene, and
Train (2008), and Hole and Kolstad (2012).

The model assumes that the coefficient on the price variable follows (the negative of) a log-normal distribution.
Hence, if the estimated parameter is b, the price variable has coefficient -exp(b). The transformed coefficient
is saved and displayed as part of the output, but as presented the saved and display value is the negative of the exponentiated
average value of b, not the average of the value -exp(b).

Options

group(varname) specifies a numeric identifier variable
for choice occasions. group() is required.

identifier(varname) identifies coefficient sets
(those observations for which a set of coefficients apply). Thus,
when a person is observed making choices over multiple
occasions, one would use group(varname) to specify the choice
occasions, while identifier(varname) would identify the person.
identifier() is required.

rand(varlist) specifies independent variables
with random coefficients. The variables immediately following the
dependent variable in the syntax are considered to have fixed
coefficients (see the examples below). While a model can be run without
any independent variables with fixed coefficients, at least one
random-coefficient independent variable is required for
bayesmixedlogitwtp to work. rand() is required. In the event that one wishes to estimate
a mixed logit model with just a price variable, no normalization is required so bayesmixedlogit should suffice.

{ opt price(varname)} designates the price variable and is required.

Subsequent options exactly mirror the options of bayesmixedlogit and provide
control over how drawing from the posterior occurs.

draws(#) specifies the number of draws that are to be taken from the posterior
distribution of the parameters. The default is draws(1000).

drawsrandom(#) is an advanced option. The drawing algorithm
treats each set of random coefficients as a Gibbs step in sampling from
the joint posterior distribution of parameters. In difficult,
large-dimensional problems, it might be desirable to let individual Gibbs
steps run for more than one draw to achieve better mixing and
convergence of the algorithm.

drawsfixed(#) is a more advanced option. The drawing algorithm treats
fixed coefficients as a Gibbs step in sampling from the joint posterior
distribution of parameters. In difficult, large-dimensional problems, it
might be desirable to let this step in Gibbs sampling run for more than a
single draw. The default is drawsfixed(1).

burn(#) specifies the length of the burn-in period; the first
# draws are discarded upon completion of the algorithm and before
further results are computed.

thin(#) specifies that only every #th draw is to be retained, so
if thin(3) is specified, only every third draw is retained. This
option is designed to help ease autocorrelation in the resulting draws,
as is the option jumble, which randomly mixes draws. Both options
may be applied.

araterandom(#) specifies the desired acceptance rate for random
coefficients and should be a number between zero and one. Because an
adaptive acceptance-rejection method is used to sample random
coefficients, by specifying the desired acceptance rate, the user has
some control over adaptation of the algorithm to the problem. The
default is araterandom(.234).

aratefixed(#) specifies the desired acceptance rate for fixed
coefficients and works in the same fashion as araterandom(#).

samplerrandom(string) specifies the type of sampler that is to be
used when random parameters are drawn. It may be set to either
global or mwg. The default is samplerrandom(global),
which means that proposed changes to random parameters are drawn all at
once. If mwg -- an acronym for "Metropolis within Gibbs" -- is
instead chosen, each random parameter is drawn separately as an
independent step conditional on other random parameters in a nested
Gibbs step. The default is samplerrandom(global), but mwg
might be useful in situations in which initial values are poorly scaled.
The workings of these options are described in greater detail in Baker
(2014).

samplerfixed(string) specifies the type of sampler that is used
when fixed parameters are drawn. Options are exactly as those described
under samplerrandom(string).

dampparmfixed(#) works exactly as option dampparmrandom(#)
but is applied to drawing fixed parameters.

dampparmrandom(#) is a parameter that controls how aggressively
the proposal distributions for random parameters are adapted as drawing
continues. If the parameter is set close to one, adaptation is
aggressive in its early phase of trying to achieve the acceptance rate
specified in araterandom(#). If the parameter is set closer to
zero, adaptation is more gradual.

from(rowvector) specifies a row vector of starting values for all
parameters in order. If these are not specified, starting
values are obtained via estimation of a conditional logit model via
clogit.

fromvariance(matrix) specifies a matrix of starting values for the
random parameters.

jumble specifies to randomly mix draws.

noisy specifies that a dot be produced every time a complete pass
through the algorithm is finished. After 50 iterations, a function
value ln_fc(p) will be produced, which gives the joint log of the
value of the posterior choice probabilities evaluated at the latest
parameters. While ln_fc(p) is not an objective function per se, the author has found
that drift in the value of this function indicates that the algorithm
has not yet converged or has other problems.

saving(filename) specifies a location to store the draws from the
distribution. The file will contain just the draws after any burn-in
period or thinning of values is applied.

replace specifies that an
existing file is to be overwritten.

append specifies that an existing file is to be appended, which
might be useful if multiple runs need to be combined.

indsave(filename) specifies a file to which individual-level random
parameters are to be saved. More precisely, indsave(filename) saves
the draws of the individual-level parameters. Caution: For long runs and models
with large numbers of individuals, specifying this option can cause memory problems. Users
should be careful how it is used and consult some of the examples before employing the
option.

indkeep(#) is for use with indsave and specifies that only the last # draws of
the individual-level random parameters be kept. This helps avoid excessive memory consumption.

indwide is for use with indsave and affords the user a degree of control over how
individual-level parameters are saved. By default, individual-level parameters are saved in a panel form,
meaning that each random parameter draw is saved in a row, where draws are marked by the group identifier.
If instead the user would prefer that each row contain draws of each parameter, one could specify the indwide
option, which saves all draws in a single row, with the first entry of the row being the group identifier.
By analogy with reshape, by default draws are saved in "long" format, whereas indwide stores the draws
in "wide" format.

replaceind functions in the same way as replace, but in reference to
the file specified in indsave.

appendind functions in the same way as append, but in reference to the
file specified in indsave.

Examples

The following example mirrors examples provided of usage of the mixlogitwtp command (with thanks to Arne Rise Hole for
allowing use of the example):

. use http://fmwww.bc.edu/repec/bocode/t/traindata.dta

. bayesmixedlogitwtp y contract local wknown, group(gid) id(pid) price(price) rand(seasonal tod) draws(4000) burn(1000) thin(5) arater(.4) saving(draws) replace noisy

A case in which all coefficients are random:

. bayesmixedlogitwtp y, group(gid) id(pid) price(price) rand(seasonal tod wknown) draws(2000) burn(1000) thin(5) arater(.4) saving(draws) replace

Stored results

bayesmixedlogitwtp stores the following in e():

Scalars

e(N) number of observations

e(df_r) degrees of freedom for summarizing draws (equal to number of retained draws)

e(krnd) number of random parameters

e(kfix) number of fixed parameters

e(draws) number of draws

e(burn) burn-in observations

e(thin) thinning parameter

e(random_draws) number of draws of each set of random parameters per pass

e(fixed_draws) number of draws of fixed parameters per pass

e(damper_fixed) damping parameter -- fixed parameters

e(price_coef) -exponent of mean of estimated coefficient on price variable

e(damper_random) damping parameter -- random parameters

e(opt_arate_fixed) desired acceptance rate -- fixed parameters

e(opt_arate_random) desired acceptance rate -- random parameters

e(N_groups) number of groups

e(N_choices) number of choice occasions

e(arates_fa) acceptance rate -- fixed parameters

e(arates_ra) average acceptance rate -- random parameters

e(arates_rmax) maximum acceptance rate -- random parameters

e(arates_rmin) minimum acceptance rate -- random parameters

e(inddraws) draws of individual parameters kept

Macros

e(cmd) bayesmixedlogitwtp

e(depvar) name of dependent variable

e(pricevar) name of price variable

e(indepvars) independent variables

e(title) title in estimation output

e(properties) b V

e(saving) file containing results

e(fixed_sampler) sampler type for fixed parameters

e(random_sampler) sampler type for random parameters

e(random) random parameter names

e(fixed) fixed parameter names

e(identifier) identifier for individuals

e(group) identifier for choice occasions

e(indsave) file holding individual-level parameter draws

Matrices

e(b) mean parameter values

e(V) variance-covariance matrix of parameters

e(V_init) initial variance-covariance matrix of random parameters

e(b_init) initial mean vector of random parameters

e(arates_fixed) row vector of acceptance rates of fixed parameters

e(arates_rand) vector or matrix of acceptance rates of random parameters

Functions

e(sample) marks estimation sample

Comments

The basic algorithms used in drawing are described in detail in
Baker (2014). The user might gain a fuller understanding of the options
aratefixed(), araterandom(), dampparmfixed(),
dampparmrandom(), and other options controlling adaptation of the
proposal distribution from a reading of this document.

bayesmixedlogitwtp requires that the package of Mata functions
amcmc() be installed and also requires installation of Ben Jann's
moremata set of extended Mata functions.

Caution -- While summary statistics of the results of a
drawing are presented in the usual Stata format, bayesmixedlogitwtp
provides no guidance as to how one should actually select
the number of draws, how one should process the draws, how one should monitor
convergence of the algorithm, or how one should present and interpret results.
One would do well to consult Train (2009) and a good source on Bayesian
methods, such as Gelman et al. (2009). Fortunately, Stata provides many
tools for summarizing and plotting the results of a drawing.

References

Baker, M. J. 2014. Adaptive Markov chain Monte Carlo sampling and estimation in Mata. Stata Journal 14: 623-61.

Gelman, A., J. B. Carlin, H. S. Stern, and D. B. Rubin. 2009. Bayesian data analysis. 2nd. ed. Boca Raton, FL: Chapman & Hall/CRC.

Hole, A. R. 2007. Fitting mixed logit models by using maximum simulated likelihood. Stata Journal 7: 388-401.

Hole, A. R. and J. R. Kolstad. 2012. Mixed logit estimation of willingness to pay distributions:
a comparison of models in preference and WTP space using data
from a health-related choice experiment. Empirical Economics 42: 445-469.

Long, J. S., and J. Freese. 2006. Regression Models for Categorical Dependent Variables Using Stata. 2nd ed. College Station, TX: Stata Press.

R. Scarpa, M. Thiene, and K. Train. 2008. Utility in willingness to pay space: A tool to
address confounding random scale effects in destination choice to the Alps.
American Journal of Agricultural Economics 90: 994-1010.

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

Train, K. E. and M. Weeks. 2005. Discrete choice models in preference space and
willingness-to-pay space. In: Scarpa R, Alberini A (eds) Application of
simulation methods in environmental and resource economics. Springer,
Dordrecht, pp 1-16.

Author

Matthew J. Baker

Hunter College and the Graduate Center, CUNY

New York, NY

matthew.baker@hunter.cuny.edu

Acknowledgements

Thanks to Kenneth Train for suggesting this command, and thanks to Arne Rise Hole for permission to use
examples.

Comments, criticisms, and suggestions for improvement are welcome.

Also see

Article: Stata Journal, volume 14, number 2: st0354

Manual: [R] clogit

Help: amcmc(), bayesmixedlogit, mixlogit, mixlogitwtp, moremata (if installed)