#> price
#> 1 1
#> 2 2
#> 3 3
a) A consumer is making a choice between two bars of chocolate:
Assume that we know the observed utility of each bar to be \(v_m = 3\) and \(v_d = 4\). Using a logit model, compute the probabilities of choosing each bar: \(P_m\) and \(P_d\).
b) A third bar of chocolate is now added to the choice set. It is the exact same as the milk chocolate bar, but it has a slightly different wrapper (which has no effect on the consumer’s utility). Now, \(v_{m1} = v_{m2} = 3\), and \(v_d = 4\). Based on the probabilities from question a), what would we expect the probabilities of choosing each bar to be? What probabilities does the logit model produce?
#> price
#> 1 1
#> 2 2
#> 3 3
#> brand brand_BMW brand_Ford brand_GM
#> 1 Ford 0 1 0
#> 2 GM 0 0 1
#> 3 BMW 1 0 0
| Attribute | Bar 1 | Bar 2 | Bar 3 |
|---|---|---|---|
| Price | $1.20 | $1.50 | $3.00 |
| % Cacao | 10% | 60% | 80% |
| Attribute | Bar 1 | Bar 2 | Bar 3 |
|---|---|---|---|
| Price | $1.20 | $1.50 | $3.00 |
| % Cacao | 10% | 60% | 80% |
| Brand | Hershey | Lindt | Ghirardelli |
20:00
Let’s say our utility function is:
\[v_j = \beta_1 x_j^{\mathrm{price}} + \beta_2 x_j^{\mathrm{cacao}} + \beta_3 \delta_j^{\mathrm{hershey}} + \beta_4 \delta_j^{\mathrm{lindt}}\]
And we estimate the following coefficients:
| Parameter | Coefficient |
|---|---|
| \(\beta_1\) | -0.1 |
| \(\beta_2\) | 0.1 |
| \(\beta_3\) | -2.0 |
| \(\beta_4\) | -0.1 |
| Attribute | Bar 1 | Bar 2 | Bar 3 |
|---|---|---|---|
| Price | $1.20 | $1.50 | $3.00 |
| % Cacao | 10% | 60% | 80% |
| Brand | Hershey | Lindt | Ghirardelli |
logitr-cars folder in Positron
code/2.1-explore-data.R
Dummy coding: 1 = “Yes”, 0 = “No”
\(v_j = \beta_1 x^\mathrm{price}\)
| Coef. | Interpretation |
|---|---|
| β1 | how utility changes with increasing price |
\(v_j = \beta_1 \delta^\mathrm{price = 20} + \beta_2 \delta^\mathrm{price = 30}\)
Reference level: price=10
| Coef. | Interpretation |
|---|---|
| β1 | utility for price=20 relative to price=10 |
| β2 | utility for price=30 relative to price=10 |
cbc_encode()Standard coding (human-readable)
Rule:
Use dummy_cols() for any data frame (simulated or from a file)
Use cbc_encode() to preview {cbcTools} designs, e.g. with a no choice option
Default: first level is the reference
\(v_j = \beta_1 \delta^\mathrm{hybrid} + \beta_2 \delta^\mathrm{electric}\)
| Coef. | Interpretation |
|---|---|
| β1 | utility of Hybrid relative to Gasoline |
| β2 | utility of Electric relative to Gasoline |
logitr-cars folder in Positron
code/3.1-model-mnl.R
20:00
data.csv file in the “data” folder, which contains choice observations from chocolate bars with the following attributes:| Attribute | Description |
|---|---|
price |
Price in $ |
percent_cacao |
% Cacao (how “dark” the chocolate is) |
crispy_rice |
0 or 1 for if the bar contains crispy rice |
brand |
“Hershey”, “Lindt”, or “Ghirardelli” |
\[u_j = \beta_1 x_j^{\mathrm{price}} + \beta_2 x_j^{\mathrm{\%cacao}} + \beta_3 \delta_j^{\mathrm{crispy}} + \beta_4 \delta_j^{\mathrm{hershey}} + \beta_5 \delta_j^{\mathrm{lindt}} + \varepsilon_j\]
05:00
logitr-cars folder in Positron
code/4.1-model-no_choice.R
The “no choice” rows have NA for every attribute
powertrain_NA = 1 on the no-choice rows. Do not include it in the model!
Choices according to assumed model
\(v_j = -0.7 x_j^{\mathrm{price}} + 0.1 x_j^{\mathrm{fuelEconomy}} - 0.2 x_j^{\mathrm{accelTime}} + 0.5 \delta_j^{\mathrm{hybrid}} - 4 \delta_j^{\mathrm{electric}}\)
cbc_suggest_priors() proposes a starting point based on your attribute levels
These are only a starting point:
\[v_j = \beta_1 x_j^{\mathrm{price}} + \beta_2 x_j^{\mathrm{fuelEconomy}} + \beta_3 x_j^{\mathrm{accelTime}} + \beta_4 \delta_j^{\mathrm{hybrid}} + \beta_5 \delta_j^{\mathrm{electric}}\]
20:00
Go back to your code from last week where you created your choice questions.
Write out a utility model for your project.
Write code to simulate data according to your utility model - pick some parameter values (see simulate-choices.R).
Write code to estimate a model using your simulated data.