# pyblp.ProblemResults.compute_diversion_ratios¶

ProblemResults.compute_diversion_ratios(name='prices', market_id=None)

Estimate matrices of diversion ratios, $$\mathscr{D}$$, with respect to a variable, $$x$$.

For each market, the value in row $$j$$ and column $$k \neq j$$ is

(1)$\mathscr{D}_{jk} = -\frac{\partial s_k}{\partial x_j} \Big/ \frac{\partial s_j}{\partial x_j}.$

Diversion ratios for the outside good are reported on diagonals:

(2)$\mathscr{D}_{jj} = -\frac{\partial s_0}{\partial x_j} \Big/ \frac{\partial s_j}{\partial x_j}.$

Unlike ProblemResults.compute_long_run_diversion_ratios(), this gives the marginal treatment effect (MTE) version of the diversion ratio. For more information, see Conlon and Mortimer (2018).

Parameters
• name (str, optional) – Name of the variable, $$x$$. By default, $$x = p$$, prices.

• market_id (object, optional) – ID of the market in which to compute diversion ratios. By default, diversion ratios are computed in all markets and stacked.

Returns

Estimated $$J_t \times J_t$$ matrices of diversion ratios, $$\mathscr{D}$$. If market_id was not specified, matrices are estimated in each market $$t$$ and stacked. Columns for a market are in the same order as products for the market. If a market has fewer products than others, extra columns will contain numpy.nan.

Return type

ndarray

Examples