Title

rcl Random coefficient logit models: estimation and simulation

Syntax

rcl sharevar [varlist_iexog]
[(varlist_endog=varlist_iv)]
[if] [in]
, market(marketvar)
[options]

main variables

sharevar market share variable; compulsory to specify

varlist_iexog exogenous product characteristics (to be included
in the mean utility function)

varlist_endog endogenous product characteristics; if specified,
the first variable is assumed to be the price variable; if not specified,
price is assumed to be the first variable of varlist_iexog

varlist_iv instrumental variables (excluded exogenous
variables)

Main
market(marketvar) marketvar is the indicator variable
identifying markets; compulsory to specify

rc(varlist) variables with random coefficient in the BLP
model

nests(varlist) indicator variables of nests, subnests,
sub-subnests in the nested logit model, in this order

msize(varname) varname is the potential market size; if
not specified, default is value 1 for all markets

integrationmethod(string) method of integral simulation for the
BLP model; may be sparsegrid (default) or mc

itol(real) tolerance bound of inner loop iterations for the BLP
model; default is 10e-12

imaxiter(integer) maximum number of inner loop iterations for
the BLP model; default is 2500

accuracy(integer) accuray of sparse grid integration for the
BLP model; default is 6

draws(integer) number of draws in Monte Carlo integration for
the BLP model; default is 500

nodisplay suppress output printed on screen

Estimation
method estimation method, may be gmm2s (two-step GMM),
igmm (iterated GMM), cue (CUE GMM), tsls (three-stage least
squares, if eqestimation is specified); if no method is specified,
two-stage least squares is used

optimal use optimal instruments for estimation

robust heteroscedasticity robust standard errors

cluster(varname) cluster robust standard errors with clustering
on varname

startparams(matrix) rowvector of starting values of random
coefficients for the BLP model (if rc() is specified)

eqestimation joint estimation of demand and pricing
equation

xp(varlist) included exogenous variables in the pricing
equation; default is varlist_iexog and polinomials of
varlist_iv

pinstruments(varlist) instruments (excluded exogenous
variables) for the pricing equation; default is varlist_iv

startparams(matrix) rowvector of starting values of random
coefficients and price coefficient for the BLP model (if rc() or eqestimation
is specified)

noconstant suppress constant term; default is to add constant
to varlist_iexog if not collinear

nocollin suppress checks for collinearities and duplicate
variables

Elasticities, merger simulation, marginal costs, SSNIP test
elasticities(varname) calculate elasticites for product groups
indicated by varname

msimulation(varlist) perform merger simulation, firm variable
for pre- and post-merger ownership is the first and second variable of
varlist, respectively

mc(varname) user specified marginal costs; if not specified
(default) model implied marginal costs are used

onlymc no merger simulation is performed, only the marginal
costs implied by the pre-merger ownership are caclulated and saved into
__mc

cmce calculate compensating marginal cost efficiencies, implied
reduced marginal costs saved into __mce

ssnip(varlist) perform SSNIP test of product groups identified
by the first variable of varlist, second variable gives the product
ownership for implied marginal cost calculation

vat(varname) VAT rate contained in prices
(between 0 and 1)

Simulation without estimation
noestimation no estimation performed, required to specify for
simulation without estimation

alpha(real) negative of the mean coefficient on the price
variable (>0)

sigmas(numlist) nested logit sigmas on nests, subnests,
sub-subnests, in this order (0<=s_nest<=s_subnest<=s_subsubnest<1)

rcsigmas(numlist) random coefficients in the BLP model, in the
same order as the variables in the option rc() (>0)

xb0(varname) user specified non-price part of observed part of
mean utility; not required to specify for simulation without estimation

ksi(varname) user specified unobserved part of mean utility;
not required to specify for simulation without estimation

Contents

Description

Main options

Estimation options

Elasticities, merger simulation, marginal costs, SSNIP test

Simulation without estimation

Remarks

Examples

Stored results

References

Description

