I have the following simulation problem:
Consumers, whose utility I know, go shopping for two goods. However, prices differ each time they visit a shop. Therefore, these consumers always purchase accordingly to their relevant current budget constraints and utility functions. This gives me data for purchased quantities and corresponding prices.
Few assumptions:
- The utility is given by CES.
- Utility per consumer is stable over time.
- Neither perfect complements nor perfect substitutes.
- Coefficients for elasticity of substitution differ for consumers.
What I want to figure out from this data is the coefficient of elasticity of substitution. I tried to simulate for 1000 iterations, regress accordingly, but the results are wrong/biased.
My approach:
The problem is the following:
$$ \max_{\boldsymbol{x}} U_{i}(\boldsymbol{x}) = \left( \alpha_1 x_1^{\rho_{i}} + \alpha_2 x_2^{\rho_{i}} \right)^{\frac{1}{\rho_{i}}} \qquad s.t. \qquad P_1 x_1 + P_2 x_2 \leq M $$
Where we expect the $\rho_i$ to differ for each consumer.
I know how to compute elasticity of substitution:
$$\sigma_{ij} = \frac{\frac{\partial (x_j/x_i)}{x_j/x_i}}{\frac{\partial MRS_{ij}}{MRS_{ij}}}$$
Where $MRS_{ij} = MU_i/MU_j$.
Then, I know the main optimization condition from Lagrangian:
$$\frac{MU_i}{MU_j} = \frac{P_i}{P_j}$$
Therefore, I can plug this into the elasticity of substitution, obtaining:
$$ \sigma_{ij} = \frac{\frac{\partial (x_j/x_i)}{x_j/x_i}}{\frac{\partial P_i/P_j}{P_i/P_j}} $$
This can be rewritten in logarithmic and regression terms as:
$$\ln \left( \frac{x_j}{x_i} \right) = \sigma_{ij} \ln \left( \frac{P_i}{P_j} \right) + \epsilon$$
I know the analytic solution for this optimization problem (see code below), so I can compute the optimal purchased quantity for each consumer. I simulate prices, assuming both consumers go into the shop each day (during the day, prices are the same). Then, consumers perform their choice... I observe these choices and apply the regression equation above. However, the results are weird...
I was expecting the $\hat{\sigma_{i,j}}$ to be close to $1/(1-mean(\rho))$, however, in reality, the bigger the difference between $\rho_1$ and $\rho_2$ the bigger and more positive is the bias. It is essential to add that it gives precise results, when both parameters $\rho_1 = \rho_2$.
Now the question is: Why are those results biased? Why is the bias positive the bigger is the difference between both real elasticities? Why do I not get some mean value of elasticity of substitution? And how to properly estimate it?
The code in R used for simulation:
CES_2x_analythic = function(a1, a2, rho, P1, P2, M) {
sc_factor = ((a2/a1)*(P1/P2))^(1/(rho-1))
x1 = M/(P1+P2*(1/sc_factor))
x2 = M/(P1*sc_factor + P2)
return(c(x1, x2))
}
multicust_2goods = function(a1 = 1, a2 = 2, rho,
M = 100, n_iter = 1000) {
n_cust = length(rho)
P1 = runif(n_iter, 1, 4)
P1 = P1[rep(1:n_iter, rep(n_cust, n_iter))]
P2 = runif(n_iter, 1, 4)
P2 = P2[rep(1:n_iter, rep(n_cust, n_iter))]
rho = rho[rep(1:n_cust, n_iter)]
mean_rho = mean(rho)
mean_eos = 1/(1-mean_rho)
print(mean_eos)
vys = matrix(NA, nrow = n_iter*n_cust, ncol = 2)
vys_teor = matrix(NA, nrow = n_iter*n_cust, ncol = 2)
for (i in 1:n_iter) {
vys[i,] = CES_2x_analythic(a1 = a1, a2 = a2, rho = rho[i],
P1 = P1[i], P2 = P2[i], M = M)
vys_teor[i,] = CES_2x_analythic(a1 = a1, a2 = a2, rho = mean_rho,
P1 = P1[i], P2 = P2[i], M = M)
}
ln_goods = log(vys[,2]/vys[,1])
ln_prices = log(P1/P2)
OLS = lm(ln_goods ~ ln_prices -1)
ln_g = log(vys_teor[,2]/vys_teor[,1])
ln_p = log(P1/P2)
OLS_teor = lm(ln_g ~ ln_p -1)
return(rbind(coef(OLS), coef(OLS_teor)) )
}
multicust_2goods(rho = c(-0.5,+0.5), n_iter = 1000)
Thank you very much!