CorShrinkMatrix: Adaptive shrinkage of a matrix of pairwise correlations.

Description Usage Arguments Value References Examples

View source: R/CorShrinkMatrix.R

Description

This function performs adaptive shrinkage of a matrix of pairwise correlations using a mixture normal prior on Fisher z-scores, with each component centered at the same base level z-score value (0 for 0 base correlation) but a wide range of data-driven component variances. The method is similar to the adaptive shrinkage method for modeling false discovery rates proposed in Stephens 2016 (see reference).

Usage

1
2
3
4
CorShrinkMatrix(cormat, nsamp = NULL, zscore_sd = NULL, thresh_up = 0.99,
  thresh_down = -0.99, image = c("both", "original", "corshrink", "output",
  "null"), tol = 1e-06, image.control = list(), report_model = FALSE,
  maxiter = 1000, ash.control = list())

Arguments

cormat

A matrix of pairwise correlations - not necessarily a correlation matrix. NAs in this matrix are treated as 0.

nsamp

An integer or a matrix denoting the number of samples for each pair of variables over which the correlation has been computed. Only used when zscore_sd is not provided.

zscore_sd

A matrix of the sandard error of the Fisher z-scores for each pair of variables. May contain NA-s as well. The NA-s in this matrix must match with the NAs in the cormat matrix. If provided, it is used as default over the the asymptotic formulation using nsamp. When set to NULL, asymptotic distribution of the Fisher z-scores is used using nsamp.

thresh_up

Upper threshold for correlations in cormat. Defaults to 0.99

thresh_down

Lower threshold for correlations in cormat. Defaults to -0.99

image

character. options for plotting the original or the corshrink matrix. If image = "both", then the function outputs both the plot for original and shrunk correlationmatrix. If image = "original", then the function outputs the correlation plot for the original matrix only. If image = "corshrink", then the function outputs the correlation plot for the CorShrink matrix only.If image = "output", then the function outputs the saved ggplot figure without displaying it. If image = "null", no image is output. Defaults to "both".

tol

The tolerance chosen to check how far apart the CorShrink matrix is from the nearest positive definite matrix before applying PD completion.

image.control

Control parameters for the image when image_original = TRUE and/or image_corshrink = TRUE.

report_model

if TRUE, outputs the full adaptive shrinkage output, else outputs the shrunken vector. Defaults to FALSE.

maxiter

The maximum number of iterations run for the adaptive shrinkage EM algorithm. Default is 1000.

ash.control

The control parameters for adaptive shrinkage

Value

If report_model = FALSE, returns a list with adaptively shrunk version of the sample correlation matrix both before (ash_cor_only) and after PD completion (ash_cor_PD). If report_model = TRUE, then the function also returns all the details of the adaptive shrinkage model output.

References

False Discovery Rates: A New Deal. Matthew Stephens bioRxiv 038216; doi: http://dx.doi.org/10.1101/038216

Examples

1
2
3
data("pairwise_corr_matrix")
data("common_samples")
out <- CorShrinkMatrix(pairwise_corr_matrix, common_samples)

CorShrink documentation built on July 13, 2018, 1 a.m.