rcl estimates and simulates random coefficient logit models using
product level data. The models covered include the random coefficient logit
model of Berry, Levinsohn and Pakes (1995) (BLP), nested
logit models (with one, two or three nesting level), as well as the simple
logit model. The command can perform estimation, merger simulation and
calculation of various descriptives (elasticities -grouped or product-level-,
diversion ratios, implied marginal costs, compensating marginal cost
efficiencies). rcl can also use pre-defined parameter values and/or
marginal cost data in these simulations. Hence, it can be used as a basis for
estimation, counter-factual simulation and calibration work as well as for
data simulation.

rcl implements the estimation algorithm of Berry, Levinsohn and Pakes
(1995) for their model, and uses ivreg2 for the linear nested and
simple logit models. The standard model diagnostics of ivreg2 are
reported for each estimated model.

Requirements. Stata 11 or higher. ivreg2 and ranktest need to
be installed. (If not, type ssc install ivreg2 and
ssc install ranktest.)

Options

Main

market(marketvar)marketvar is the indicator variable
identifying markets; compulsory to specify.

rc(varlist) variables with random coefficient in the BLP model.
If not specified, the assumed model is either a nested logit model (if
the nests() option is specified) or a simple logit model.

nests(varlist) indicator variables of nests, subnests,
sub-subnests in the nested logit model (see, e.g.,
McFadden (1981)), in this order. If not specified, the
assumed model is either a BLP model (if the rc() option is specified) or
a simple logit model.

msize(varname) varname is the potential market size; if not
specified, default is value 1 for all markets. Note that the product market
shares given by sharevar are meant to be calculated on the potential
market. Hence, the potential market size variable sets the share of the outside
good of the model.

integrationmethod(string) method of integral simulation for the
BLP model. It may be sparsegrid (default) or mc. sparsegrid
implies the Smolyak sparse grid integration as implemented for Stata by the
nwspgr command of Heiss and Winschel (2007). As shown
by Judd and Skrainka (2011), this method is superior to
Monte Carlo integration in terms of both speed and accuracy. Setting mc
for the option implies Monte Carlo integration, with 500 draws (if
draws() is not set otherwise).

itol(real) tolerance bound of inner loop iterations for the
BLP model; the default is 10e-12.

imaxiter(integer) maximum number of inner loop iterations for the
BLP model; the default is 2500.

accuracy(integer) accuray of sparse grid integration for the
BLP model; the default is 6.

draws(integer) number of draws in Monte Carlo integration for the
BLP model; the default is 500.

nodisplay suppress output printed on screen.

Estimation

method estimation method, may be gmm2s (two-step GMM),
igmm (iterated GMM), cue ("continuously updated GMM estimator",
only for linear models: nested and simple logit), tsls (three-stage least
squares, if eqestimation is specified); if no method is specified,
two-stage least squares is used. The linear models are estimated by
ivreg2 (see also Baum et al 2007 and
2010). The estimation is linear due to the
log-linearization method described by Berry (1994). In the
case of the BLP model, however, the same log-linearization does not lead to a
standard linear estimating equation. Hence, the nested fixed-point estimation
algorithm of BLP, Nevo (2000) and (2001)
is implemented.

optimal use optimal instruments for estimation.
Chamberlain (1987) shows that in a general GMM estimation
framework, the instrument set which minimizes the variance of the estimator,
that is, the "optimal" instrument set, is a function of the data and the
model's parameters. Hence, in general optimal instrumenting is not feasible as
the optimal instruments are not known prior to estimation. (In some specific
cases optimal instrumenting is feasible. For example, in a linear model, under
homoscedasticity and some assumptions about the structure of the underlying
economic model, the two-stage least squares estimator is optimal. For
non-linear models like BLP, however, this is no longer true, not even for
the case with homoscedastic error terms.) In practice, approximations of the
optimal instruments are feasible. rcl implements the two-step procedure
described by Reynaert and Verboven (2014) to calculate
an approximation of the optimal instruments and to estimate the model. The
authors show that the procedure improves the statistical reliability and
precision of the estimates. In the first step of the procedure, the standard IV
estimates of the parameters are calculated using the instrumental variables in
varlist_iv. These first-step estimates are then used to calculate the
optimal instruments. The second step is the estimation of the model with the
optimal instruments.

robust heteroscedasticity robust standard errors.

