Skip to content

hierarchicalforecast/mintrace-without-insample

Rule mintrace-without-insample
Pack HierarchicalForecast
Severity error
Fix none, edit by hand
Library versions every version

MinTrace(method="mint_shrink") estimates forecast error covariance from in-sample residuals. Give reconcile the historical targets and the fitted predictions of the base models.

reconciliation = HierarchicalReconciliation(reconcilers=[MinTrace(method="mint_shrink")])
forecasts = reconciliation.reconcile(Y_hat_df=base, S_df=summing, tags=tags)
forecasts = reconciliation.reconcile(Y_hat_df=base, S_df=summing, tags=tags, Y_df=fitted)

The rule looks for a literal MinTrace("mint_shrink") in the list or tuple of reconcilers, either in a constructor chained to reconcile or assigned on the previous statement. It reports a missing Y_df or an explicit Y_df=None when no positional argument or unpacked options could supply it. Temporal reconciliation has different requirements and is outside this check.

HierarchicalForecast 1.5.3 raised ValueError asking for Y_df. With fitted values from StatsForecast, the reconciled total equaled the sum of two leaves on all seven forecast dates. See the reconciliation API and worked example.

Fit the base models on the training set and pass a frame with one row per series and training time, the actual target, and a fitted column for each base model. For StatsForecast, call forecast(..., fitted=True) and then forecast_fitted_values(). xpd has no automatic fix.

xpd prints this message with the issue. A name that starts with $ stands for code from your file.

This MinTrace method needs in-sample residuals to estimate forecast error covariance. Pass Y_df with the observed targets and the fitted values of the base models.

Browse the other rules of the HierarchicalForecast pack.