ProblemResults.importance_sampling(draws, ar_constant=1.0, seed=None, agent_data=None, integration=None, delta=None)

Use importance sampling to construct nodes and weights for integration.

Importance sampling is done with the accept/reject procedure of Berry, Levinsohn, and Pakes (1995). First, agent_data and/or integration are used to provide a large number of candidate sampling nodes \(\nu\) and any demographics \(d\).

Out of these candidate agent data, each candidate agent \(i\) in market \(t\) is accepted with probability \(\frac{1 - s_{i0t}}{M}\) where \(M \geq 1\) is some accept-reject constant. The probability of choosing an inside good \(1 - s_{i0t}\), is evaluated at the estimated \(\hat{\theta}\) and \(\delta(\hat{\theta})\).

Optionally, ProblemResults.compute_delta() can be used to provide a more precise \(\delta(\hat{\theta})\) than the estimated The idea is that more precise agent data (i.e., more integration nodes) would be infeasible to use during estimation, but is feasible here because \(\delta(\hat{\theta})\) only needs to be computed once given a \(\hat{\theta}\).

Out of the remaining accepted agents, \(I_t\) equal to draws are randomly selected within each market \(t\) and assigned integration weights \(w_{it} = \frac{1}{I_t} \cdot \frac{1 - s_{0t}}{1 - s_{i0t}}\).

If this procedure accepts fewer than draws agents in a market, an exception will be raised. A good rule of thumb is to provide more candidate draws in each market than \(\frac{M \times I_t}{1 - s_{0t}}\).

  • draws (int, optional) – Number of draws to take from sampling_agent_data in each market.

  • ar_constant (float, optional) – Accept/reject constant \(M \geq 1\), which is by default, 1.0.

  • seed (int, optional) – Passed to numpy.random.RandomState to seed the random number generator before importance sampling is done. By default, a seed is not passed to the random number generator.

  • agent_data (structured array-like, optional) – Agent data from which draws will be sampled, which should have the same structure as agent_data in Problem. The weights field does not need to be specified, and if it is specified it will be ignored. By default, the same agent data used to solve the problem will be used.

  • integration (Integration, optional) – Integration configuration for how to build nodes from which draws will be sampled, which will replace any nodes field in sampling_agent_data. This configuration is required if sampling_agent_data is specified without a nodes field.

  • delta (array-like, optional) – More precise \(\delta(\hat{\theta})\) than the estimated, which can be computed by passing a more precise integration rule to ProblemResults.compute_delta(). By default, is used.


Computed ImportanceSamplingResults.

Return type