cluster(varname) cluster robust standard errors with clustering
on varname.

startparams(matrix) rowvector of starting values of random
coefficients for the BLP model (if rc() is specified).

eqestimation joint estimation of demand and pricing equation.
Reynaert and Verboven (2014) show that joint estimation of
the demand and pricing equations might result in more accurate estimates than
single equation demand estimation. The pricing equation is derived in the
following way. Assuming Bertrand (price) competition, the optimal markups can
be calculated as a function of the model's parameters and the demand function.
Price is then modelled as a sum of the implied markup and the marginal cost.
This latter is assumed to be a linear function of the "cost shifters" given by
the the option xp(varlist). (If that latter option is not specified the
cost shifters are given by varlist_iexog and polinomials of
varlist_iv.) To calculate the implied Bertrand markups, a product
ownership structure has to be given. The user can specify this by the
msimulation() option. For example, if firm is the categorical
variable describing which product is owned by which firm, specifying
msimulation(firm) will tell this to the command. If msimulation() is
not specified it is assumed that each product is owned by a separate,
single-product firm. Note that if msimulation() specifies only one
variable no merger simulation is carried out. The implied markups and
marginal costs, evaluated at the estimated parameters, are saved into the
variables __mrkp and __mc, respectively.

xp(varlist) included exogenous variables in the pricing
equation; the default is varlist_iexog and polinomials of
varlist_iv.

pinstruments(varlist) instruments (excluded exogenous variables)
for the pricing equation when ; the default is varlist_iv.

startparams(matrix) rowvector of starting values of random
coefficients and price coefficient for the BLP model (if rc() or eqestimation
is specified).

noconstant suppress constant term; the default is to add a
constant variable to varlist_iexog if it is not collinear.

nocollin suppress checks for collinearities and duplicate
variables.

Elasticities, merger simulation, marginal costs, SSNIP test

elasticities(varname) calculate elasticity and diversion ratio
(square) matrices for product groups indicated by varname. The elements of
the matrices are quantity weighted averages across markets. The dimension of
the matrices is equal to the number of uniqe elements in varname. If
varname is the product identifier the resulting matrices are just the
product level elasticities and diversion ratios. If varname identifies
groups of products the results are the aggregated elasticities. If varname
is a constant variable the result is the aggrate demand elasticity. The
elasticity and diversion ratio matrices are stored as "el" and "dr",
respectively.

msimulation(varlist) perform merger simulation, pre- and
post-merger ownership of products, that is, the indicator of independent firms
is the first and second variable of varlist, respectively. Merger
simulation amounts to calculating the new Bertrand price equilibrium when the
ownership structure of products is changed. The simple and nested logit models
are solved using simple fixed-point iterations. For the BLP model, iterations
between a quasi Newton-algorithm on the sum of squared normalized first order
conditions of the Bertrand equilibrium and a quasi Newton-algorithm on the sum
of squared price prediction errors are used. For the simple and nested logit
models, the implied (pre-merger) marginal costs can be calculated using
closed-form analytical formulas. For the BLP model, numerical matrix inversion
is used. These implied margins are used as default, but specifying the
mc() option one can use other margins as well (this can be the case, for
example, in some calibration or data simulation works). If the two variables
given in varlist are the same, the current equilibrium is calculated
(again, this can be of use, for example, when a dataset of equilibrium prices
and shares is simulated given model parameters and marginal costs). Finally,
note that when no merger simulation is needed but one still wants to calculate
the implied Bertrand marginal costs and markups (for example, when joint
demand/pricing estimation is performed, see option eqestimation, or when
simply the onlymc option is specified), it is sufficient to specify only
one element in varlist that gives the product ownership structure.
(Moreover, in the case of the joint demand/pricing estimation the
msimulation(varlist) option can be entirely omitted, implying the
assumption that each product is owned by a separate, single-product firm.)
The post-merger prices, shares and equilibrium first order conditions, as well
as the implied (pre-merger) markups and marginal costs are saved into the
variables __p_post, __s_post, __foc_post, __mrkp and __mc, respectively.

mc(varname) user specified marginal costs; if not specified
(default) the model implied marginal costs are used.

