BLP_data: Prepares data and parameters related to the BLP algorithm for...

View source: R/BLP_data.R

BLP_dataR Documentation

Prepares data and parameters related to the BLP algorithm for estimation.

Description

Prepares data and parameters related to the BLP algorithm for estimation.

Usage

BLP_data(
  model,
  market_identifier,
  product_identifier,
  par_delta,
  group_structure = NULL,
  additional_variables = NULL,
  productData,
  demographic_draws,
  integration_accuracy,
  integration_method,
  integration_draws,
  integration_weights,
  integration_seed,
  blp_inner_tol = 1e-09,
  blp_inner_maxit = 10000
)

Arguments

model

the model to be estimated in R's formula syntax,

market_identifier

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

product_identifier

character specifying the product identifier (variable name must be included in productData),

par_delta

optional: numeric vector with values for the mean utility (variable name must be included in productData),

group_structure

optional: character specifying a group structure for clustered standard erros (variable name must be included in productData),

additional_variables

optional: character vector specifying variables you want to keep for later analysis (variable names must be included in productData)

productData

data.frame with product characteristics,

demographic_draws

optional: list with demographic draws for each market to consider observed heterogeneity (see details),

integration_accuracy

integer specifying integration accuracy,

integration_method

character specifying integration method,

integration_draws

numeric matrix of manually provided integration draws (see details),

integration_weights

numeric vector of manually provided integration weights,

integration_seed

seed for the draws of Monte Carlo based integration,

blp_inner_tol

tolerance for the contraction mapping (default: 1e-9),

blp_inner_maxit

maximum iterations for the contraction mapping (default: 10000)

Details

For any form of user provided integration draws, i.e. integration_draws (unobserved heterogeneity) or demographic_draws (observed heterogeneity), list entries must be named and contain the variable market_identifier to allow market matching. Each line in these list entries contains the draws for one market. In case of unobserved heterogeneity, list names must match the random coefficients from the model formula. The par_delta argument provides the variable name for mean utilitys. For example, in the estimation algorithm these values are used as starting guesses in the contraction mapping. Another example is the evaluation of the GMM, which is also based on the provided mean utilitys. If you need to update par_delta or any other variable in the data object, use update_BLP_data.

Value

Returns an object of class blp_data.

Examples

K<-2 #number of random coefficients
data <- simulate_BLP_dataset(nmkt = 25, nbrn = 20,
                        Xlin = c("price", "x1", "x2", "x3", "x4", "x5"),
                        Xexo = c("x1", "x2", "x3", "x4", "x5"),
                        Xrandom = paste0("x",1:K),instruments = paste0("iv",1:10),
                        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 )


model <- as.formula("shares ~  price + x1 + x2 + x3 + x4 + x5 |
                    x1 + x2 + x3 + x4 + x5 |
                    0+ x1 + x2 |
                    iv1 + iv2 + iv3 + iv4 + iv5 + iv6 + iv7 + iv8 +iv9 +iv10" )

blp_data <- BLP_data(model = model, market_identifier="cdid",
                     product_id = "prod_id",
                     productData = data,
                     integration_method = "MLHS" ,
                     integration_accuracy = 40,
                     integration_seed = 1)


BLPestimatoR documentation built on Dec. 3, 2022, 5:07 p.m.