From 4baf521834e33c45aca32bb69fe7290a418a6660 Mon Sep 17 00:00:00 2001 From: Rik Huijzer Date: Mon, 20 Dec 2021 11:37:16 +0100 Subject: [PATCH] Point to cov if not positive definite (#746) --- src/reliability.jl | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/reliability.jl b/src/reliability.jl index aebb94b29..e9abb58b3 100644 --- a/src/reliability.jl +++ b/src/reliability.jl @@ -51,7 +51,11 @@ item 4: 0.7826 ``` """ function cronbachalpha(covmatrix::AbstractMatrix{<:Real}) - isposdef(covmatrix) || throw(ArgumentError("Covariance matrix must be positive definite.")) + if !isposdef(covmatrix) + throw(ArgumentError("Covariance matrix must be positive definite. " * + "Maybe you passed the data matrix instead of its covariance matrix? " * + "If so, call `cronbachalpha(cov(...))` instead.")) + end k = size(covmatrix, 2) k > 1 || throw(ArgumentError("Covariance matrix must have more than one column.")) v = vec(sum(covmatrix, dims=1))