onlymc no merger simulation is performed, only the marginal
costs and markups implied by the pre-merger product ownership and Bertrand
competition are caclulated and saved into __mc and __mrkp, respectively. The
pre-merger product ownership structure is given by the first variable
specified in the msimulation(varlist) option (and note that in this case
it is sufficient to specify only one element in the varlist).

cmce calculate compensating marginal cost efficiencies. These
are the implied post-merger marginal costs at which the merger would have no
price effect (the prices at the new, post-merger equilibrium would be the same
as the pre-merger prices). Hence, these new marginal costs give an indication
on the level of marginal cost savings needed to compensate for the merger
induced loss of competition between the mergin parties. (See also
Werden (1996)). The efficient marginal costs are saved into
__mce. The option can be combined with the onlymc option. The pre-merger
product ownership structure is given by the first variable specified in the
msimulation(varlist) option (and note that in this case it is sufficient
to specify only one element in the varlist).

ssnip(varlist) perform SSNIP test of product groups identified
by the first variable of varlist, with the second variable identifying the
product ownership for the implied marginal cost calculation. SSNIP stands for
"Small but Significant Non-transitory Increase in Price". The implemented
version of the SSNIP test calculates for each product group separately the
implied % change in the total profit generated by the group's products when the
prices of the group's products are subject to a "SSNIP", that is, they are
increased by 1, 5 or 10% uniformly (while the price of all other products are
kept unchanged). The test is a measure of the overall demand side
substitutability of the product group in question (with products not in the
group), with positive profit changes indicating relatively weaker
substitutability. See also Ivaldi and Lorincz (2011) for
more discussion. The results are stored in the matrix "ssnip".

vat(varname) VAT rate contained in prices (between 0 and 1). No
need to specify it if the price variable is net of VAT.

Simulation without estimation

noestimation no estimation performed, required to specify for
simulation without estimation. In the main part of the command, it is
sufficient to specify only the share and price variables (in this order, these
are used as starting points for the equilibrium simulation). From the options,
the market() option is still needed. This mode of operation can be used
to calculate elasticities (elasticities()); equilibrium prices, shares,
implied marginal costs or compensating marginal cost efficiencies
(msimulation(), onlymc, cmce); or SSNIP tests
(ssnip()). The outcome variables and matrices are saved as before; in
particular __s_post and __p_post are the calculated equilibrium's market shares
and prices, respectively. The typical use can be to replicate some simulation
results for an already estimated model; simulate a new price equilibrium with
change in product qualities (see option xb0() below); simulate new
equilibrium datasets for given parameters, marginal costs (using the mc()
option) and/or characteristics; or some combinations of these cases. Note that
for the msimulation() option it is sufficient to specify only one
variable.

alpha(real) negative of the mean coefficient on the price
variable (>0). If a negative value is given its absolute value is used. If no
value is specified the mean price coefficient is estimated from a regression of
the mean utility on the price and other characteristics (if specified).

sigmas(numlist) nested logit sigmas on nests, subnests,
sub-subnests, in this order (0<=s_nest<=s_subnest<=s_subsubnest<1).

rcsigmas(numlist) random coefficients in the BLP model, in the
same order as the variables in the option rc() (>0).

