cor_smooth {correlation} | R Documentation |
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.
cor_smooth(x, method = "psych", verbose = TRUE, ...) is.positive_definite(x, tol = 10^-12, ...) is_positive_definite(x, tol = 10^-12, ...)
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. |
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)