quantlab.model.evaluation.rank_autocorrelation_series#

quantlab.model.evaluation.rank_autocorrelation_series(pred, lag=1)[source]#

Return each row’s rank correlation with the row lag rows before, NaN where there is none.

The prediction’s own persistence, as the factor report’s rank_autocorrelation: row t is the cross-sectional rank IC of pred[t] against pred[t - lag] on the symbols finite in both. The first lag rows have no earlier row and are NaN, as is a row skipped by the rank IC. A signal whose order changes little from bar to bar (values near 1) needs little trading to follow.

Parameters:
predarray_like

A 2-D [T, S] panel of predictions.

lagint, default 1

How many rows back each row is compared with; at least 1.

Returns:
np.ndarray

A float64 array of length T.

Raises:
ValueError

If pred is not 2-D or lag is below 1.

Examples

The second row swaps the top two of the first:

>>> rank_autocorrelation_series([[1.0, 2.0, 3.0, 4.0], [1.0, 2.0, 4.0, 3.0]])
array([nan, 0.8])