Windowed covariance
PortfolioOptimisers.WindowedCovariance Type
struct WindowedCovariance{__T_ce, __T_w, __T_window} <: AbstractCovarianceEstimatorCovariance estimator that restricts computation to a rolling or indexed observation window.
WindowedCovariance wraps another covariance estimator and applies it to a subset of observations defined by a window and/or custom observation weights. This enables time-varying or recency-weighted covariance estimation.
Fields
ce: Covariance estimator.w: Optional observation weights vectorobservations × 1, or a concrete subtype ofDynamicAbstractWeights. Ifnothing, the computation is unweighted.window: Window specification: an integer (lastwindowobservations) or a vector of indices.
Constructors
WindowedCovariance(;
ce::StatsBase.CovarianceEstimator = PortfolioOptimisersCovariance(),
w::Option{<:ObsWeights} = nothing,
window::Option{<:Int_VecInt} = nothing
) -> WindowedCovarianceKeywords correspond to the struct's fields.
Validation
If
wis notnothing,!isempty(w).If
windowis provided, it must be nonempty, nonnegative, and finite.
Related
sourcePortfolioOptimisers.factory Method
factory(ce::WindowedCovariance, w::ObsWeights) -> WindowedCovarianceReturn a new WindowedCovariance estimator with observation weights w applied to the underlying covariance estimator and stored as the windowed weights.
Arguments
ce: Covariance estimator.w: Observation weights vectorobservations × 1.
Returns
ce: New covariance estimator of the same type as the argument, with the new weights applied.
Related
sourceStatistics.cov Method
Statistics.cov(ce::WindowedCovariance, X::MatNum; dims::Int = 1, mean = nothing, iv::Option{<:MatNum} = nothing,
kwargs...)Compute the covariance matrix using a rolling or indexed observation window.
This method selects a window of observations from X (and applies observation weights if specified), then delegates to the underlying covariance estimator.
Arguments
ce: Windowed covariance estimator.X: Data matrix of asset returns (observations × assets).dims: Dimension along which to perform the computation.mean: Optional pre-computed mean passed to the underlying estimator.iv: Optional implied volatility matrix. Used if any internal covariance estimator is an instance ofImpliedVolatility.kwargs...: Additional keyword arguments passed to the underlying estimator.
Returns
sigma::MatNum: Covariance matrixfeatures x features.
Related
sourceStatistics.cor Method
Statistics.cor(ce::WindowedCovariance, X::MatNum; dims::Int = 1, mean = nothing, iv::Option{<:MatNum} = nothing,
kwargs...)Compute the correlation matrix using a rolling or indexed observation window.
This method selects a window of observations from X (and applies observation weights if specified), then delegates to the underlying covariance estimator's cor method.
Arguments
ce: Windowed covariance estimator.X: Data matrix of asset returns (observations × assets).dims: Dimension along which to perform the computation.mean: Optional pre-computed mean passed to the underlying estimator.iv: Optional implied volatility matrix. Used if any internal covariance estimator is an instance ofImpliedVolatility.kwargs...: Additional keyword arguments passed to the underlying estimator.
Returns
rho::MatNum: Correlation matrixfeatures x features.
Related
source