pyblp.ProblemResults.compute_consumer_surpluses¶

ProblemResults.
compute_consumer_surpluses
(prices=None, market_id=None, keep_all=False)¶ Estimate populationnormalized consumer surpluses, \(\text{CS}\).
Assuming away nonlinear income effects, the surplus in market \(t\) is
(1)¶\[\text{CS} = \sum_{i \in I_t} w_{it}\text{CS}_{it},\]in which the consumer surplus for individual \(i\) is
(2)¶\[\text{CS}_{it} = \log\left(1 + \sum_{j \in J_t} \exp V_{ijt}\right) \Big/ \left(\frac{\partial V_{i1t}}{\partial p_{1t}}\right),\]or with nesting parameters,
(3)¶\[\text{CS}_{it} = \log\left(1 + \sum_{h \in H} \exp V_{iht}\right) \Big/ \left(\frac{\partial V_{i1t}}{\partial p_{1t}}\right)\]where \(V_{ijt}\) is defined in (1) and \(V_{iht}\) is defined in (38).
Warning
\(\frac{\partial V_{1ti}}{\partial p_{1t}}\) is the derivative of utility for the first product with respect to its price. The first product is chosen arbitrarily because this method assumes that there are no nonlinear income effects, which implies that this derivative is the same for all products. Computed consumer surpluses will likely be incorrect if prices are formulated in a nonlinear fashion like
log(prices)
. Parameters
prices (arraylike, optional) – Prices at which utilities and price derivatives will be evaluated, such as equilibrium prices, \(p^*\), computed by
ProblemResults.compute_prices()
. By default, unchanged prices are used.market_id (object, optional) – ID of the market in which to compute consumer surplus. By default, consumer surpluses are computed in all markets and stacked.
keep_all (bool, optional) – Whether to keep all individuals’ surpluses \(\text{CS}_{it}\) or just marketlevel surpluses. By default only marketlevel surpluses are returned, but returning all surpluses will be important for analysis by agent type or demographic category.
 Returns
Estimated populationnormalized consumer surpluses, \(\text{CS}\) (or individuals’ surpluses if
keep_all
isTrue
). Ifmarket_ids
was not specified, rows are in the same order asProblem.unique_market_ids
. Ifkeep_all
isTrue
, columns for a market are in the same order as agents for the market. If a market has fewer agents than others, extra columns will containnumpy.nan
. Return type
ndarray
Examples