attraction_data: Prepare data to estimate a market share attraction model

View source: R/attraction_data.R

attraction_dataR Documentation

Prepare data to estimate a market share attraction model

Description

Prepare a data set (in long format) to its base-brand representation, so that it can be estimated using SUR or maximum likelihood.

Usage

attraction_data(formula, data = NULL, subset = NULL, heterogenous = NULL, index = NULL, model = "MCI", benchmark = NULL, ...)

Arguments

formula

a two-sided linear formula object describing the attraction model to be estimated, with the market share on the left of a ~ operator (must sum to 1 per period) and the explanatory variables, separated by + operators, on the right. All explanatory variables are estimated as homogenous, unless they are added as one-sided formulas under heterogenous.

data

an optional data frame containing the variables named in formula, heterogenous, and index. By default the variables are taken from the environment from which attraction_data is called.

heterogenous

a one-sided formula object, with variables on the right of a ~ sign describing all heterogenous variables, separated by + operators.

index

a one-sided formula object, with two variables on the right of a ~ sign, describing (1) the brand index, and (2) the time index of the data, seperated by a + sign. The package authors strongly recommend to sort the data by brand and time before calling attraction_date.

model

specifies the transformation type that will be applied to the data. Can be one of "MCI" (standard) or "MNL".. For details, see Fok 2001.

benchmark

character vector, specifying the benchmark brand to be chosen for normalization; default of NULL implies that the algorithm automatically determines the benchmark brand (chosing the brand with most available observations for all variables and all time periods).

subset

an optional expression indicating the subset of the rows of data that should be used in the fit. This can be a logical vector, or a numeric vector indicating which observation numbers are to be included, or a character vector of the row names to be included. All observations are included by default.

...

other potential arguments. Currently not implemented.

Details

  • ...

Value

An object of class attr.data, for which some methods are available (e.g., show).

References

Cooper, L. G., & Nakanishi, M. (1988). Market-share analysis: Evaluating competitive marketing effectiveness. Boston: Kluwer Academic Publishers.

Fok, D., Franses, P. H., & Paap, R. (2001). Econometric analysis of the market share attraction model.

See Also

itersur for details on how to estimate the model.

Examples

# Load package
  require(marketingtools) 

# Simulate raw data
  rawdata <- do.call('cbind', attraction_simulate_data())
  head(rawdata)

# Transform to base-brand representation
  dtbb <- attraction_data(formula = y ~ X.var_3 + X.var_4 + X.var_5 + X.var_1 + X.var_2, heterogenous = ~ X.var_1 + X.var_2, index = ~ index.var + index.t, data=rawdata, model="MCI")

# verify object
  validObject(dt)

# show a summary about the transformed data
  show(dt)

# Estimate model using itersur (FGLS)
  m <- itersur(X=dtbb@X,Y=as.matrix(dtbb@y), index=data.frame(date=dtbb@period,brand=dtbb@individ), method = "FGLS")
  
  show(m) # summarize m
  print(m@sigma) # show contemporaneous variance-covariance matrix
  
# Estimate model using itersur with correction for autocorrelation in the residuals (FGLS-Praise-Winsten)
  m <- itersur(X=dtbb@X,Y=as.matrix(dtbb@y), index=data.frame(date=dtbb@period,brand=dtbb@individ), method = "FGLS-Praise-Winsten")
  
  show(m) # summarize m
  print(m@sigma) # show contemporaneous variance-covariance matrix
    


hannesdatta/marketingtools documentation built on June 3, 2022, 11:42 p.m.