xb0(varname) user specified non-price part of observed part of
mean utility; not required to specify for simulation without estimation. The
non-price part of the observed part of mean utility is the observed mean
"quality" of the product. In some simulations, the question to be investigated
is how the equilibrium prices and quantities change if the quality of (some or
all) prodcuts change. The new quality levels can be given by the xb0()
option. (The option can also be combined with the ksi() option, which
gives the unobserved component of the mean utility, for example, from a
previous estimation. If ksi() is not specified, the unobserved component
is calculated as the remaining part of the mean utility after substracting xb0
and the price utility component.

ksi(varname) user specified unobserved part of mean utility; not
required to specify for simulation without estimation.

aelast(numlist) user specified value of aggregate elasticity. If
specified the market size is adjusted so that the implied aggregate elasticity
to be equal to the number given. The specified value can be positive or
negative; the negative of its absolute value will be used. The implied market
size is saved into the variable __msize.

Remarks

The Mata functions of rcl are compiled into the Mata library lrcl.mlib
(downloaded automatically during installation into the ado/plus/l folder; for
the location of the ado folders type sysdir). The source code of the
functions can be found in the ancillary rcl_*.do do files. The the
rcl_mlib_data_generation.do file reproduces the lrcl.mlib library from these do
files. These files are downloaded into the current directory if rcl is
installed by specifying the all option: "ssc install rcl, all replace".
(The current directory's name is in c(pwd). Alternatively, the files can be
directly downloaded from the IDEAS website.) The rcl_mlib_generation.do file
compiles the lrcl library using the other do files. Note that the addresses
might have to be changed depending on the files' location.

The rcl_and_test_data_generation.do file reproduces the rcl_test_data.dta
test dataset used in the examples below (and saves it into the
ado/plus/r folder). Also, note that if rcl is installed from SSC ("ssc
install rcl, all replace") the test dataset is downloaded from the website and
saved into the current directory.

rcl uses the ivreg2 command of
Baum et al 2007 and 2010 for the
estimation of the linear nested and simple logit models. In addition, various
auxiliary functions from ivreg2 and ranktest (of Kleibergen and
Schaffer) are used separately for some calculations. All of these cases are
indicated in the ado and do files. Also, rcl uses the nwspgr
command of Heiss and Winschel (2007) for the sparse grid
integration. The authors of these commands and functions are acknowledged and,
of course, are not responsible for any mistake in or error of the rcl
command.

Examples

Setup: load test dataset into memory

use http://fmwww.bc.edu/repec/bocode/r/rcl_test_data.dta, clear

Estimation and simulation of a simple logit model

rcl share x1 (price = w* x1_* cc ccg), market(market) robust elasticities(firm) msimulation(firm firm_post)

Estimation and simulation of a one-level nested logit model
(nest variable: g)

rcl share x1 (price = w* x1_* cc ccg), market(market) nests(g) robust elasticities(firm) msimulation(firm firm_post)

Estimation and simulation of a BLP model (random coefficients on
characteristic x1)

rcl share x1 (price = w* x1_* cc ccg), market(market) rc(x1) robust elasticities(firm) msimulation(firm firm_post)

Merger simulation of a two-level nested logit model with pre-determined
model coefficients (nest and subnest variables: g and h)

rcl share price, market(market) nests(g h) noestimation alpha(-0.5) sigmas(0.5 0.7) msimulation(firm firm_post)

Simulation of equilibrium prices and shares from a three-level nested
logit model with pre-determined model coefficients, marginal costs and
"observed" non-price mean utility component (the equilibrium prices and shares
are saved into the variables __p_post and __s_post)

rcl share price, market(market) nests(g h k) noestimation alpha(-0.5) sigmas(0.5 0.7 0.9) elasticities(constant) msimulation(firm) mc(mc) xb(xb0)

Stored results

rcl stores the following results in e():

Scalars
e(N) Number of observations
e(r2) R-squared (fit of mean utility)
e(r2_a) Adjusted R-squared
e(r2_d) R-squared of demand equation (fit of mean utility)
e(r2_p) R-squared of pricing equation
e(r2_a_d) Adjusted R-squared of demand equation (fit of mean utility)
e(r2_a_p) Adjusted R-squared of pricing equation
e(F) F statistic
e(N_clust) Number of clusters
e(j) Hansen J statistic
e(jp) p-value of Hansen J statistic
e(jdf) dof of Hansen J statistic = degree of overidentification = L-K
e(idstat) LM test statistic for underidentification (Anderson or Kleibergen-Paap)
e(idp) p-value of underidentification LM statistic
e(iddf) dof of underidentification LM statistic
e(widstat) F statistic for weak identification (Cragg-Donald or Kleibergen-Paap)

Macros
e(dmodel) Demand model (blp, logit, nlogit, nlogit2 or nlogit3)
e(title) Title
e(estimator name) Estimator name
e(vce) Type of variance-covariance estimator
e(share) Share variable
e(market) Market variable
e(exexog) List of excluded exogenous variables
e(iexog) List of included exogenous variables
e(endog) List of endogenous (right hand side) variables
e(dups) List of duplicate variables
e(collin) List of collinear variables

Matrices
e(b) Coefficient vector
e(V) Variance-covariance matrix of the estimators
e(el) Elasticity matrix
e(dr) Diversion ratio matrix
e(ssnip) Matrix with SSNIP-test results

Functions
e(sample) Marks estimation sample

Variables
(Note that if the command needs any of these variables it will be generated or overwritten.)
__shat Implied pre-merger market shares (same as sharevar)
__s_post Post-merger equilibrium market shares
__p_post Post-merger equilibrium prices
__foc_post Post-merger first order conditions of equilibrium
__delta Mean utilities
__xb0 Non-price component of observed part of mean utility
__ksi Unobserved component of mean utility
__mc Implied marginal costs
__mrkp Implied markups
__mce Implied "efficient" marginal costs (if the cmce option is specified)
__msize Implied market size (if the aelast() option is specified)

References

Baum, C. F., Schaffer, M.E., and Stillman, S., (2007):
"Enhanced routines for instrumental variables/GMM estimation and testing,"
The Stata Journal, Vol. 7, No. 4, pp. 465-506.
http://ideas.repec.org/a/tsj/stataj/v7y2007i4p465-506.html.
Working paper version: Boston College Department of Economics Working Paper No. 667.
http://ideas.repec.org/p/boc/bocoec/667.html.

Baum, C.F., Schaffer, M.E., Stillman, S., (2010):
"ivreg2: Stata module for extended instrumental variables/2SLS, GMM and AC/HAC, LIML and k-class regression,"
http://ideas.repec.org/c/boc/bocode/s425401.html

Berry, S. T., (1994):
"Estimating Discrete-Choice Models of Product Differentiation,"
Rand Journal of Economics, 25(2), pp. 242-262.

Berry, S. T., J. Levinsohn, and A. Pakes, (1995):
"Automobile Prices in Equilibrium,"
Econometrica, 63(4), pp. 841-890.

Chamberlain, G., (1987):
"Asymptotic efficiency in estimation with conditional moment restrictions,"
Journal of Econometrics, 34(3), pp. 305-334.

Heiss, F., and Winschel, W., (2007):
"Quadrature on sparse grids: Code to generate and readily evaluated nodes and weights,"
http://www.sparse-grids.de/

Ivaldi, M. and S. Lorincz, (2011):
"Implementing Relevant Market Tests in Antitrust Policy: Application to Computer Servers,"
Review of Law & Economics, 7(1), pp. 29-71.

Judd, K. L., and B. Skrainka, (2011):
"High Performance Quadrature Rules: How Numerical Integration Affects a Popular Model of Product Differentiation,"
CeMMAP working papers, CWP03/11, Centre for Microdata Methods and Practice, Institute for Fiscal Studies.
http://www.cemmap.ac.uk/wps/cwp0311.pdf

McFadden, D., (1981):
"Econometric Models of Probabilistic Choice,"
in C.F. Manski, D. McFadden (eds), Structural Analysis of Discrete Data with Econometric Applications,
MIT Press, Cambridge, Massachusetts, pp. 198-272.

Nevo, A., (2000):
"A Practitioner’s Guide to Estimation of Random-Coefficients Logit Models of Demand,"
Journal of Economics & Management Strategy, 9(4), pp. 513–548.

Nevo, A., (2001):
"Measuring Market Power in the Ready-to-Eat Cereal Industry,"
Econometrica, 69(2), pp. 307-342.

Reynaert, M. and F. Verboven, (2012):
"Improving the Performance of Random Coefficients Demand Models: the Role of Optimal Instruments,"
Journal of Econometrics, 179(1), pp. 83-98.

Werden, G. J., (1996):
"A Robust Test for Consumer Welfare Enhancing Mergers Among Sellers of Differentiated Products,"
Journal of Industrial Economics, 44, pp. 409-413.

Author

Szabolcs Lorincz

European Commission

szabolcs@gmail.com

Disclaimer: The views expressed are those of the author and cannot be
regarded as stating an official position of the European Commission, or as an
indication on what methodologies the European Commission would use or how it
would assess them in any of its proceedings.