Nixtla/hierarchicalforecast

Exception: min_trace (wls_var) needs covariance matrix to be positive definite.

Closed this issue · 6 comments

What happened + What you expected to happen

All min_trace methods are throwing this issue for me

Versions / Dependencies

Latest version : 202307

Reproduction script

  reconcilers = [BottomUp() , MinTrace(method="wls_var")]

  hrec = HierarchicalReconciliation(reconcilers=reconcilers)

Issue Severity

High: It blocks me from completing my task.

Hey @vinaybridge,

You can use MinTrace's mint_shr_ridge parameter to help with the invertibility of the covariance matrix:
https://nixtla.github.io/hierarchicalforecast/methods.html#mintrace

Another strategy to improve the covariance's invertibility is to use a bit of random noise in the series.
See the FavoritaHierarchicalDataset.load_item_data normal noise example:
https://github.com/Nixtla/hierarchicalforecast/blob/main/experiments/hierarchical_baselines/nbs/run_favorita_baselines.ipynb

Hi @kdgutier , Thank you for possible solution. I have tried MinTrace(method="mint_shrink",nonnegative=True) but it is running very slower than "OLS" , so how to speed up it ?
Any idea

MinTraceSparse might be already available if you install hierarchicalforecast from github main:

!pip install git+https://github.com/Nixtla/hierarchicalforecast.git

Not able to import it, Can you share template code for MinTraceSparse ?

Installed package from

!pip install git+https://github.com/Nixtla/hierarchicalforecast.git

image

I recommend you start a new conda or pip virtual environment.
Alternatively, you can try to upgrade the package

!pip install --upgrade git+https://github.com/Nixtla/hierarchicalforecast.git