estimateBLP: Performs a BLP demand estimation.

Description Usage Arguments Details Value Examples

View source: R/blpFunctions.R

Description

Performs a BLP demand estimation.

Usage

1
2
3
4
5
estimateBLP(Xlin, Xexo, Xrandom, instruments, demographics, shares, cdid,
  prodid = NULL, productData, demographicData, starting.guesses.theta2,
  starting.guesses.delta, solver.method = "BFGS", solver.control = list(),
  blp.control = list(), integration.control = list(),
  postEstimation.control = list(), printLevel = 0)

Arguments

Xlin

character vector specifying the set of linear variables (variable names must be included in productData)

Xexo

character vector specifying the set of exogenous variables (subset of Xlin)

Xrandom

character vector specifying the set of random coefficients (variable names must be included in productData)

instruments

character vector specifying the set of instrumental variables (variable names must be included in productData)

demographics

optional: character vector specifying the set of demographic variables (must be included as list entries in demographicData)

shares

character vector specifying observed market shares (variable name must be included in productData)

cdid

character vector specifying the market identifier (variable name must be included in productData)

prodid

columnname in productData that identifies product currently only used to name elasticity matrix. If ommited (=NULL) use default names for elasticity matrix

productData

dataframe with product characteristics

demographicData

optional: list with demographic data for each market (see details)

starting.guesses.theta2

matrix with starting values for the optimization routine (NA entries indicate the exclusion from estimation, i.e. the coefficient is assumed to be zero)

starting.guesses.delta

optional: numeric vector with starting guesses for the mean utility

solver.method

specifies the solver method in optim or ucminf

solver.control

list of additional arguments for the optimization routines:

solver.reltol

tolerance for the optimization routine

solver.maxit

maximum iterations for the optimization routine

...

further arguments passed to optim or ucminf

blp.control

list of additional argruments for the BLP algorithm:

inner.tol

tolerance for the contraction mapping

inner.maxit

maximum iterations for the contraction mapping

integration.control

list of parameters for the BLP integration problem:

method

integration method

amountNodes

integration accuracy for Monte Carlo based integration

accuracyQuad

integration accuracy for integration by quadrature rules

seed

seed for the draws of Monte Carlo based integration

nodes

set of manually provided integration nodes

weights

set of manually provided integration weights

output

if TRUE, integration nodes and individual shares (sij) are available as output

postEstimation.control

list of parameters specifying post estimation results:

standardError

chose robust (default) or nonRobust

extremumCheck

if TRUE (default), second derivatives are checked for the existence of minimum at the point estimate

elasticities

character vector specifying the set of variables elasticities are calculated for

printLevel

level of output information ranges from 1 (no GMM results) to 4 (every norm in the contraction mapping)

Details

The optimization routines are included in the packages optim and ucminf. Only gradient based methods are supported. The ucminf clones MATLABs' standard trust region optimization routine, which turns out to be effective in avoiding overflow problems in the BLP model. Valid arguments are BFGS , BFGS_matlab, L-BFGS-B or CG.

For solver options, the use of solver.maxit and solver.rel is recommended. For conflicts of solver.maxit and solver.reltol and arguments of the respective solvers, priority is given to the latter. Make sure that additionally provided solver control arguments are valid.

For demographics variables, list entries of demographicData must be named according to demographics. Each list entry contains a dataframe with the draws for different markets and a variable (according to the cdid argument) that allows to match the draws with the markets.

The logit model is used for elasticity calculation, if the variable of interest is not included in Xrandom. Columns of the elasticity matrix contain the variables that are changed by 1%, and rows contain effects on other products in the choice set.

Value

Returns an object of class 'blp'. This object contains, among others, all estimates for preference parameters and standard errors. Necessary information for further post estimation analysis can be included as well.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# Parameters
i<-1
K<-2
Xlin_example <-  c("price", "x1", "x2", "x3", "x4", "x5")
Xexo_example <- c("x1", "x2", "x3", "x4", "x5")
Xrandom_example <- paste0("x",1:K)
instruments_example <- paste0("iv",1:10)

# Data generation
BLP_data <- get.BLP.dataset(nmkt = 25, nbrn = 20,
                            Xlin = Xlin_example,
                            Xexo = Xexo_example,
                            Xrandom = Xrandom_example,
                            instruments = instruments_example,
                            true.parameters = list(Xlin.true.except.price = rep(0.2,5),
                                                   Xlin.true.price = -0.2, Xrandom.true = rep(2,K),
                                                   instrument.effects = rep(2,10),
                                                   instrument.Xexo.effects = rep(1,5)),
                            price.endogeneity = list( mean.xi = -2,
                                                      mean.eita = 0,
                                                      cov = cbind( c(1,0.7), c(0.7,1))),
                            printlevel = 0, seed = 5326 )

# Estimation
BLP_est<- estimateBLP(Xlin = Xlin_example,
                      Xrandom = Xrandom_example,
                      Xexo =  Xexo_example,
                      instruments = instruments_example,
                      shares = "shares",
                      cdid = "cdid",
                      productData = BLP_data,
                      starting.guesses.theta2 = rep(1,K),
                      solver.control = list(maxeval = 5000),
                      solver.method = "BFGS_matlab",

                      starting.guesses.delta =  rep(1, length(BLP_data$cdid)),
                      blp.control = list(inner.tol = 1e-6,
                                         inner.maxit = 5000),
                      integration.control= list(  method="MLHS",
                                                  amountNodes= 100,
                                                  seed= 3   ),
                      postEstimation.control= list(standardError = "robust",
                                                   extremumCheck = TRUE,
                                                   elasticities = "price"),
                      printLevel = 2)

# Show results
summary(BLP_est)

skranz/BLPestimatoR documentation built on May 5, 2019, 1:32 a.m.