# covarianceDenoising

## Syntax

## Description

returns a covariance estimate that uses random matrix theory to denoise the
empirical covariance matrix. For more information, see Covariance Denoising and Denoising Algorithm.`SigmaHat`

= covarianceDenoising(`AssetReturns`

)

In addition, you can use `covarianceShrinkage`

to compute an estimate of covariance matrix
using shrinkage estimation. For information on which covariance estimation method to
choose, see Comparison of Methods for Covariance Estimation.

returns a covariance estimate from an initial covariance matrix estimate
(`SigmaHat`

= covarianceDenoising(`Sigma`

,`SampleSize`

)`Sigma`

) and the sample size used to estimate the initial
covariance (`sampleSize`

).

`[`

returns a covariance estimate and the number of eigenvalues that are associated with
signal in combination with either of the input argument combinations in the previous
syntaxes.`SigmaHat`

,`numSignalEig`

] = covarianceDenoising(___)

## Examples

## Input Arguments

## Output Arguments

## More About

## Algorithms

The `covarianceDenoising`

function shrinks only the part of the
covariance that corresponds with noise as follows:

Compute the correlation matrix

*C*associated with the traditional covariance estimate Σ.Compute the eigendecomposition of

*C*=*V*Λ*V*^{T}.Estimate the empirical distribution of the eigenvalues using kernel density estimation with

`fitdist(x,'Kernel')`

. For more information, see`fitdist`

.Fit the Marchenko-Pastur distribution to the empirical distribution by minimizing the mean squared error (MSE) between the empirical probability density function (pdf) and the fitted Marchenko-Pastur pdf. This gives the theoretical bounds λ

^{+}and λ^{-}on the eigenvalues associated with noise.Let $$\stackrel{-}{\lambda}$$ be the average of the eigenvalues smaller than λ

^{+}. Set all eigenvalues smaller than λ^{+}to $$\stackrel{-}{\lambda}$$. These are the eigenvalues associated with noise.Compute the denoised version of the correlation matrix $$\hat{C}=V\stackrel{-}{\Lambda}{V}^{T}$$ and rescale $$\hat{C}$$ so that the main diagonal only has ones. $$\hat{C}$$ is a correlation matrix.

Compute the denoised covariance estimate $$\hat{\Sigma}$$ from $$\hat{C}$$.

## References

[1] Lòpez de Prado, M.
*Machine Learning for Asset Managers (Elements in Quantitative
Finance).* Cambridge University Press, 2020.

## Version History

**Introduced in R2023a**