cov_shrink: Shrink the covariance matrix towards some global mean

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/shrinkage.R

Description

This performs a covariance shrinkage estimation as specified in Ledoit and Wolf. Using within the larger framework only requires using the ShrinkageDenoiser type, which handles the work of constructing a shrinkage estimate of the covariance matrix of returns (and consequently its corresponding correlation matrix).

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19

Arguments

returns

A zoo object of returns. This is TxM

sample

The sample covariance matrix (synonomous to S)

prior

The shrinkage target covariance matrix (synonomous to F)

S

The sample covariance matrix

pi.est

The estimate returned from shrinkage.p

...

Additional parameters to pass to prior.fun

Details

cov_shrink(h, prior.fun = cov.prior.cc, ...)

cov_shrink(h, T, constant.fun, prior.fun = cov.prior.cc, ...)

cov_shrink(h, ...)

cov_sample...

cov_samplereturns

cov_samplereturns

T - Length of returns series used in scaling of shrinkage coefficient

h - A generic tawny object representing either a returns, covariance, or correlation matrix

constant.fun - Use this function to calculate the shrinkage constant

prior.fun - Generates the prior/model covariance matrix

Most of the code related to the shrinkage estimator is tied to calculating a value for the shrinkage coefficient. The remainder of the code shrinks the sample covariance matrix towards the target. In addition, there is a function generator used in conjunction with the optimizePortfolio process to produce a correlation matrix based on the shrinkage.

Value

Scalars are produced by all of the shrinkage.* functions, resulting in the final shrinkage coefficient, calculated by shrinkage.intensity.

The cov.sample function calculates the sample covariance matrix and is MxM.

The cov.shrink function produces the shrunk version of the covariance matrix and has the same dimensions as the sample covariance matrix.

The cor.mean function calculates the constant correlation used in estimating the global mean (aka the shrinkage target) produced by cov.prior.cc.

Author(s)

Brian Lee Yung Rowe

See Also

tawny, optimizePortfolio

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
  require(tawny.types)
  # Estimate the covariance matrix based on the given asset returns
  data(sp500.subset)
  ys <- TawnyPortfolio(sp500.subset, 150)
  S.hat <- cov_shrink(ys)

  # Optimize the portfolio weights using the shrinkage estimator
  ws <- optimizePortfolio(ys, ShrinkageDenoiser())

  # Calculate the sample covariance matrix
  S <- cov.sample(ys$returns)

  # Calculate the shrinkage coefficient
  F <- cov.prior.cc(S)
  k <- shrinkage.intensity(ys$returns, F, S)

Example output

Loading required package: tawny.types
INFO [2017-12-01 01:36:12] Optimizing portfolio for [2008-12-12, 2009-02-27]

tawny documentation built on April 21, 2018, 1:05 a.m.