4.2 Individual-level stuff: Part-worth utilities and ratios
Price
Packaging
Flavor
ID
$2
$3
$4
Paper
Sticker
Chocolate
Nuts
4
0
-2.22
-3.98
0
-4.24
0
-9.76
5
0
-2.55
-5.99
0
-0.19
0
-0.14
6
0
-1.31
-2.87
0
2.67
0
-8.60
7
0
-1.61
-3.34
0
2.63
0
-6.78
8
0
-1.57
-3.71
0
3.49
0
-4.41
For respondent 4, the difference in preference when moving from $2 to $4 is roughly the same as the preference for a sticker
We can also calculate the relative importance of each attribute for each individual by determining how much each attribute contributes to the overall utility of the choice. We first calculate the range of each
predict_mnl <-function(model, data) {# Function for predicting shares from a multinomial logit model # model: mlogit object returned by mlogit()# data: a data frame containing the set of designs for which you want to # predict shares. Same format at the data used to estimate model. data.model <-model.matrix(update(model$formula, 0~ .), data = data)[ , -1] utility <- data.model %*% model$coef share <-exp(utility) /sum(exp(utility))cbind(share, data)}predict_hier_mnl <-function(model, data, nresp =1000) { # Function to predict shares of a hierarchical multinomial logit model# model: mlogit object returned by mlogit()# data: a data frame containing the set of designs for which you want to# predict shares. Same format at the data used to estimate model.# Note that this code assumes all model parameters are random data.model <-model.matrix(update(model$formula , 0~ .), data = data)[ , -1] coef.Sigma <-cov.mlogit(model) coef.mu <- model$coef[1:dim(coef.Sigma)[1]] draws <- MASS::mvrnorm(n = nresp, coef.mu, coef.Sigma) shares <-matrix(NA, nrow = nresp, ncol =nrow(data))for (i in1:nresp) { utility <- data.model%*%draws[i,] share <-exp(utility)/sum(exp(utility)) shares[i,] <- share }cbind(colMeans(shares), data)}example_product_mix <-tribble(~price, ~packaging, ~flavor,"$2", "Plastic + sticker", "Chocolate","$3", "Plastic + sticker", "Chocolate","$4", "Plastic + sticker", "Chocolate","$2", "Plastic + paper", "Nuts","$3", "Plastic + paper", "Nuts","$4", "Plastic + paper", "Nuts") |>mutate(across(everything(), factor))predict_hier_mnl(model_mlogit_hierarchical, example_product_mix)## colMeans(shares) price packaging flavor## 1 0.645363 $2 Plastic + sticker Chocolate## 2 0.121951 $3 Plastic + sticker Chocolate## 3 0.045006 $4 Plastic + sticker Chocolate## 4 0.157910 $2 Plastic + paper Nuts## 5 0.021582 $3 Plastic + paper Nuts## 6 0.008187 $4 Plastic + paper Nuts