cor_smooth {correlation} | R Documentation |
Smooth a non-positive definite correlation matrix to make it positive definite
Description
Make correlations positive definite using psych::cor.smooth
. If smoothing
is done, inferential statistics (p-values, confidence intervals, etc.) are
removed, as they are no longer valid.
Usage
cor_smooth(x, method = "psych", verbose = TRUE, ...)
is.positive_definite(x, tol = 10^-12, ...)
is_positive_definite(x, tol = 10^-12, ...)
Arguments
x |
A correlation matrix. |
method |
Smoothing method. Can be |
verbose |
Set to |
... |
Other arguments to be passed to or from other functions. |
tol |
The minimum eigenvalue to be considered as acceptable. |
Examples
set.seed(123)
data <- as.matrix(mtcars)
# Make missing data so pairwise correlation matrix is non-positive definite
data[sample(seq_len(352), size = 60)] <- NA
data <- as.data.frame(data)
x <- correlation(data)
is.positive_definite(x)
smoothed <- cor_smooth(x)
[Package correlation version 0.8.5 Index]