Correlation covariance

PortfolioOptimisers.CorrelationCovarianceType
struct CorrelationCovariance{__T_ce} <: AbstractCovarianceEstimator

Answers both cov and cor with the wrapped estimator's correlation matrix.

Use it where a caller demands a covariance estimator but the computation wants the correlation — a clustering distance, for instance, which reads a scale-free matrix.

Fields

  • ce: Covariance estimator.

Constructors

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

Keywords correspond to the struct's fields.

Propagated parameters

When factory is called on this type, the following @fprop-tagged fields are automatically propagated:

  • ce: Recursively updated via factory.

View parameters

When port_opt_view is called on this type, the following @vprop-tagged fields are automatically subset to the selected indices:

Examples

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

Related

source
Statistics.covMethod
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.

Algorithm

  1. Call Statistics.cor(ce.ce, X; dims = dims, kwargs...) and return its result.

The returned matrix carries a unit diagonal, so a caller that reads the diagonal for a variance reads ones, not variances.

Arguments

  • ce: Correlation covariance estimator.
  • X: Data matrix observations × assets if the dims keyword does not exist or dims = 1, assets × observations when dims = 2.
  • dims: Dimension along which to perform the computation.
  • kwargs...: Additional keyword arguments passed to the underlying estimator.

Returns

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

Related

source
Statistics.corMethod
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...).

Algorithm

  1. Call Statistics.cor(ce.ce, X; dims = dims, kwargs...) and return its result.

cov and cor on a CorrelationCovariance return the same matrix.

Arguments

  • ce: Correlation covariance estimator.
  • X: Data matrix observations × assets if the dims keyword does not exist or dims = 1, assets × observations when dims = 2.
  • dims: Dimension along which to perform the computation.
  • kwargs...: Additional keyword arguments passed to the underlying estimator.

Returns

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

Related

source