diff --git a/src/connectedness/mhar.py b/src/connectedness/mhar.py index 01b3afc..095350c 100644 --- a/src/connectedness/mhar.py +++ b/src/connectedness/mhar.py @@ -152,7 +152,7 @@ def fit_mhar_fixed_alpha( bd, bw, bm = np.split(model.coef_, 3, axis=1) phi1 = bd + bw / cfg.weekly_window + bm / cfg.monthly_window residuals = Y - (X @ model.coef_.T + model.intercept_) - sigma = np.cov(residuals.T) + sigma = residuals.T @ residuals / residuals.shape[0] return MHARFit( phi1=phi1, coef=model.coef_, diff --git a/src/connectedness/pipeline.py b/src/connectedness/pipeline.py index 68d68ca..4f6bb01 100644 --- a/src/connectedness/pipeline.py +++ b/src/connectedness/pipeline.py @@ -42,11 +42,16 @@ class SpilloverPipeline: ... SpilloverPipeline(prices) ... .compute_returns() ... .compute_realized_measures() - ... .auto_pit() + ... .force_pit() ... .fit_static() ... .fit_rolling(window=365) ... .run() ... ) + + If no PIT method is called before ``fit_static``/``run``, the pipeline + applies :meth:`force_pit` automatically. This matches Chanatásig-Niza, + Ciarreta and Zárraga (2022), who PIT every realized series. Use + :meth:`auto_pit` to opt in to the selective variant. """ def __init__( @@ -104,6 +109,8 @@ def force_pit(self) -> SpilloverPipeline: return self def fit_static(self) -> SpilloverPipeline: + if not self._transformed: + self.force_pit() for name in self._measure_names: df = self._transformed.get(name, self._measure(name)) self._static[name] = static_spillover(df, self._config) @@ -122,6 +129,8 @@ def fit_rolling( def run(self) -> PipelineResult: if self._realized is None: self.compute_realized_measures() + if not self._transformed: + self.force_pit() if not self._static: self.fit_static() if self._rolling_kwargs is not None and not self._rolling: