Skip to content
11

Denoise covariance

PortfolioOptimisers.DenoiseCovariance Type
julia
struct DenoiseCovariance{T1, T2, T3} <: AbstractCovarianceEstimator
    ce::T1
    dn::T2
    pdm::T3
    function DenoiseCovariance(ce::AbstractCovarianceEstimator, dn::Denoise,
                               pdm::Option{<:Posdef})
        return new{typeof(ce), typeof(dn), typeof(pdm)}(ce, dn, pdm)
    end
end

A covariance estimator that applies a denoising algorithm and positive definite projection to the output of another covariance estimator. This type enables robust estimation of covariance matrices by first computing a base covariance, then applying denoising and positive definiteness corrections in sequence.

Fields

  • ce: The underlying covariance estimator to be denoised.

  • dn: The denoising algorithm to apply to the covariance matrix.

  • pdm: The positive definite matrix projection method.

Constructors

julia
DenoiseCovariance(; ce::AbstractCovarianceEstimator; dn::Denoise = Denoise(),
                  pdm::Option{<:Posdef} = Posdef())

Keyword arguments correspond to the fields above.

Examples

julia
julia> DenoiseCovariance()
DenoiseCovariance
   ce ┼ Covariance
      │    me ┼ SimpleExpectedReturns
      │       │     w ┼ nothing
      │       │   idx ┴ nothing
      │    ce ┼ GeneralCovariance
      │       │    ce ┼ StatsBase.SimpleCovariance: StatsBase.SimpleCovariance(true)
      │       │     w ┼ nothing
      │       │   idx ┴ nothing
      │   alg ┴ Full()
   dn ┼ Denoise
      │      alg ┼ ShrunkDenoise
      │          │   alpha ┴ Float64: 0.0
      │     args ┼ Tuple{}: ()
      │   kwargs ┼ @NamedTuple{}: NamedTuple()
      │   kernel ┼ typeof(AverageShiftedHistograms.Kernels.gaussian): AverageShiftedHistograms.Kernels.gaussian
      │        m ┼ Int64: 10
      │        n ┼ Int64: 1000
      │      pdm ┼ Posdef
      │          │      alg ┼ UnionAll: NearestCorrelationMatrix.Newton
      │          │   kwargs ┴ @NamedTuple{}: NamedTuple()
  pdm ┼ Posdef
      │      alg ┼ UnionAll: NearestCorrelationMatrix.Newton
      │   kwargs ┴ @NamedTuple{}: NamedTuple()

Related

source
Statistics.cov Method
julia
Statistics.cov(ce::DenoiseCovariance, X::MatNum; dims = 1, kwargs...)

Compute the denoised and positive definite projected covariance matrix for the data matrix X using the specified DenoiseCovariance estimator.

Arguments

  • ce: The DenoiseCovariance estimator specifying the base covariance estimator, denoising algorithm, and positive definite projection.

  • X: The data matrix (observations × assets).

  • dims: Dimensions along which to perform the computation.

  • kwargs...: Additional keyword arguments passed to the underlying covariance estimator.

Returns

  • sigma::MatNum: denoised covariance matrix.

Validation

  • dims in (1, 2).

Details

  • Computes the covariance matrix using the base estimator in ce.

  • Transposes X if dims == 2 to ensure variables are in columns.

  • Ensures the covariance matrix is mutable.

  • Applies positive definite projection using the method in ce.pdm.

  • Applies the denoising algorithm in ce.dn with the aspect ratio T/N.

  • Returns the processed covariance matrix.

Related

source
Statistics.cor Method
julia
Statistics.cor(ce::DenoiseCovariance, X::MatNum; dims = 1, kwargs...)

Compute the denoised and positive definite projected correlation matrix for the data matrix X using the specified DenoiseCovariance estimator.

Arguments

  • ce: The DenoiseCovariance estimator specifying the base covariance estimator, denoising algorithm, and positive definite projection.

  • X: The data matrix (observations × assets).

  • dims: Dimensions along which to perform the computation.

  • kwargs...: Additional keyword arguments passed to the underlying correlation estimator.

Returns

  • rho::MatNum: denoised correlation matrix.

Validation

  • dims in (1, 2).

Details

  • Computes the correlation matrix using the base estimator in ce.

  • Transposes X if dims == 2 to ensure variables are in columns.

  • Ensures the correlation matrix is mutable.

  • Applies positive definite projection using the method in ce.pdm.

  • Applies the denoising algorithm in ce.dn with the aspect ratio T/N.

  • Returns the processed correlation matrix.

Related

source