Practice Questions 1

Suppose we estimate the following utility model describing preferences for cars:

\[ \tilde{u}_j = \alpha p_j + \beta_1 x_j^{\mathrm{mpg}} + \beta_2 x_j^{\mathrm{elec}} + \varepsilon_j \]

where the variables are

  • \(p_j\): Price in USD $1,000
  • \(x_j^{\mathrm{mpg}}\): Fuel economy in miles per gallon
  • \(x_j^{\mathrm{elec}}\): Variable that takes 1 if the car is an electric car and 0 otherwise

The estimated model produces the following coefficients:

  • \(\alpha\): -0.7
  • \(\beta_1\): 0.1
  • \(\beta_2\): -4.0
  1. Use the estimated coefficients to compute the WTP for fuel economy and electric car vehicle type.
beta <- c(price = -0.7, mpg = 0.1, elec = -4.0)
wtp <- beta / (-1*beta[1])
wtp
#>      price        mpg       elec 
#> -1.0000000  0.1428571 -5.7142857
  1. Use the estimated coefficients to compute market shares for the alternatives in the following market:
alternative price mpg elec
1 15 20 0
2 30 100 1
3 20 40 0
X <- matrix(c(
    15, 20, 0,
    30, 100, 1,
    20, 40, 0),
    ncol = 3, byrow = TRUE)

v_j <- X %*% beta
exp_v_j <- exp(v_j)
P_j <- exp_v_j / sum(exp_v_j)
P_j
#>             [,1]
#> [1,] 0.816570769
#> [2,] 0.001227664
#> [3,] 0.182201566

Very few people will choose the electric vehicle (option 2). Most will choose the less expensive (and less fuel efficient) gasoline vehicle.

Practice Questions 2

Suppose we estimate the following utility model describing preferences for cars:

\[ \tilde{u}_j = \alpha p_j + \beta_1 x_j^{\mathrm{mpg}} + \beta_2 x_j^{\mathrm{elec}} + \varepsilon_j \]

where the variables are

  • \(p_j\): Price in USD $1,000
  • \(x_j^{\mathrm{mpg}}\): Fuel economy in miles per gallon
  • \(x_j^{\mathrm{elec}}\): Variable that takes 1 if the car is an electric car and 0 otherwise

The estimated model produces the following coefficients and hessian:

  • \(\alpha\): -0.7
  • \(\beta_1\): 0.1
  • \(\beta_2\): -4.0

\[ \nabla_{\beta}^2 \ln(\mathcal{L}) = \begin{bmatrix} -6000 & 50 & 60 \\ 50 & -700 & 50 \\ 60 & 50 & -300 \end{bmatrix} \]

  1. Generate 10,000 draws of the model coefficients using the estimated coefficients and hessian. Use the mvrnorm() function from the MASS library.
library(MASS)

beta <- c(price = -0.7, mpg = 0.1, elec=-4.0)
hessian <- matrix(c(
    -6000,   50,   60,
       50, -700,   50,
       60,   50, -300),
    ncol=3, byrow=T)

covariance <- -1*(solve(hessian))
draws <- mvrnorm(10^5, beta, covariance)
head(draws)
#>           price        mpg      elec
#> [1,] -0.7191424 0.06821708 -4.053404
#> [2,] -0.6973099 0.09142923 -3.990660
#> [3,] -0.6940185 0.06213294 -3.892560
#> [4,] -0.6919551 0.10085524 -4.084752
#> [5,] -0.7104872 0.09159229 -4.009056
#> [6,] -0.6680536 0.07860711 -3.903577
  1. Use the draws to compute the mean WTP and 95% confidence intervals of WTP for fuel economy and electric car vehicle type.
wtp_draws <- as.data.frame(draws[,2:3] / (-1*draws[,1]))
head(wtp_draws)
#>          mpg      elec
#> 1 0.09485893 -5.636441
#> 2 0.13111707 -5.722936
#> 3 0.08952634 -5.608726
#> 4 0.14575402 -5.903204
#> 5 0.12891476 -5.642686
#> 6 0.11766587 -5.843210
# Fuel economy:
mean(wtp_draws$mpg)
#> [1] 0.1426625
quantile(wtp_draws$mpg, c(0.025, 0.975))
#>       2.5%      97.5% 
#> 0.03647869 0.24936068
# Electric vehicle type:
mean(wtp_draws$elec)
#> [1] -5.716492
quantile(wtp_draws$elec, c(0.025, 0.975))
#>      2.5%     97.5% 
#> -5.979075 -5.464631
# Other approach, use the ci() function 
maddTools::ci(wtp_draws)
#>            mean       lower      upper
#> mpg   0.1426625  0.03647869  0.2493607
#> elec -5.7164918 -5.97907474 -5.4646309