Windowed variance
PortfolioOptimisers.WindowedVariance Type
struct WindowedVariance{__T_ce, __T_w, __T_window} <: AbstractVarianceEstimatorVariance estimator that restricts computation to a rolling or indexed observation window.
WindowedVariance wraps another variance 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 variance estimation.
Fields
ce: Expected returns 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
WindowedVariance(;
ce::AbstractVarianceEstimator = SimpleVariance(),
w::Option{<:ObsWeights} = nothing,
window::Option{<:Int_VecInt} = nothing
) -> WindowedVarianceKeywords 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::WindowedVariance, w::ObsWeights) -> WindowedVarianceReturn a new WindowedVariance estimator with observation weights w applied to the underlying variance estimator and stored as the windowed weights.
Arguments
ce: Windowed variance estimator.w: Observation weights vectorobservations × 1.
Returns
ce::WindowedVariance: Updated estimator with weights applied.
Related
sourceStatistics.var Method
Statistics.var(ce::WindowedVariance, X::MatNum; dims::Int = 1, mean = nothing, iv::Option{<:MatNum} = nothing,
kwargs...)Compute the variance vector using a rolling or indexed observation window (matrix input).
This method selects a window of observations from X, applies observation weights if specified, then delegates to the underlying variance estimator.
Arguments
ce: Windowed variance 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
var::Matrix{<:Number}: Variance vector for the selected window.
Related
sourceStatistics.var Method
Statistics.var(ce::WindowedVariance, X::VecNum; mean = nothing)Compute the variance using a rolling or indexed observation window (vector input).
This method selects a window of observations from the vector X, applies observation weights if specified, then delegates to the underlying variance estimator.
Arguments
ce: Windowed variance estimator.X: Data vector of returns.mean: Optional pre-computed mean passed to the underlying estimator.
Returns
var::Number: Variance for the selected window.
Related
sourceStatistics.std Method
Statistics.std(ce::WindowedVariance, X::MatNum; dims::Int = 1, mean = nothing, iv::Option{<:MatNum} = nothing, kwargs...)Compute the standard deviation vector using a rolling or indexed observation window (matrix input).
This method selects a window of observations from X, applies observation weights if specified, then delegates to the underlying variance estimator's std method.
Arguments
ce: Windowed variance 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
sd::Matrix{<:Number}: Standard deviation vector for the selected window.
Related
sourceStatistics.std Method
Statistics.std(ce::WindowedVariance, X::VecNum; mean = nothing)Compute the standard deviation using a rolling or indexed observation window (vector input).
This method selects a window of observations from the vector X, applies observation weights if specified, then delegates to the underlying variance estimator's std method.
Arguments
ce: Windowed variance estimator.X: Data vector of returns.mean: Optional pre-computed mean passed to the underlying estimator.
Returns
sd::Number: Standard deviation for the selected window.
Related
source