Correlation covariance

PortfolioOptimisers.CorrelationCovariance — Type
struct CorrelationCovariance{__T_ce, __T_cache} <: AbstractCovarianceEstimator

Returns the correlation matrix of the wrapped estimator from both cov and cor.

Use it where a caller needs a covariance estimator but the computation needs the correlation matrix. A clustering distance is an example, because it reads a matrix that has no scale.

Fields

  • ce: Covariance estimator.
  • cache: Optional partial-fit state. It is nothing until partial_fit! writes one. When the caller gives no data matrix, the batch verb of the estimator reads it. Each propagation channel does one thing with it. factory keeps it unchanged, because a factory call resolves the configuration, not the sample. port_opt_view copies the entries of the selected assets into a new state, so the viewed estimator holds the state of those assets alone. obs_weights_view removes it, because a state has no slice on the observation axis. Only a type with an observation-weights field has that channel. A type with no such field falls through to the identity method, so it keeps its state. A family whose state has no exact asset slice removes it on both axes and names the reason.

Constructors

CorrelationCovariance(;    ce::StatsBase.CovarianceEstimator = Covariance(),    cache::Option{<:AbstractPartialFitState} = nothing) -> CorrelationCovariance

Keywords correspond to the struct's fields.

Validation

Propagated parameters

factory passes its arguments on to these @fprop fields:

  • ce: Recursively updated through factory.
  • cache: Carried unchanged through factory.

View parameters

port_opt_view takes the view of these @vprop fields at 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.cov — Method
Statistics.cov(ce::CorrelationCovariance, X::MatNum; dims::Int = 1,
               kwargs...)

Compute the correlation matrix with the wrapped estimator, and return it as the covariance matrix.

Use this method where a context accepts a covariance estimator but needs a correlation matrix.

Algorithm

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

The returned matrix has a unit diagonal. A caller that reads the diagonal as variances reads ones.

Arguments

  • ce: The 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 the computation runs.
  • kwargs...: More keyword arguments for the wrapped estimator.

Returns

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

Related

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

Compute the correlation matrix with the wrapped estimator.

Algorithm

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

cov and cor on a CorrelationCovariance return the same matrix.

Arguments

  • ce: The 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 the computation runs.
  • kwargs...: More keyword arguments for the wrapped estimator.

Returns

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

Related

source