Skip to content

Commit

Permalink
Revert "BUG/TST: use correct expression for nested logit second choic…
Browse files Browse the repository at this point in the history
…e probabilities"

This reverts commit 5e35845.
  • Loading branch information
chrisconlon committed Dec 7, 2022
1 parent 7bf45be commit 5c8f40b
Show file tree
Hide file tree
Showing 7 changed files with 112 additions and 356 deletions.
4 changes: 2 additions & 2 deletions docs/background.rst
Original file line number Diff line number Diff line change
Expand Up @@ -295,9 +295,9 @@ Micro moment parts based on second choice are averages over values :math:`v_{pij

Its simulated analogue is

.. math:: v_p = \frac{\sum_{t \in T} \sum_{i \in I_t} \sum_{j, k \in J_t \cup \{0\}} w_{it} s_{ijt} s_{ik(-j)t} w_{d_pijkt} v_{pijkt}}{\sum_{t \in T} \sum_{i \in I_t} \sum_{j, k \in J_t \cup \{0\}} w_{it} s_{ijt} s_{ik(-j)t} w_{d_pijkt}}.
.. math:: v_p = \frac{\sum_{t \in T} \sum_{i \in I_t} \sum_{j, k \in J_t \cup \{0\}} w_{it} s_{ijt} s_{ik(-j)t} w_{d_pijkt} v_{pijkt}}{\sum_{t \in T} \sum_{i \in I_t} \sum_{j, k \in J_t \cup \{0\}} w_{it} s_{ijt} s_{ik(-j)t} w_{d_pijkt}},

Covariances are defined analogously.
in which second choice probabilities are :math:`s_{ik(-j)t} = \frac{s_{ikt}}{1 - s_{ijt}}` if :math:`k \neq j` and zero if :math:`k = j`. Covariances are defined analogously.


Random Coefficients Nested Logit
Expand Down
1 change: 0 additions & 1 deletion docs/testing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ The full suite of tests also requires installation of the following software:

- `Artleys Knitro <https://www.artelys.com/solvers/knitro/>`_ version 10.3 or newer: testing optimization routines.
- `MATLAB <https://www.mathworks.com/products/matlab.html>`_: comparing sparse grids with those created by the function `nwspgr <http://www.sparse-grids.de/>`_ created by Florian Heiss and Viktor Winschel, which must be included in a directory on the MATLAB path.
- `R <https://www.r-project.org/>`_: simulating nested logit errors created by the package `evd <https://cran.r-project.org/web/packages/evd/index.html>`_ created by Alec Stephenson, which must be installed.

If software is not installed, its associated tests will be skipped. Additionally, some tests that require support for extended precision will be skipped if on the platform running the tests, ``numpy.longdouble`` has the same precision as ``numpy.float64``. This tends to be the case on Windows.

Expand Down
8 changes: 4 additions & 4 deletions pyblp/markets/economy_results_market.py
Original file line number Diff line number Diff line change
Expand Up @@ -443,8 +443,8 @@ def safely_compute_score_denominator_contributions(
micro_chunks = self.generate_micro_chunks(probabilities, probabilities_tangent_mapping)
for agent_indices, probabilities_chunk, probabilities_tangent_mapping_chunk in micro_chunks:
_, denominator_mapping_chunk, _, tangent_mapping_chunk = self.compute_micro_dataset_contributions(
[dataset], self.delta, probabilities_chunk, probabilities_tangent_mapping_chunk, xi_jacobian,
compute_jacobians=True, agent_indices=agent_indices
[dataset], self.delta, probabilities_chunk, probabilities_tangent_mapping_chunk, compute_jacobians=True,
agent_indices=agent_indices
)
if dataset in denominator_mapping_chunk:
denominator += denominator_mapping_chunk[dataset]
Expand Down Expand Up @@ -474,8 +474,8 @@ def safely_compute_score_numerator_contributions(
micro_chunks = self.generate_micro_chunks(probabilities, probabilities_tangent_mapping)
for agent_indices, probabilities_chunk, probabilities_tangent_mapping_chunk in micro_chunks:
weights_mapping_chunk, _, tangent_mapping_chunk, _ = self.compute_micro_dataset_contributions(
[dataset], self.delta, probabilities_chunk, probabilities_tangent_mapping_chunk, xi_jacobian,
compute_jacobians=True, agent_indices=agent_indices
[dataset], self.delta, probabilities_chunk, probabilities_tangent_mapping_chunk, compute_jacobians=True,
agent_indices=agent_indices
)
if dataset in weights_mapping_chunk:
weights_chunk = weights_mapping_chunk[dataset]
Expand Down

0 comments on commit 5c8f40b

Please sign in to comment.