fintech-algorithms

Christiano-Fitzgerald Filter

Install and import

bash
npm install fintech-algorithms
ts
import { cfFilter } from "fintech-algorithms/statistical-time-series/decomposition-and-cycles/christiano-fitzgerald-filter";

Signature

cfFilter(values, low, high, drift)

An asymmetric band-pass filter that uses the whole sample, so unlike Baxter-King it produces values at the ends. The trade is that the filter weights differ at each observation, which makes it non-stationary by construction.

Parameters

NameTypeNotes
valuesnumber[]Observation series.
lownumberShortest cycle length to retain.
min: 1 · integer: true
highnumberLongest cycle length to retain.
min: 1 · integer: true
driftbooleanWhether to remove a linear drift before filtering.
optional

Returns

{ cycle, trend }

The cycle component over the full sample length.

Errors

  • When low ≥ high — throws

Complexity: time O(n²), space O(n).

Worked example

executed Captured by running this function on the input its own test provides. Real output of real code — but not asserted against a published figure.

Input

values
[
  100.0901805654,
  101.3367333472,
  102.4083163971,
  102.9128416721,
  103.198587938,
  102.4311805579
]

Showing 6 of 192 elements.

low
6
high
32
drift
true

Call

cfFilter(values, low, high, drift)

Returns

object with 7 fields: cycle, trend, drift_line, low_period, high_period, drift_removed_before_filtering, reconstruction_max_error

{
  "cycle": [
    -0.9710232193903039,
    -0.24888106131204424,
    0.6369705111805075,
    1.3312619134532966,
    1.5158058129594352,
    1.0859129088320714
  ],
  "trend": [
    101.06120378479031,
    101.58561440851204,
    101.77134588591949,
    101.58157975864671,
    101.68278212504057,
    101.34526764906794
  ],
  "drift_line": [
    0,
    0.03320258794921465,
    0.0664051758984293,
    0.09960776384764396,
    0.1328103517968586,
    0.16601293974607326
  ],
  "low_period": 6,
  "high_period": 32,
  "drift_removed_before_filtering": true,
  "reconstruction_max_error": 7.105427357601002e-15
}

Other exports

This module also exports stlDecompose, hpFilter, bkFilter, fftPeriodogram, haarWavelet, runTopic. Every module additionally exports run as an alias of its primary function, and a meta object carrying its catalog id, domain, family, shape and article URL.

Diagrams

Christiano-Fitzgerald Filter — decomposition map
Christiano-Fitzgerald Filter — endpoint risk
Christiano-Fitzgerald Filter — family handoff
Christiano-Fitzgerald Filter — parameter effect
Christiano-Fitzgerald Filter — scenario comparison

How it works

This page states the contract — how to call it correctly. The article explains the concept: why it works, and where it breaks.

Read the article →

References

  • Evidence table
  • Source records
  • Evidence policy
  • Version notes