Skip to content

Commit 4baf521

Browse files
authored
Point to cov if not positive definite (#746)
1 parent b0ca0b0 commit 4baf521

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/reliability.jl

+5-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,11 @@ item 4: 0.7826
5151
```
5252
"""
5353
function cronbachalpha(covmatrix::AbstractMatrix{<:Real})
54-
isposdef(covmatrix) || throw(ArgumentError("Covariance matrix must be positive definite."))
54+
if !isposdef(covmatrix)
55+
throw(ArgumentError("Covariance matrix must be positive definite. " *
56+
"Maybe you passed the data matrix instead of its covariance matrix? " *
57+
"If so, call `cronbachalpha(cov(...))` instead."))
58+
end
5559
k = size(covmatrix, 2)
5660
k > 1 || throw(ArgumentError("Covariance matrix must have more than one column."))
5761
v = vec(sum(covmatrix, dims=1))

0 commit comments

Comments
 (0)