the leading minor of order 1 is not positive definite

14 views
Skip to first unread message

Dongchen Zhang

unread,
May 26, 2023, 12:15:08 PM5/26/23
to nimble-users
Hi guys,

When I am using the nimble I hit the following error messages: 
Error in chol.default(model$q[1:3, 1:3]) :
the leading minor of order 1 is not positive definite
Here is the nimble model that I am using:
test.nimble <-  nimbleCode(
  qq ~ dgamma(shape = 1, rate = 5) ## aq and bq are estimated over time
  q[1:3, 1:3] <- qq * diag(3)
 
  # X model
  X.mod[1:4] ~ dmnorm(mean = muf[1:4], cov = pf[1:4, 1:4])
 
  # ## Likelihood
  for (i in 1:3) {
    tmpX[i]  <- X.mod[H[i]]
    Xs[i] <- tmpX[i]
  }
  X[1:3] ~ dmnorm(Xs[1:3], prec = q[1:3, 1:3])
  Y[1:3] ~ dmnorm(X[1:3], prec = R[1:3, 1:3])
})
any thoughts?
Thanks!
Dongchen

Perry de Valpine

unread,
May 26, 2023, 12:28:18 PM5/26/23
to Dongchen Zhang, nimble-users
Hi Dongchen,
This usually means that you have not provided a valid covariance or precision matrix (or values for nodes from which it is computed, in this case qq) in data, inits or constants. The Cholesky decomposition (chol.default) is called as part of nimble's handling of dmnorm.  Based on the "model$q" in the message, it looks like the q[1:3, 1:3] is not a valid precision matrix. The Error message you see is from nimbleModel's attempt to calculate all nodes in your model, which is still uncompiled and so executing in R, and so that is an R error message. It should be surrounded by a nimble message that errors at this stage are not necessarily a problem; they might just mean that your model is not fully initialized, which is what we typically see with the chol error.  Since q is a deterministic node computed as qq * diag(3), is it possible that you have not provided a value for q in data, inits, or constants?  (A value will not be simulated from the prior as part of nimbleModel. That will only happen later if you start MCMC, for example, and the model is still not fully initialized.) To check, you can enter:
model$qq
model$q
You've only shown your nimbleCode, not a call to nimbleModel or nimbleMCMC (which would make your example fully reproducible), so I can only guess at what's going on.
HTH and please follow up if you're still stuck.
Perry


--
You received this message because you are subscribed to the Google Groups "nimble-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nimble-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/nimble-users/4582eb35-f937-4909-be77-181c9671574dn%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages