pyblp.ProblemResults.bootstrap

ProblemResults.bootstrap(draws=1000, seed=None, iteration=None, constant_costs=True)

Use a parametric bootstrap to create an empirical distribution of results.

The constructed BootstrappedResults can be used just like ProblemResults to compute various post-estimation outputs for different markets. The only difference is that BootstrappedResults methods return arrays with an extra first dimension, along which bootstrapped results are stacked. These stacked results can be used to construct, for example, confidence intervals for post-estimation outputs.

For each bootstrap draw, parameters are drawn from the estimated multivariate normal distribution of all parameters defined by ProblemResults.parameters and ProblemResults.parameter_covariances (where the second covariance matrix is divided by \(N\)). Any bounds configured in Problem.solve() will also bound parameter draws. Each parameter draw is used to compute the implied mean utility, \(\delta\), and shares, \(s\). If a supply side was estimated, the implied marginal costs, \(c\), and prices, \(p\), are computed as well by iterating over the \(\zeta\)-markup contraction in (52). If marginal costs depend on prices through market shares, they will be updated to reflect different prices during each iteration of the routine.

Note

By default, parametric bootstrapping may use a lot of memory. This is because all bootstrapped results (for all draws) are stored in memory at the same time. Memory usage can be reduced by calling this method in a loop with draws = 1. In each iteration of the loop, compute the desired post-estimation output with the proper method of the returned BootstrappedResults class and store these outputs.

Parameters
  • draws (int, optional) – The number of draws that will be taken from the joint distribution of the parameters. The default value is 1000.

  • seed (int, optional) – Passed to numpy.random.RandomState to seed the random number generator before any draws are taken. By default, a seed is not passed to the random number generator.

  • iteration (Iteration, optional) – Iteration configuration used to compute bootstrapped prices by iterating over the \(\zeta\)-markup equation in (52). By default, if a supply side was estimated, this is Iteration('simple', {'atol': 1e-12}). Analytic Jacobians are not supported for solving this system. This configuration is not used if a supply side was not estimated.

  • constant_costs (bool, optional) – Whether to assume that marginal costs, \(c\), remain constant as equilibrium prices and shares change. By default this is True, which means that firms treat marginal costs as constant when setting prices. If set to False, marginal costs will be allowed to adjust if shares was included in the formulation for \(X_3\) in Problem. This is not relevant if a supply side was not estimated.

Returns

Computed BootstrappedResults.

Return type

BootstrappedResults

Examples