pyblp.ProblemResults.simulate_micro_data¶
-
ProblemResults.
simulate_micro_data
(dataset, seed=None)¶ Simulate observations \(n \in N_d\) from a micro dataset \(d\).
Each micro observation \(n\) underlying the dataset \(d\) is simulated according to agent weights \(w_{it}\), choice probabilities \(s_{ijt}\), and survey weights \(w_{dijt}\).
- Parameters
dataset (MicroDataset) – The
MicroDataset
for which micro data will be simulated.seed (int, optional) – Passed to
numpy.random.RandomState
to seed the random number generator before data are simulated. By default, a seed is not passed to the random number generator.
- Returns
Micro data with as many rows as
observations
passed to thedataset
. Fields:micro_ids : (object) - IDs corresponding to observations \(n\).
market_ids : (object) - Market IDs \(t_n\) for each observation \(n\).
agent_indices : (int) - Within-market indices of agents \(i_n\) that take on values from \(0\) to \(I_t - 1\).
choice_indices : (int) - Within-market indices of simulated choices \(j_n\). If
compute_weights
passed to thedataset
returns an array with \(J_t\) elements in its second axis, then choice indices take on values from \(0\) to \(J_t - 1\) where \(0\) corresponds to the first inside good. If it returns an array with \(1 + J_t\) elements in its second axis, then choice indices take on values from \(0\) to \(J_t\) where \(0\) corresponds to the outside good.
If the
dataset
is configured to support second choice data, second choices will also be simulated:second_choice_indices : (int) - Within-market indices of simulated second choices \(k_n\). If
compute_weights
passed to thedataset
returns an array with \(J_t\) elements in its third axis, then second choice indices take on values from \(0\) to \(J_t - 1\) where \(0\) corresponds to the first inside good. If it returns an array with \(1 + J_t\) elements in its third axis, then second choice indices take on values from \(0\) to \(J_t\) where \(0\) corresponds to the outside good.
Integration nodes and demographics can be merged in on the
market_ids
andagent_indices
fields. Product characteristics can be merged in on themarket_ids
andchoice_indices
fields. Product characteristics of any second choices can be merged in on themarket_ids
andsecond_choice_indices
fields.- Return type
recarray
Examples