quantlab.factor.kunquant_ts.EWResidualStd#
- class quantlab.factor.kunquant_ts.EWResidualStd(y, x, window, half_life)[source]#
Bases:
_EWWindowOpStandard deviation of the residual of
EWBeta’s fit ofyonx.With
alphaandbetathe exponentially weighted least-squares intercept and slope (seeEWBeta), the result issqrt(sum(w * (y - alpha - beta * x)**2) / sum(w))over the bars where both are valid, computed in closed form assqrt(var_w(y) - cov_w(x, y)**2 / var_w(x))and floored at 0 before the root. A weighted population figure, likeEWVar; USE4’s HSIGMA with(y, x)the stock’s and the market’s excess returns. NaN for the firstwindow - 1bars and whenxdoes not vary over the valid bars.- Parameters:
- yOpBase
The regressand, such as a stock’s excess return.
- xOpBase
The regressor, such as the market’s excess return.
- windowint
Number of trailing bars, the current one included.
- half_lifefloat
Age in bars at which the weight is one half.
- Raises:
- ValueError
If
window < 1orhalf_life <= 0.
Examples
>>> Output(EWResidualStd(Input("excess"), Input("market_excess"), 252, 63), "hsigma")