Regime switches: private API
Functions
PortfolioOptimisers.hac_outer_product! — Function
hac_outer_product!(
cache::RegimeAdjustedCovarianceState,
ce::RegimeAdjustedExpWeightedCovariance,
X::AbstractVector{<:Union{var"#s152", var"#s69"} where {var"#s152"<:Number, var"#s69"<:AbstractJuMPScalar}},
dvalid::AbstractVector{<:Bool}
) -> Any
Computes the outer product of one observation, with the Newey-West HAC correction where hac_lags is not nothing, and divides each product by its exact factor.
The correction adds each lagged cross-product and its transpose, weighted by the Bartlett kernel $w_j = 1 - j/(L+1)$, so the update reads the serial correlation of the returns. An entry of a lagged observation that is not finite is read as zero, which freezes that pair's contribution. Each product is then divided by hac_pair_factor, its mean in units of the covariance of the pair, which is one under PreCentred.
Arguments
cache::RegimeAdjustedCovarianceState: Online covariance computation cache (mutated).ce::RegimeAdjustedExpWeightedCovariance: Covariance estimator configuration.X::VecNum: The deviations of the current observation, zero where an asset gives none.dvalid::AbstractVector{<:Bool}: Mask of the assets whose deviation exists.
Returns
XXt::MatNum: The HAC-adjusted outer product stored incache.XXt.
Related
PortfolioOptimisers.hac_pair_factor — Function
hac_pair_factor(
cache::RegimeAdjustedCovarianceState,
ce::RegimeAdjustedExpWeightedCovariance,
dvalid::AbstractVector{<:Bool}
) -> Any
Exact factor of each product of the regime covariance at the current observation, in units of the covariance of the pair.
The product is the outer product of the deviations, with the HAC products where hac_lags is set. Its mean, for returns that are independent in time, is the covariance of the pair times centring_pair_factor, plus centring_lag_factor once the buffer holds a lagged observation. Under PreCentred the factor is one.
Arguments
cache: Online covariance computation cache, before the observation folds into its counts and overlap.ce: Covariance estimator configuration.dvalid: Mask of the assets whose deviation exists at the observation.
Returns
F::Union{<:Number, <:MatNum}: TheN × Nmatrix of the factors, or one.
Related