Open
Description
CovEst.hardPD() does not give a matrix that is positive definite? See code below
I believe this comes from the second search, which searches within the "first non pd" (Cvec1[iter]
) to the last "pd" (Cvec1[iter-1]
). It starts from the lowest, and then see if it is non pd. So this will stop at the first value (first non pd), and hence returns a non-pd value!?
Solution is probably either to inverse the line: Cvec2 = seq(from=Cvec1[iter], to=Cvec1[iter-1], length.out=20)
, or to change the sign in the second if ((min(eigen(tmpS, only.values=TRUE)$values)) < sqrt(.Machine$double.eps)){
to stop at the first pd?
Thanks!
library(CovTools)
pdim <- 20
data <- matrix(rnorm(10*pdim), ncol=pdim)
out4 <- CovEst.hardPD(data)
min(eigen(out4$S, only.values = TRUE)$values)
#> [1] -0.2785753
## verify with matrixcalc
matrixcalc::is.positive.definite(out4$S)
#> [1] FALSE
Created on 2021-05-05 by the reprex package (v2.0.0)
Metadata
Metadata
Assignees
Labels
No labels