Skip to content

Commit

Permalink
Change VAR to throw error when it can't estimate model parameters.
Browse files Browse the repository at this point in the history
  • Loading branch information
djpasseyjr committed Nov 5, 2024
1 parent 51be058 commit 8c6bbdc
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions interfere/_methods/vector_autoregression.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,14 @@ def _fit(
ntrend = len(trend) if trend.startswith("c") else 0
max_estimable_lags = (self.var.n_totobs - self.var.neqs - ntrend) // (1 + self.var.neqs)
maxlags = min(self.method_params["maxlags"], max_estimable_lags)
if maxlags < 0:
raise ValueError(
"Not enough data to estimate VAR model parameters for any "
"number of lags."
f"\n\t Trend equations: {ntrend}"
f"\n\t AR equations: {self.var.neqs}"
f"\n\t Observations: {self.var.n_totobs}"
)

self.results = self.var.fit(
maxlags=maxlags,
Expand Down

0 comments on commit 8c6bbdc

Please sign in to comment.