Skip to content
13

Correlation covariance

PortfolioOptimisers.CorrelationCovariance Type
julia
struct CorrelationCovariance{__T_ce} <: AbstractCovarianceEstimator

A covariance estimator that returns the correlation matrix as both the covariance and correlation.

CorrelationCovariance wraps another covariance estimator and delegates both cov and cor calls to the underlying estimator's cor method. This is useful when a correlation matrix is needed in contexts that accept a covariance estimator.

Fields

  • ce: Covariance estimator.

Constructors

julia
CorrelationCovariance(;
    ce::StatsBase.CovarianceEstimator = Covariance()
) -> CorrelationCovariance

Keywords correspond to the struct's fields.

Examples

julia
julia> CorrelationCovariance()
CorrelationCovariance
  ce ┼ Covariance
     │    me ┼ SimpleExpectedReturns
     │       │   w ┴ nothing
     │    ce ┼ GeneralCovariance
     │       │   ce ┼ StatsBase.SimpleCovariance: StatsBase.SimpleCovariance(true)
     │       │    w ┴ nothing
     │   alg ┴ Full()

Related

source
PortfolioOptimisers.factory Method
julia
factory(ce::CorrelationCovariance, w::ObsWeights) -> CorrelationCovariance

Return a new CorrelationCovariance estimator with observation weights w applied to the underlying covariance estimator.

Arguments

  • ce: Covariance estimator.

  • w: Observation weights vector observations × 1.

Returns

  • ce: New covariance estimator of the same type as the argument, with the new weights applied.

Related

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

Compute the correlation matrix using the underlying estimator.

This method delegates to Statistics.cor(ce.ce, X; dims = dims, kwargs...), returning the correlation matrix as the "covariance". This is useful when a correlation matrix is required in a context that accepts a covariance estimator.

Arguments

  • ce: Correlation covariance estimator.

  • X: Data matrix of asset returns (observations × assets).

  • dims: Dimension along which to perform the computation.

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

Returns

  • rho::MatNum: Correlation matrix features x features.

Related

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

Compute the correlation matrix using the underlying estimator.

This method delegates to Statistics.cor(ce.ce, X; dims = dims, kwargs...).

Arguments

  • ce: Correlation covariance estimator.

  • X: Data matrix of asset returns (observations × assets).

  • dims: Dimension along which to perform the computation.

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

Returns

  • rho::MatNum: Correlation matrix features x features.

Related

source