# pyblp.Simulation.replace_endogenous¶

Simulation.replace_endogenous(costs=None, prices=None, iteration=None, error_behavior='raise')

Replace simulated prices and market shares with equilibrium values that are consistent with true parameters.

This method is the standard way of solving the simulation. Prices and market shares are computed in each market by iterating over the $$\zeta$$-markup contraction in (46):

(1)$p \leftarrow c + \zeta(p).$

Note

To not replace prices, pass the desired prices to prices and use an Iteration configuration with method='return'. This just uses the iteration “routine” that simply returns the the starting values, which are prices.

Using this same fake iteration routine and not setting prices will result in a simulation under perfect (instead of Bertrand) competition because the default starting values for the iteration routine are marginal costs.

Note

This method supports parallel() processing. If multiprocessing is used, market-by-market computation of prices and shares will be distributed among the processes.

Parameters
• costs (array-like, optional) – Marginal costs, $$c$$. By default, $$c = X_3\gamma + \omega$$ if costs_type was 'linear' in Simulation (the default), and the exponential of this if it was 'log'. Marginal costs must be specified if $$X_3$$ was not formulated in Simulation. If marginal costs depend on prices through market shares, they will be updated to reflect different prices during each iteration of the routine.

• prices (array-like, optional) – Prices at which the fixed point iteration routine will start. By default, costs, are used as starting values.

• iteration (Iteration, optional) – Iteration configuration for how to solve the fixed point problem. By default, Iteration('simple', {'atol': 1e-12}) is used. Analytic Jacobians are not supported for solving this system.

• error_behavior (str, optional) –

How to handle errors when computing prices and shares. For example, the fixed point routine may not converge if the effects of nonlinear parameters on price overwhelm the linear parameter on price, which should be sufficiently negative. The following behaviors are supported:

• 'raise' (default) - Raise an exception.

• 'warn' - Use the last computed prices and shares. If the fixed point routine fails to converge, these are the last prices and shares computed by the routine. If there are other issues, these are the starting prices and their associated shares.

Returns

SimulationResults of the solved simulation.

Return type

SimulationResults

Examples