cov_shrink: Shrinked Covariance Matrix

Description Usage Arguments Details Value References Examples

View source: R/cov_shrink.R

Description

This function computes the shrinked covariance matrix from the sample covariance matrix and a structured estimator. The optimal shrinkage intensity is estimated too.

Usage

1
cov_shrink(data, na.rm = FALSE, use = "everything")

Arguments

data

matrix or data.frame containing only numeric variables

na.rm

matrix or data.frame containing only numeric variables

use

character string as in cov. Giving a method for computing covariances in the presence of missing values.This must be (an abbreviation of) one of the strings "everything", "all.obs", "complete.obs", "na.or.complete", or "pairwise.complete.obs".

Details

The estimator computes a weighted mean of two covariance estimators. The unstructured estimator is the sample covariance matrix denoted as S and a structured estimator dentoed as F. The returned covariance matrix is computed by the following equation

δ F + (1 - δ) S

with δ denoting the weighting term taking values between 0 and 1.

The structured estimator contains the following entries

f_{ij} = s_{ij}^2 \qquad i = j \\ f_{ij} = \bar{r} s_{ii} s_{jj}

In case missing values are present the

Value

list containing the shrinked covariance matrix and the optimal shrinkage parameter δ.

References

Ledoit, Olivier and Wolf, Michael, Honey, I Shrunk the Sample Covariance Matrix (June 2003). UPF Economics and Business Working Paper No. 691.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
library(MASS)
library(matrixcalc)

set.seed(30)
int_p <- 3
int_N <- 5
vec_mu <- rnorm(int_p)
mat_A <- matrix(runif(int_p^2) - 1, nrow = 3)
mat_Sigma <- cov2cor(t(mat_A) %*% mat_A)
X <- mvrnorm(int_N, vec_mu, mat_Sigma)

cov_shrink(X, )

LeonardMK/covshrink documentation built on Dec. 18, 2021, 4:33 a.m.