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 all Problem.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 by compute_values of an optimal MicroMoment.

Parameters
  • dataset (MicroDataset) – The MicroDataset for which scores will be computed. The compute_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 by ProblemResults.compute_micro_scores(), except without choice_indices or second_choice_indices, since scores will be computed for all choices.

  • integration (Integration, optional) – Integration configuration of the form required by ProblemResults.compute_micro_scores().

Returns

Scores \(\mathscr{S}_n\). The list is in the same order as ProblemResults.theta (also see ProblemResults.theta_labels). Each element of the list is a mapping from market IDs supported by the dataset to an array of scores for the corresponding parameter and market. The array’s dimensions correspond to the dimensions of the weights returned by compute_weights passed to dataset. Note that it is possible for parameters in ProblemResults.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 single MicroPart should select the array corresponding to that parameter and the requested market t. Any numpy.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 through numpy.nan_to_num).

Return type

list