Description Usage Arguments Value References Examples
Implements a Bayesian target-averaged linear shrinkage covariance estimator as in Gray et al. (2018). It is most useful when the observed data is high-dimensional (more variables than observations) and there are other datasets that can be used to include as prior data-driven targets to shrink towards.
1 2 3 4 5 6 7 8 |
X |
|
targets |
|
without |
|
alpha |
|
plots |
|
ext.data |
|
list
–
matrix
– the estimated covariance matrix.
array
– the targets used for shrinkage.
matrix
– the weight of each (target, alpha)
pair such that sum(weights)=1
. The weights are calculated by
normalising the log-marginal likelihood values below.
matrix
– the values of the log marginal
likelihood for each (target, alpha) pair.
list
– the values of shrinkage intensities used.
Gray, H., Leday, G.G.R., Vallejos, C.A. and Richardson, S., 2018. Shrinkage estimation of large covariance matrices using multiple shrinkage targets. arXiv preprint.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | set.seed(101)
X <- matrix(rnorm(50), 10, 5) # p=10, n=5, identity covariance
X <- t(scale(t(X), center=TRUE, scale=FALSE)) # mean 0
tas <- taShrink(X, plots = FALSE) # apply shrinkage and view target weight bar plot
barplot(targetWeights(tas), names.arg = c(1:9, "S"),
main = "Target-specific shrinkage weights",
col = rainbow(dim(tas$targets)[3]+1), space = 0,
xlab = "Target", ylab = "Weight")
abs(tas$sigmahat - diag(10)) # inspect absolute differences
norm(tas$sigmahat-diag(10), type="F") # calculate loss
# compare this to each single target
norm(gcShrink(X, var=1, cor=1)$sigmahat-diag(10), type="F")
norm(gcShrink(X, var=2, cor=1)$sigmahat-diag(10), type="F")
norm(gcShrink(X, var=3, cor=1)$sigmahat-diag(10), type="F")
norm(gcShrink(X, var=1, cor=2)$sigmahat-diag(10), type="F")
norm(gcShrink(X, var=2, cor=2)$sigmahat-diag(10), type="F")
norm(gcShrink(X, var=3, cor=2)$sigmahat-diag(10), type="F")
norm(gcShrink(X, var=1, cor=3)$sigmahat-diag(10), type="F")
norm(gcShrink(X, var=2, cor=3)$sigmahat-diag(10), type="F")
norm(gcShrink(X, var=3, cor=3)$sigmahat-diag(10), type="F")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.