Skip to content

Commit

Permalink
BUG: fix collinearity message when instruments were manually specified
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffgortmaker committed Jan 29, 2022
1 parent 33ad24d commit 46ad949
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions pyblp/economies/economy.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ def _format_formulations(self) -> str:

return format_table(header, *data, title="Formulations")

def _detect_collinearity(self) -> None:
def _detect_collinearity(self, added_exogenous: bool) -> None:
"""Detect any collinearity issues in product data matrices."""

# skip collinearity checking when it is disabled via zero tolerances
Expand All @@ -175,8 +175,8 @@ def _detect_collinearity(self) -> None:
'X1': [str(f) for f in self._X1_formulations],
'X2': [str(f) for f in self._X2_formulations],
'X3': [str(f) for f in self._X3_formulations],
'ZD': [str(f) for f in self._X1_formulations if 'prices' not in f.names],
'ZS': [str(f) for f in self._X3_formulations]
'ZD': [str(f) for f in self._X1_formulations if 'prices' not in f.names] if added_exogenous else [],
'ZS': [str(f) for f in self._X3_formulations] if added_exogenous else [],
}
matrix_labels.update({
'ZD': [f'demand_instruments{i}' for i in range(self.MD - len(matrix_labels['ZD']))] + matrix_labels['ZD'],
Expand Down
4 changes: 2 additions & 2 deletions pyblp/economies/problem.py
Original file line number Diff line number Diff line change
Expand Up @@ -1346,7 +1346,7 @@ def __init__(
self._handle_errors(ZS_errors)

# detect any problems with the product data
self._detect_collinearity()
self._detect_collinearity(add_exogenous)

# output information about the initialized problem
output(f"Initialized the problem after {format_seconds(time.time() - start_time)}.")
Expand Down Expand Up @@ -1406,7 +1406,7 @@ def __init__(self, problem: ProblemEconomy, demand_instruments: Array, supply_in
raise exceptions.MultipleErrors(ZS_errors)

# detect any collinearity issues with the updated instruments
self._detect_collinearity()
self._detect_collinearity(added_exogenous=True)

# output information about the re-created problem
output(f"Re-created the problem after {format_seconds(time.time() - start_time)}.")
Expand Down

0 comments on commit 46ad949

Please sign in to comment.