if (FALSE) { # requireNamespace("psych", quietly = TRUE)
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)
}
Run the code above in your browser using DataLab