Choice Modeling for Marketing in R
Elea McDonnell Feit
Assistant Professor of Marketing, Drexel University
Type
milk, dark, milk with nuts, dark with nuts, white
Brand
Dove, Ghirardelli, Godiva, Hershey's, Lindt
Price
0.5, 0.6, ... steps of 0.1 ..., 3.9, 4.0
choc_survey[choc_survey$Subject == 1 & choc_survey$Trial == 1, ]
Subject Trial Alt Type Brand Price
1 1 1 1 NA NA NA
2 1 1 2 NA NA NA
3 1 1 3 NA NA NA
# Setup your attributes and levels list attribs <- list(Type = c("Milk", "Dark", "White"), Brand = c("Cadbury", "Toblerone", "Kinder"), Price = 5:30 / 10)
# Create all possible combinations of attributes all_comb <- expand.grid(attribs) nrow(all_comb) head(all_comb)
144
Type Brand Price 1 Milk Cadbury 0.5 2 Dark Cadbury 0.5 3 White Cadbury 0.5 4 Milk Toblerone 0.5 5 Dark Toblerone 0.5 6 White Toblerone 0.5
for (i in 1:100) {
rand_rows <- sample(1:nrow(all_comb), size = 12 * 3)
rand_alts <- all_comb[rand_rows, ]
choc_survey[choc_survey$Subject == i, 4:6] <- rand_alts
}
Choice Modeling for Marketing in R