Skip to content

Commit

Permalink
Point to cov if not positive definite (#746)
Browse files Browse the repository at this point in the history
  • Loading branch information
rikhuijzer authored Dec 20, 2021
1 parent b0ca0b0 commit 4baf521
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/reliability.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit 4baf521

Please sign in to comment.