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_valuesof an optimalMicroMoment.- Parameters
dataset (MicroDataset) – The
MicroDatasetfor which scores will be computed. Thecompute_weightsfunction is called separately for each observation \(n\).micro_data (structured array-like, optional) –
By default, each row in
Problem.agentsand each possible choice is treated as an observation \(n\). In this case,integrationshould generally be specified to define integration \(i \in I_n\) over unobserved heterogeneity.If
micro_datais specified, it should be of the form required byProblemResults.compute_micro_scores(), except withoutchoice_indicesorsecond_choice_indices, since scores will be computed for all choices.integration (Integration, optional) –
Integrationconfiguration 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 thedatasetto an array of scores for the corresponding parameter and market. The array’s dimensions correspond to the dimensions of the weights returned bycompute_weightspassed todataset. Note that it is possible for parameters inProblemResults.thetato mechanically have zero scores, for example if they are on a constant demographic.To build an optimal
MicroMomentthat matches the score for a parameter,compute_valuesin its singleMicroPartshould select the array corresponding to that parameter and the requested markett. Anynumpy.nanvalues in this array correspond to agent-choices that are assigned a probability of \(\mathscr{P}_n = 0\) by the sampling process defined bydataset, so should be replaced by some arbitrary number (e.g., by passing the array of scores throughnumpy.nan_to_num).- Return type
list