# Derivatives of Nested Logit Demand function

I have the following function (from economics, the nested logit demand model).

$$q_i(p)= \frac{\exp\left[\frac{\delta_i - bp_i}{\lambda}\right]\left(\sum_{j \in V_i}\exp\left[\frac{\delta_j - bp_j}{\lambda}\right]\right)^{\lambda-1}}{1 + \left(\sum_{j \in V_i}\exp\left[\frac{\delta_j - bp_j}{\lambda}\right]\right)^{\lambda} + \left(\sum_{l \in V_{-i}}\exp\left[\frac{\delta_l - bp_l}{\lambda}\right]\right)^{\lambda}}$$

$p$ and $\delta$ are vectors of length $I$, measuring the price and quality of each product $i$ according to the subscript. $V_i$ is set of products in the same group as product $i$, whilst $V_{-i}$ is all products in the other group (all products must fall in one group of the other). $b >0$ and $p_i > 0, \delta_i > 0, \forall i$, whilst $\lambda \in [0.5,1]$.

How do I find the three derivatives $\dfrac{\partial q_i(p)}{\partial p_i}$, $\dfrac{\partial q_i(p)}{\partial p_j}, j \in V_i$ and $\dfrac{\partial q_i(p)}{\partial p_k}, k \in V_{-i}$? I find it hard to compute this because the sums are raised to the power, and so it becomes very messy, although there may be a trick that makes this simpler.

There is a trick involving decomposing the choice probability of a nested logit model. Have a look at Train 2009, Ch. 4 p. 86. In short, using Train's notation, the probability of individual $n$ choosing product $i$ in nest $B_k$ can be expressed as:

$P_{ni} = P_{ni | B_k} P_{n B_k}$

That is, the choice probability is the probability of choosing product $i$ given that nest $B_k$ is chosen times the probability of choosing nest $B_k$. These probabilities are (see derivation in the reference):

$P_{ni | B_k} = \dfrac{e^{Y_{ni}/\lambda_k}}{\sum_{j \in B_k} e^{Y_{ni}/\lambda_k} }$

$P_{nB_k} = \dfrac{e^{W_{nk} + \lambda_k I_{nk}}}{\sum^K_{l=1} e^{W_{nk} + \lambda_k I_{nk}}}$

where $I_{nk} = ln \sum_{j \in B_k} e^{Y_{nj}/\lambda_k}$ is the inclusive value from choosing nest $B_k$.

As you can see, these probabilities do not involve exponents over the summation terms, and finding price derivatives is now a much simpler exercise.