Mutual Information Covariance
PortfolioOptimisers.MutualInfoCovariance — Type
struct MutualInfoCovariance{__T_ve, __T_bins, __T_normalise} <: AbstractCovarianceEstimatorMeasures codependence with mutual information, which captures a non-linear relationship a correlation misses.
The mutual information matrix is optionally normalised by the smaller of the two marginal entropies, then rescaled by the marginal standard deviations of ve to give a covariance matrix.
Mutual information is non-negative, so every entry of the matrix is non-negative and no pair is ever reported as opposed. A negative linear relationship reads as a strong one, not as a negative one. When normalise is false the correlation matrix is unbounded above and its diagonal carries the marginal entropy in nats rather than one, so it is a codependence matrix rather than a correlation matrix in the usual sense.
Mathematical definition
\[\begin{align} \hat{\boldsymbol{\rho}}_{ij} &= \mathrm{MI}(X_i,\, X_j)\,, \\ \hat{\mathbf{\Sigma}}_{ij} &= \begin{cases} \hat{\sigma}_i^2 & i = j \\ \hat{\boldsymbol{\rho}}_{ij}\,\hat{\sigma}_i\,\hat{\sigma}_j & i \neq j \end{cases}\,. \end{align}\]
Where:
- $\hat{\boldsymbol{\rho}}_{ij}$: Mutual information-based correlation between assets $i$ and $j$.
- $\hat{\mathbf{\Sigma}}_{ij}$: Covariance between assets $i$ and $j$.
- $\mathrm{MI}(X_i, X_j)$: Mutual information between assets $i$ and $j$, computed by
mutual_info. Whennormaliseistrueit is divided by $\min(H(X_i), H(X_j))$, which bounds it to $[0,\, 1]$. - $\hat{\sigma}_i$: Marginal standard deviation of asset $i$ from the variance estimator
ve.
The diagonal of $\hat{\mathbf{\Sigma}}$ is the variance whatever $\hat{\boldsymbol{\rho}}$ carries there, so the two values of normalise give the same diagonal and differ only off it.
Fields
ve: Variance estimator.
bins: Binning algorithm or fixed number of bins.
normalise: Whether to normalise the mutual and/or variation of information calculation.
Constructors
MutualInfoCovariance(; ve::AbstractVarianceEstimator = SimpleVariance(), bins::Int_Bin = HacineGharbiRavier(), normalise::Bool = true) -> MutualInfoCovarianceKeywords correspond to the struct's fields.
Validation
- If
binsis an integer,0 < bins <= RESOURCE_LIMITS[].max_bins(the joint histogram isbins × bins; seeRESOURCE_LIMITS).
Propagated parameters
When factory is called on this type, the following @fprop-tagged fields are automatically propagated:
ve: Recursively updated viafactory.
View parameters
When port_opt_view is called on this type, the following @vprop-tagged fields are automatically subset to the selected indices:
ve: Recursively viewed viaport_opt_view.
Examples
julia> MutualInfoCovariance()MutualInfoCovariance ve ┼ SimpleVariance │ me ┼ SimpleExpectedReturns │ │ w ┴ nothing │ w ┼ nothing │ corrected ┴ Bool: true bins ┼ HacineGharbiRavier() normalise ┴ Bool: trueRelated
References
Statistics.cor — Method
Statistics.cor(ce::MutualInfoCovariance, X::MatNum; dims::Int = 1, kwargs...)Compute the mutual information (MI) correlation matrix using a MutualInfoCovariance estimator.
This method computes the pairwise mutual information correlation matrix for the input data matrix X, using the binning strategy and normalisation specified in ce. The MI correlation captures both linear and nonlinear dependencies between asset returns, making it robust to complex relationships that may not be detected by traditional correlation measures.
The result is bounded by $[0, 1]$ with a unit diagonal only when ce.normalise is true. When it is false the entries are mutual information in nats and the diagonal is the marginal entropy, as mutual_info states.
Algorithm
- Orient
Xtoobservations × assetswithdims_oriented, which validatesdimsand transposes whendimsis2. - Return
mutual_infoof the oriented matrix, under the binning algorithmce.binsand the flagce.normalise.
Arguments
ce: Covariance estimator.X: Data matrixobservations × assetsif thedimskeyword does not exist ordims = 1,assets × observationswhendims = 2.dims: Dimension along which to perform the computation.kwargs...: Additional keyword arguments (currently unused).
Validation
dims in (1, 2).
Returns
rho::MatNum: Correlation matrixassets x assets.
Related
References
- [5]
- D. Cajas. Advanced Portfolio Optimization: A Cutting-edge Quantitative Approach (Springer Nature Switzerland, 2025).
- [24]
- C. E. Shannon. A mathematical theory of communication. The Bell System Technical Journal 27, 379–423 (1948).