qis.compute_ewm_vector_autocorr¶
- qis.compute_ewm_vector_autocorr(a, span=None, ewm_lambda=0.94, lag=1, is_normalize=True, nan_backfill=NanBackfill.FFILL, var_init_type=InitType.ZERO)[source]¶
EWM autocorrelation ratio of each column: EWM lagged moment over EWM second moment.
Runs
g_t = lambda g_{t-1} + (1 - lambda) x_{t-lag} x_tandv_t = lambda v_{t-1} + (1 - lambda) x_t^2fromt = lagand returnsg_t / v_t. The input is used as given (demean it first). Both states are seeded at zero by default, so the estimate dated t uses rows up to t only, the warm-up factor cancels in the ratio, and the result is the diagonal ofcompute_ewm_matrix_autocorr(). The ratio divides by the current second moment only, so it is not bounded by one.- Parameters:
a (ndarray) – demeaned observations, shape (t,) or (t, n)
span (int | ndarray) – if given, overrides
ewm_lambdavialambda = 1 - 2 / (span + 1)ewm_lambda (float) – EWM decay, used when
spanis Nonelag (int) – lag in rows
is_normalize (bool) – return the ratio; False returns
g_tnan_backfill (NanBackfill) – how a non-finite update is handled; by default both states carry forward
var_init_type (InitType) – seed of
v.InitType.ZERO(default) is point in time;InitType.VARseeds with the full-samplenp.nanvarof each column, which looks ahead with a weight that decays likelambda^t
- Returns:
shape (t, n), n being 1 for 1-d input; NaN for the first
lagrows and wherever the second moment is not positive- Raises:
ValueError – if
var_init_typeis neitherInitType.ZEROnorInitType.VAR- Return type: