Description Usage Arguments Details Value Note Author(s) References Examples

Function which performs various estimations of covariance matrices.

1 | ```
covEstimation(rets, control = list())
``` |

`rets` |
a matrix |

`control` |
control parameters (see *Details*). |

The argument `control`

is a list that can supply any of the following components:

`type`

method used to compute the covariance matrix, among

`'naive'`

,`'ewma'`

,`'lw'`

,`'factor'`

,`'const'`

,`'cor'`

,`'oneparm'`

,`'diag'`

and`'large'`

where:`'naive'`

is used to compute the naive covariance matrix.`'ewma'`

is used to compute the exponential weighting moving average covariance matrix. The following formula is used to compute de ewma covariance matrix:*Sigma[t] := lambda * Sigma[t-1] + (1-lambda) r[t-1]'r[t-1]*where

*r_t*is the*(N x 1)*vector of returns at time*t*. Note that the data must be sorted from the oldest to the latest.`'factor'`

is used to compute the covariance matrix estimation using a K-factor approach.`'lw'`

is a weighted average of the sample covariance matrix and a "prior" or "shrinkage target". The prior is given by a one-factor model and the factor is equal to the cross-sectional average of all the random variables. See Ledoit and Wolf (2003).`'const'`

is a weighted average of the sample covariance matrix and a "prior" or "shrinkage target". The prior is given by constant correlation matrix.`'cor'`

is a weighted average of the sample covariance matrix and a "prior" or "shrinkage target". The prior is given by the constant correlation covariance matrix given by Ledoit and Wolf (2003)`'oneparm'`

is a weighted average of the sample covariance matrix and a "prior" or "shrinkage target". The prior is given by the one-parameter matrix. All variances are the same and all covariances are zero.`'diag'`

is a weighted average of the sample covariance matrix and a "prior" or "shrinkage target". The prior is given by a diagonal matrix.`'large'`

This estimator is a weighted average of the sample covariance matrix and a "prior" or "shrinkage target". Here, the prior is given by a one-factor model. The factor is equal to the cross-sectional average of all the random variables. The weight, or "shrinkage intensity" is chosen to minimize quadratic loss measured by the Frobenius norm. The estimator is valid as the number of variables and/or the number of observations go to infinity, but Monte-Carlo simulations show that it works well for values as low as 10. The main advantage is that this estimator is guaranteed to be invertible and well-conditioned even if variables outnumber observations.`'bs'`

is the Bayes-Stein estimator for the covariance matrix given by Jorion (1986).Default:

`type = 'naive'`

`lambda`

decay parameter. Default:

`lambda = 0.94`

.`K`

number of factors to use when the K-factor approach is chosen to estimate the covariance matrix. Default:

`K = 1`

.

A *(N x N)* covariance matrix.

Part of the code is inspired from the Matlab code by Ledoit and Wolf.

David Ardia <david.ardia@unifr.ch> and Jean-Philippe Gagnon Fleury.

Herold, U., Maurer, R. (2006).
Portfolio choice and estimation risk. A comparison of bayesian to heuristic approaches
*Astin bulletin* **36**(1), pp.135–160.

Kolusheva, Daniela. (July 2008).
Out-of-sample Performance of Asset Allocation Strategies
Ledoit, O., Wolf, M. (2002).
Improved estimation of the covariance matrix of stock returns with an application to portfolio selection
*Journal of Empirical Finance * **10**, pp.603–621.

Ledoit, O., Wolf, M. (2003).
Honey, I Shrunk the Sample Covariance Matrix.
*The Journal of Portfolio Management* **30**(4), pp.110–119.

Ledoit, O., Wolf, M. (2004).
A well-conditioned estimator for large-dimensional covariance matrices
*Journal of Multivariate Analysis* **88**, pp.365–411.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | ```
# For the examples, we simply generate a 100 x 25 random matrix.
set.seed(3214)
T = 100
N = 25
rets = matrix(rnorm(T*N), nrow = T, ncol = N)
# Computes the naive covariance estimation.
covEstimation(rets)
#Computes the ewma estimation of the covariance with default lambda = 0.94.
covEstimation(rets, control = list(type = "ewma"))
#Computes the ewma estimation of the covariance with default lambda = 0.90.
covEstimation(rets, control = list(type = "ewma", lambda = 0.9))
#Computes the factor estimation of the covariance with dafault K = 1.
covEstimation(rets, control = list(type = "factor"))
#Computes the factor estimation of the covariance with K = 3.
covEstimation(rets, control = list(type = "factor", K = 3))
#Computes the Ledot-Wolf's estimation of the covariance.
covEstimation(rets, control = list(type = "lw"))
#Shrinkage of the covariance matrix using constant correlation matrix.
covEstimation(rets, control = list(type = "const"))
#Shrinkage of the covariance matrix towards constant correlation matrix by Ledoit-Wolf.
covEstimation(rets, control = list(type = "cor"))
#Shrinkage of the covariance matrix towards one-parameter matrix.
covEstimation(rets, control = list(type = "oneparm"))
#Shrinkage of the covaraince matrix towards diagonal matrix.
covEstimation(rets, control = list(type = "diag"))
#Shrinkage of the covariance matrix for large data set.
covEstimation(rets, control = list(type = "large"))
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.