Learn R Programming

BLPestimatoR (version 0.1.5)

get.BLP.dataset: This function creates a simulated BLP dataset.

Description

This function creates a simulated BLP dataset.

Usage

get.BLP.dataset(nmkt, nbrn, Xlin, Xexo, Xrandom, instruments,
  true.parameters = list(), price.endogeneity = list(), printlevel = 1,
  seed)

Arguments

nmkt

number of markets

nbrn

number of products

Xlin

character vector specifying the set of linear variables

Xexo

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

Xrandom

character vector specifying the set of random coefficients (subset of Xlin)

instruments

character vector specifying the set of instrumental variables

true.parameters

list with parameters of the DGP

Xlin.true.except.price

"true" linear coefficients in utility function except price

Xlin.true.price

"true" linear price coefficient in utility function

Xrandom.true

"true" set of random coefficients

instrument.effects

"true" coefficients of instrumental variables to explain endogenous price

instrument.Xexo.effects

"true" coefficients of exogenous variables to explain endogenous price

price.endogeneity

list with arguments of the multivariate normal distribution

mean.xi

controls for the mean of the error term in the utility function

mean.eita

controls for the mean of the error term in the price function

cov

controls for the covariance of xi and eita

printlevel

0 (no output) 1 (summary of generated data)

seed

seed for the random number generator

Value

Returns a simulated BLP dataset.

Details

The dataset is balanced, so every market has the same amount of products. Only unobserved heterogeneity can be considered. Variables that enter the equation as a Random Coefficient or exogenously must be included in the set of linear variables. The parameter.list argument specifies the "true" effect on the individual utility for each component. Prices are generated endogenous as a function of exogenous variables and instruments, where the respective effect sizes are specified in instrument.effects and instrument.Xexo.effects. Error terms xi and eita are drawn from a multivariate normal distribution, whose parameters can be set in price.endogeneity. Market shares are generated by MLHS integration rule with 10000 nodes.

Examples

Run this code
# NOT RUN {
K<-2 #number of random coefficients
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 <- 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 = 234234 )


# }

Run the code above in your browser using DataLab