qis.NanBackfill

class qis.NanBackfill(*values)[source]

Bases: Enum

how the EWM recursion treats a missing observation.

The recursion s_t = (1-λ) x_t + λ s_{t-1} has no value to carry forward at a NaN, so a policy is required. Which one is right depends on whether the gap means “no observation arrived” or “the series is genuinely absent here”. Every policy applies only after a column’s first finite observation: before it the output is NaN under all four. In a covariance or beta recursion the policy applies entry by entry, to the entries whose update involves a missing value.

Variables:
  • FFILL – hold the last state, s_t = s_{t-1}: time stops for the series. The default of the column-wise functions. In a covariance matrix with gaps that differ across assets it can break positive semidefiniteness

  • DEFLATED_FFILL – decay the last state, s_t = λ s_{t-1}, which is exactly the update with the missing observation replaced by zero. The usual reading for a return series, where a missing return is economically zero; it keeps covariance matrices positive semidefinite and is the default of the covariance functions

  • ZERO_FILL – reset the state to zero, s_t = 0: the history is erased and the next observation restarts the recursion at (1-λ) x_t. For a series that is genuinely absent at the gap

  • NAN_FILL – carry the state as ZERO_FILL does, and report NaN at the gap instead of the zero state, so the output flags where the input was missing. A genuine zero estimate is reported as zero

__init__(*args, **kwds)

Attributes

FFILL = 1
DEFLATED_FFILL = 2
ZERO_FILL = 3
NAN_FILL = 4