Skip to content

Commit a53c9db

Browse files
Rik Huijzerkagalenko-m-b
Rik Huijzer
authored andcommitted
Point to cov if not positive definite (#746)
1 parent 3d152ca commit a53c9db

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/reliability.jl

Lines changed: 5 additions & 1 deletion
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)