pyblp.ProblemResults.importance_sampling¶
-
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_dataand/orintegrationare 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 estimatedProblemResults.delta. 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
drawsare 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
drawsagents 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}}\).- Parameters
draws (int, optional) – Number of draws to take from
sampling_agent_datain 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.RandomStateto 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_datainProblem. Theweightsfield 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) –
Integrationconfiguration for how to build nodes from which draws will be sampled, which will replace anynodesfield insampling_agent_data. This configuration is required ifsampling_agent_datais specified without anodesfield.delta (array-like, optional) – More precise \(\delta(\hat{\theta})\) than the estimated
ProblemResults.delta, which can be computed by passing a more precise integration rule toProblemResults.compute_delta(). By default,ProblemResults.deltais used.
- Returns
Computed
ImportanceSamplingResults.- Return type
ImportanceSamplingResults
Examples