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
The estimated model produces the following coefficients:
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
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.
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
The estimated model produces the following coefficients and hessian:
\[ \nabla_{\beta}^2 \ln(\mathcal{L}) = \begin{bmatrix} -6000 & 50 & 60 \\ 50 & -700 & 50 \\ 60 & 50 & -300 \end{bmatrix} \]
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.7286497 0.10451394 -4.064856
#> [2,] -0.6842361 0.08717615 -3.948952
#> [3,] -0.6827557 0.07328742 -3.989380
#> [4,] -0.7039099 0.09308334 -3.942283
#> [5,] -0.6793988 0.11220360 -4.009691
#> [6,] -0.6902164 0.06530339 -4.042897
wtp_draws <- as.data.frame(draws[,2:3] / (-1*draws[,1]))
head(wtp_draws)
#> mpg elec
#> 1 0.14343509 -5.578614
#> 2 0.12740654 -5.771329
#> 3 0.10734061 -5.843056
#> 4 0.13223759 -5.600551
#> 5 0.16515131 -5.901822
#> 6 0.09461293 -5.857435
# Fuel economy:
mean(wtp_draws$mpg)
#> [1] 0.1430632
quantile(wtp_draws$mpg, c(0.025, 0.975))
#> 2.5% 97.5%
#> 0.03653376 0.25022657
# Electric vehicle type:
mean(wtp_draws$elec)
#> [1] -5.716113
quantile(wtp_draws$elec, c(0.025, 0.975))
#> 2.5% 97.5%
#> -5.977965 -5.465227
# Other approach, use the ci() function
maddTools::ci(wtp_draws)
#> mean lower upper
#> mpg 0.1430632 0.03653376 0.2502266
#> elec -5.7161128 -5.97796522 -5.4652268