pyblp.OptimizationProgress

class pyblp.OptimizationProgress

Information about the current progress of optimization.

They key attributes of this class needed to define a custom optimization routine are objective and gradient. Many other attributes of ProblemResults are also included, and can be used to help define an alternative optimization routine (e.g., Gauss-Newton), to debug issues, or to add custom ad-hoc moments to the configured problem.

problem

Problem that created this progress.

Type

Problem

fp_converged

Flags for convergence of the iteration routine used to compute \(\delta(\theta)\) in each market. Values are in the same order as Problem.unique_market_ids.

Type

ndarray

fp_iterations

Number of major iterations completed by the iteration routine used to compute \(\delta(\theta)\) in each market. Values are in the same order as Problem.unique_market_ids.

Type

ndarray

contraction_evaluations

Number of times the contraction used to compute \(\delta(\theta)\) was evaluated in each market. Values are in the same order as Problem.unique_market_ids.

Type

ndarray

theta

Unfixed parameters, \(\theta\), in the following order: \(\Sigma\), \(\Pi\), \(\rho\), non-concentrated out elements from \(\beta\), and non-concentrated out elements from \(\gamma\).

Type

ndarray

sigma

Cholesky root of the covariance matrix for unobserved taste heterogeneity, \(\Sigma\).

Type

ndarray

sigma_squared

Covariance matrix for unobserved taste heterogeneity, \(\Sigma\Sigma'\).

Type

ndarray

pi

Parameters that measures how agent tastes vary with demographics, \(\Pi\).

Type

ndarray

rho

Parameters that measure within nesting group correlations, \(\rho\).

Type

ndarray

beta

Demand-side linear parameters, \(\beta\).

Type

ndarray

gamma

Supply-side linear parameters, \(\gamma\).

Type

ndarray

sigma_bounds

Bounds for \(\Sigma\) that were used during optimization, which are of the form (lb, ub).

Type

tuple

pi_bounds

Bounds for \(\Pi\) that were used during optimization, which are of the form (lb, ub).

Type

tuple

rho_bounds

Bounds for \(\rho\) that were used during optimization, which are of the form (lb, ub).

Type

tuple

beta_bounds

Bounds for \(\beta\) that were used during optimization, which are of the form (lb, ub).

Type

tuple

gamma_bounds

Bounds for \(\gamma\) that were used during optimization, which are of the form (lb, ub).

Type

tuple

sigma_labels

Variable labels for rows and columns of \(\Sigma\), which are derived from the formulation for \(X_2\).

Type

list of str

pi_labels

Variable labels for columns of \(\Pi\), which are derived from the formulation for demographics.

Type

list of str

rho_labels

Variable labels for \(\rho\). If \(\rho\) is not a scalar, this is Problem.unique_nesting_ids.

Type

list of str

beta_labels

Variable labels for \(\beta\), which are derived from the formulation for \(X_1\).

Type

list of str

gamma_labels

Variable labels for \(\gamma\), which are derived from the formulation for \(X_3\).

Type

list of str

theta_labels

Variable labels for \(\theta\), which are derived from the above labels.

Type

list of str

delta

Mean utility, \(\delta(\theta)\).

Type

ndarray

clipped_shares

Vector of booleans indicating whether the associated simulated shares were clipped during the last fixed point iteration to compute \(\delta(\theta)\). All elements will be False if shares_bounds in Problem.solve() is disabled (by default shares are bounded from below by a small number to alleviate issues with underflow and negative shares).

Type

ndarray

tilde_costs

Estimated transformed marginal costs, \(\tilde{c}(\theta)\) from (9). If costs_bounds were specified in Problem.solve(), \(c\) may have been clipped.

Type

ndarray

clipped_costs

Vector of booleans indicating whether the associated marginal costs were clipped. All elements will be False if costs_bounds in Problem.solve() was not specified.

Type

ndarray

xi

Unobserved demand-side product characteristics, \(\xi(\theta)\), or equivalently, the demand-side structural error term. When there are demand-side fixed effects, this is \(\Delta\xi(\theta)\) in (32). That is, fixed effects are not included.

Type

ndarray

omega

Unobserved supply-side product characteristics, \(\omega(\theta)\), or equivalently, the supply-side structural error term. When there are supply-side fixed effects, this is \(\Delta\omega(\theta)\) in (32). That is, fixed effects are not included.

Type

ndarray

micro

Micro moments, \(\bar{g}_M\), in (34).

Type

ndarray

micro_values

Micro moment values, \(f_m(v)\). Rows are in the same order as ProblemResults.micro.

Type

ndarray

objective

GMM objective value, \(q(\theta)\), defined in (10). If scale_objective was True in Problem.solve() (which is the default), this value was scaled by \(N\) so that objective values are more comparable across different problem sizes. Note that in some of the BLP literature (and earlier versions of this package), this expression was previously scaled by \(N^2\).

Type

float

xi_by_theta_jacobian

\(\frac{\partial\xi}{\partial\theta} = \frac{\partial\delta}{\partial\theta}\).

Type

ndarray

omega_by_theta_jacobian

\(\frac{\partial\omega}{\partial\theta} = \frac{\partial\tilde{c}}{\partial\theta}\).

Type

ndarray

micro_by_theta_jacobian

\(\frac{\partial\bar{g}_M}{\partial\theta}\).

Type

ndarray

gradient

Gradient of the GMM objective, \(\nabla q(\theta)\), defined in (18).

Type

ndarray

projected_gradient

Projected gradient of the GMM objective. When there are no parameter bounds, this will always be equal to ProblemResults.gradient. Otherwise, if an element in \(\hat{\theta}\) is equal to its lower (upper) bound, the corresponding projected gradient value will be truncated at a maximum (minimum) of zero.

Type

ndarray

projected_gradient_norm

Infinity norm of ProblemResults.projected_gradient.

Type

ndarray

W

Weighting matrix, \(W\), used to compute these results.

Type

ndarray

Methods