help lclogit2

Title

lclogit2 -- Enhanced module to estimate latent class logit models via EM algorithm

Syntax

lclogit2
depvar
[varlist1] [if] [in],
group(varname)
rand(varlist2)
nclasses(#)
[,	id(varname)
membership(varlist3)
constraints(numlist)
seed(#)
iterate(#)
ltolerance(#)
tolerance(#)
tolcheck
nolog]

lclogitml2
depvar
[varlist1] [if] [in],
group(varname)
rand(varlist2)
nclasses(#)
[,	id(varname)
membership(varlist3)
constraints(numlist)
seed(#)
from(init_specs)
noninteractive_options]

Description

lclogit2 is an enhanced version of lclogit (Pacifico and Yoo, 2013), and estimates latent class conditional logit models using the Expectation-Maximization (EM) algorithm of Bhat (1997). Like its predecessor, lclogit2 produces maximum likelihood estimates without standard errors. To obtain standard errors, users may apply boostrap as Train (2008) has proposed.
Alternatively, users may pass lclogit2 estimates as starting values to lclogitml2.

lclogitml2 is a parallel command that estimates latent class conditional logit models using usual optimization methods for maximum likelihood estimation. See maximize.
It can be used as a standalone estimation command. It can be also used as a tool to obtain standard errors associated with existing lclogit2 estimates, as suggested above.

Both lclogit2 and lclogitml2 are supported by postestimation commands lclogitpr2, lclogitcov2 and lclogitwtp2. Before applying lclogit2 with option membership(), Maartin Buis's fmlogit (findit fmlogit) must be installed.

Major differences between lclogit2 and lclogit are as follows.

1. lclogit2 can estimate the same model considerably faster as it uses Mata to execute core algebraic operations.

2. lclogit2 allows a model to include both homogeneous coefficients that remain identical across classes and heterogeneous coefficients that vary across classes.
It assumes that varlist1 have homogeneous coefficients and varlist2 have heterogeneous coefficients. In contrast, lclogit assumes that all coefficients are heterogeneous.

3. lclogit2 can incorporate linear constraints, defined in the usual manner using Stata's constraint command.
The constraints may apply within a particular class, as well as across different classes. In contrast, lclogit can only incorporate within-class linear constraints,
and has its own syntax requirements for how such constraints should be defined.

4. lclogitml2 is now a standalone estimation command. In contrast, lclogitml accompanying lclogit is simply a wrapper that passes
existing lclogit estimates to Sophia Rabe-Hesketh's gllamm (findit gllamm). This difference brings about several advantages. First, lclogitml2
has been coded in Mata, and can estimate latent class conditional logit models considerably faster than gllamm. Second, lclogitml2 can directly incorporate
the linear constraints defined for lclogit2. In comparison, to impose the same constraints in lclogit and lclogitml estimation runs, users must
define a set of constraints to satisfy the syntax requirements of lclogit, and translate them into another set of constraints to satisfy that of gllamm.
Third, lclogitml2 is better suited to estimating a model with a large number of heterogeneous coefficients. Suppose that the model of interest includes C classes and
varlist2 includes K variables so that there are C * K heterogeneous coefficients. In ml model parlance, lclogitml2 will add C equations where each equation
consists of K coefficients for a particular class. In contrast, gllamm will add C * K equations, where each equation's intercept corresponds to a particular coefficient.
When C * K is large, a call to gllamm via lclogitml may fail with an error message stating that some equation is not found, presumably because there is a limit on
the number of equations that gllamm can add to a ml model statement.

5. lclogit2 and lclogitml2 are supported by a new postestimation command, lclogitwtp2, that calculates the willingness-to-pay (WTP) measures implied by the estimated latent class conditional logit model. The WTP measures are the main parameters of interest in many non-market valuation studies.

Options for lclogit2

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

rand(varlist2) is required and specifies independent variables whose coefficients are allowed to vary across classes.

nclasses(#) is required and specifies the number of latent classes.

id(varname) specifies a numeric identifier variable for individual choice makers. If left unspecified, lclogit2 assumes that group(.) and id(.) are identical (i.e. each choice situation was for a different choice maker).

membership(varlist3) specifies indepedent variables to enter the fractional multinomial logit model of class membership. These variables are assumed to be constant within a choice choice maker across all alternatives and choice situations.

constraints(numlist) specifies the linear constraints to be applied during estimation. The constraints must have been defined using constraint.
Equation names for coefficients on varlist1 and varlist2 are Fix and Class`c' respectively, where `c' refers to a particular class number.
For example, the coefficient on varname in varlist1 is [Fix]varname, and the coefficient on varname in varlist2 is [Class1]varname
for Class 1, [Class2]varname for Class 2 and so on.

seed(#) sets the seed for pseudo uniform random numbers used in computing starting values. The default is c(seed).

iterate(#) specifies the maximum number of iterations. The default is 1000.

ltolerance(#) specfies the tolerance for the log likelihood. When the proportional increase in the log likelihood over the last five iterations is less than the specified value, lclogit2 declares convergence. The default is 0.00001.

tolcheck requests the use of an extra convergence criterion to reduce the chance of false declaration of convergence. If this option is used, lclogit2 will declare convergence when
(1) the relative change in the log likelihood over the last five iterations is smaller than ltolerance(#) AND (2) the relative difference in the coefficient vector over the last five iterations
is smaller than tolerance(#).

tolerance(#) specifies the tolerance for the coefficient vector. The default is 0.0004.

nolog suppresses the display of an iteration log.

Options for lclogitml2

In addition to options that overlap with lclogit2, lclogitml2 offers the following.

from(init_specs) requests the use of user-supplied initial values for the coefficients.

noninteractive_options specifies other extra options for use with ml model in noninteractive mode.

Examples

Consider the Huber and Train (2001) data file that has been used in lclogit examples. In this data file, each choice maker identified by pid faces
several choice situations identified by gid.

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

Use lclogit2 to estimate a 4-class model, assuming all choice model coefficients are heterogeneous. Then, pass the results as starting values to lclogitml2.

. lclogit2 y, rand(price contract local wknown tod seasonal) id(pid) group(gid) nclasses(4)

. matrix start = e(b)

. lclogitml2 y, rand(price contract local wknown tod seasonal) id(pid) group(gid) nclasses(4) from(start)

Type lclogit2 to display active lclogitml2 results in an lclogit2-style output table.

. lclogitml2 y, rand(price contract local wknown tod seasonal) id(pid) group(gid) nclasses(4) from(start)

. lclogit2

Repeat the first example, assuming that the coefficients on price is homogeneous.

. lclogit2 y price, rand(contract local wknown tod seasonal) id(pid) group(gid) nclasses(4)

. matrix start = e(b)

. lclogitml2 y price, rand(contract local wknown tod seasonal) id(pid) group(gid) nclasses(4) from(start)

Repeat the first example, under two constraints: (1) Class 1 and Class 3 have the same coefficient on contract and (2) in Class 2, the coefficient on local takes the value of zero.

. constraint 1 [Class1]contract = [Class3]contract

. constraint 2 [Class2]local = 0

. lclogit2 y, rand(price contract local wknown tod seasonal) id(pid) group(gid) nclasses(4) constraints(1 2)

. matrix start = e(b)

. lclogitml2 y, rand(price contract local wknown tod seasonal) id(pid) group(gid) nclasses(4) constraints(1 2) from(start)

Switch on tolcheck to check convergence of the EM algorithm more carefully.

. lclogit2 y, rand(price contract local wknown tod seasonal) id(pid) group(gid) nclasses(4) tolcheck

Saved results

lclogit2 and lclogitml2 save the following in e():

Scalars

e(N) number of observations

e(N_g) number of choice situations identifed by group()

e(N_i) number of choice makers identifed by id()

e(nclasses) number of latent classes

e(k) number of coefficients

e(k_fix) number of variables in varlist1

e(k_rand) number of variables in varlist2

e(k_share) number of variables in varlist3

e(ll) log likelihood

e(bic) Bayesian information criterion

e(aic) Akaike information criterion

e(caic) Consistent Akaike information criterion

e(converged) convergence criterion is satified (=1) or not (=0)

Macros

e(cmd) lclogit2

e(title) Model estimated via EM algorithm

e(group) name of group() variable

e(id) name of id() variable

e(depvar) name of variable depvar

e(indepvars_fix) names of variables in varlist1

e(indepvars_rand) names of variables in varlist2

e(indepvars_share) names of variables in varlist3

e(seed) pseudo random number seed

Matrices

e(b) coefficient vector that collects all coefficients

e(b_fix) vector of coefficients on varlist1

e(b_rand) vector of coefficients on varlist2

e(b_share) vector of coefficients on varlist3

e(B) matrix of choice model coefficients

e(CMB) matrix of class membership model coefficients

e(P) vector of (estimation sample average) class shares

e(PB) vector of weighted average choice model coefficients, where weights = class shares

Functions

e(sample) marks estimation sample

Reference

Bhat, C., 1997. An endogenous segmentation mode choice model with an application to intercity travel. Transportation Science 31, 34-48.

Huber, J. and K. Train, 2001. On the similarity of classical and bayesian estimates of individual mean partworths. Marketing Letters 12, 259-269.

Pacifico, D. and H. Yoo, 2013. lclogit: A Stata command for fitting latent-class conditional logit models via the expectation-maximization algorithm. Stata Journal 13, 625-639.

Train, K., 2008. EM Algorithms for Nonparametric Estimation of Mixing Distributions. Journal of Choice Modelling 1 (1) 40-69.

Author

Hong Il Yoo (h.i.yoo@durham.ac.uk): Durham University Business School, United Kingdom.

Also see

Online: lclogit2_postestimation, lclogit (if installed), fmlogit (if installed), mixlogit (if installed), gllamm (if installed)