I am trying to use the dmt function in the package {mnormt}. Throughout my algorithm, the covariance matrix is sometime calculated to be singular. When attempting to calculate the dmt function with a covariance that is not positive definite, I would like it to return Inf or NaN instead of an error message.
I have been using the try function, however it is not yeilding the desired result. (I did not include the values since they are 17 dimensions, all you need to know is that sigij is singular) try(out <- dmt(y[,j],new$mu[,,4],sigij,ceiling(new$nu[4])),silent=TRUE) Error in chol.default(x, pivot = FALSE) : the leading minor of order 16 is not positive definite I have similarly tried the trycatch function (see below for code) however I am using this within a function made my be (which i call "ll") so I get errors like ll <- function(new,y){ ....... out <- tryCatch(dmt(y[,j],new$mu[,,3],sigij, ceiling(new$nu[3])),error = function(e) -Inf) .... } ll(new,y) Error in chol.default(x, pivot = FALSE) : the leading minor of order 16 is not positive definite [1] -Inf If anyone could shed some light on this problem, it would be greatly appreciated. -- View this message in context: http://r.789695.n4.nabble.com/try-to-silence-errors-tp4225754p4225754.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.