Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/connectedness/mhar.py
Original file line number Diff line number Diff line change
Expand Up @@ -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_,
Expand Down
11 changes: 10 additions & 1 deletion src/connectedness/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__(
Expand Down Expand Up @@ -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)
Expand All @@ -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:
Expand Down
Loading