pyblp.ProblemResults.compute_agent_scores¶
-
ProblemResults.
compute_agent_scores
(dataset, micro_data=None, integration=None)¶ Compute scores for all agent-choices, treated as observations \(n \in N_d\) from a micro dataset \(d\).
This method is the same as
ProblemResults.compute_micro_scores()
, except it computes scores for all possible choices of allProblem.agents
. Each agent-choice is treated as a separate observation \(n\). Instead of returning an array, this method returns a mapping from market IDs to scores, to facilitate use bycompute_values
of an optimalMicroMoment
.- Parameters
dataset (MicroDataset) – The
MicroDataset
for which scores will be computed. Thecompute_weights
function is called separately for each observation \(n\).micro_data (structured array-like, optional) –
By default, each row in
Problem.agents
and each possible choice is treated as an observation \(n\). In this case,integration
should generally be specified to define integration \(i \in I_n\) over unobserved heterogeneity.If
micro_data
is specified, it should be of the form required byProblemResults.compute_micro_scores()
, except withoutchoice_indices
orsecond_choice_indices
, since scores will be computed for all choices.integration (Integration, optional) –
Integration
configuration of the form required byProblemResults.compute_micro_scores()
.
- Returns
Scores \(\mathscr{S}_n\). The list is in the same order as
ProblemResults.theta
(also seeProblemResults.theta_labels
). Each element of the list is a mapping from market IDs supported by thedataset
to an array of scores for the corresponding parameter and market. The array’s dimensions correspond to the dimensions of the weights returned bycompute_weights
passed todataset
. Note that it is possible for parameters inProblemResults.theta
to mechanically have zero scores, for example if they are on a constant demographic.To build an optimal
MicroMoment
that matches the score for a parameter,compute_values
in its singleMicroPart
should select the array corresponding to that parameter and the requested markett
. Anynumpy.nan` values in this array correspond to agent-choices that are assigned a probability of :math:`\mathscr{P}_n = 0` by the sampling process defined by ``dataset
, so should be replaced by some arbitrary number (e.g., by passing the array of scores throughnumpy.nan_to_num
).- Return type
list