Error In Chol Default X
Contents |
Tour Start here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring the leading minor of order 2 is not positive definite chol developers or posting ads with us Cross Validated Questions Tags Users Badges Unanswered Ask Question _ error in chol.default((value + t(value))/2) Cross Validated is a question and answer site for people interested in statistics, machine learning, data analysis, data mining, and data visualization. Join them; error in chol default value t value 2 the leading minor of order 1 is not positive definite nlme it only takes a minute: Sign up Here's how it works: Anybody can ask a question Anybody can answer The best answers are voted up and rise to the top “the leading minor of order 1 is not positive definite”
Chol R
error using 2l.norm in mice up vote 4 down vote favorite 1 I am having a problem using the 2l.norm method of multilevel imputation in mice. Unfortunately I cannot post a reproducible example because of the size of my data - when I reduce the size, the problem vanishes. For a particular variable, mice produces the following errors and warnings: Error in chol.default(inv.sigma2[class] * X.SS[[class]] + inv.psi) : the leading minor of order 1 is not positive definite In addition: cholesky decomposition in r Warning messages: 1: In rgamma(n.class, n.g/2 + 1/(2 * theta), scale = 2 * theta/(ss * : NAs produced 2: In rgamma(1, n.class/(2 * theta) + 1, scale = 2 * theta * H/n.class) : NAs produced 3: In rgamma(1, n.class/2 - 1, scale = 2/(n.class * (sigma2.0/H - log(sigma2.0) + : NAs produced If I use the 2l.pan, norm or pmm methods, the problem does not occur. The variable has the following distribution: Min. 1st Qu. Median Mean 3rd Qu. Max. NA's 50.0 117.0 136.0 136.7 155.0 249.0 3124 Also, the class sizes have the following distribution: Min. 1st Qu. Median Mean 3rd Qu. Max. 3.00 50.00 80.00 88.52 111.00 350.00 r missing-data multiple-imputation mice share|improve this question edited Apr 12 '13 at 12:08 asked Apr 12 '13 at 11:59 Robert Long 5,3901437 add a comment| 1 Answer 1 active oldest votes up vote 3 down vote I have had a similar problem in MICE, see my self-discussion here. The problem occurs because you have overfitted your model (too many parameters, variables), some variables are highly colinear or you have cases that have missings on all variables. In my case the model was overfitted. One way to solve this issue is by adjusting the predictor matrix of MICE. You may give imp$pred where impis your mids object, to look at the predictor matrix. You can use new.pred<-quickpred(data) mice(...,pred=new.pred) to automatically generate a predictor matrix based on the b
= -1, ...) Arguments x an object for which a method exists. The default method applies to numeric (or logical) symmetric, positive-definite matrices. ... arguments to be based to or from methods. pivot Should pivoting be used? LINPACK logical. Should LINPACK be used (now ignored)? tol A numeric tolerance for use with pivot = TRUE. Details chol is generic: the description here applies to the default method. Note that only the upper triangular part of x is used, so that R'R = x http://stats.stackexchange.com/questions/55925/the-leading-minor-of-order-1-is-not-positive-definite-error-using-2l-norm-in-m when x is symmetric. If pivot = FALSE and x is not non-negative definite an error occurs. If x is positive semi-definite (i.e., some zero eigenvalues) an error will also occur as a numerical tolerance is used. If pivot = TRUE, then the Choleski decomposition of a positive semi-definite x can be computed. The rank of x is https://stat.ethz.ch/R-manual/R-devel/library/base/html/chol.html returned as attr(Q, "rank"), subject to numerical errors. The pivot is returned as attr(Q, "pivot"). It is no longer the case that t(Q) %*% Q equals x. However, setting pivot <- attr(Q, "pivot") and oo <- order(pivot), it is true that t(Q[, oo]) %*% Q[, oo] equals x, or, alternatively, t(Q) %*% Q equals x[pivot, pivot]. See the examples. The value of tol is passed to LAPACK, with negative values selecting the default tolerance of (usually) nrow(x) * .Machine$double.neg.eps * max(diag(x). The algorithm terminates once the pivot is less than tol. Unsuccessful results from the underlying LAPACK code will result in an error giving a positive error code: these can only be interpreted by detailed study of the FORTRAN code. Value The upper triangular factor of the Choleski decomposition, i.e., the matrix R such that R'R = x (see example). If pivoting is used, then two additional attributes "pivot" and "rank" are also returned. Warning The code does not check for symmetry. If pivot = TRUE and x is not non-negative
♦ ♦ | Report Content as Inappropriate ♦ ♦ try to silence errors 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 http://r.789695.n4.nabble.com/try-to-silence-errors-td4225754.html 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 error in 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 error in chol light on this problem, it would be greatly appreciated. MacQueen, Don Threaded Open this post in threaded view ♦ ♦ | Report Content as Inappropriate ♦ ♦ Re: try to silence errors Something like the following may be what you are looking for. try.out <- try(dmt(y[,j],new$mu[,,4],sigij,ceiling(new$nu[4])),silent=TRUE) if (class(try.out) == 'try-error'} ) { out <- NaN } else { out <- try.out } -Don -- Don MacQueen Lawrence Livermore National Laboratory 7000 East Ave., L-627 Livermore, CA 94550 925-423-1062 On 12/22/11 7:59 AM, "statfan" <[hidden email]> wrote: >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 >erro