quantlab.analysis.factor_report.newey_west_t_stat#

quantlab.analysis.factor_report.newey_west_t_stat(values, lags)[source]#

Return the t-statistic of the mean of values and its two-sided p-value.

The standard error is Newey-West’s, with Bartlett weights 1 - l / (lags + 1) on the autocovariances up to lags, so a series whose neighbours are correlated, such as the IC of overlapping multi-bar forward returns, is not credited with more independent periods than it has. Missing values are dropped and the rest treated as consecutive. lags=0 gives the ordinary t-statistic with the population variance. The p-value uses a t distribution with n - 1 degrees of freedom.

Parameters:
valuespandas.Series

The series, for example a per-period IC.

lagsint

Autocovariance lags included; see newey_west_lags.

Returns:
tuple of float

(t_stat, p_value); both NaN with fewer than two values or zero variance.

Examples

>>> t, p = newey_west_t_stat(pair.ic, lags=4)
>>> round(t, 2), p < 1e-6
(10.91, True)