I’ve often found the cholesky behaviour a little spooky, here I have an example I can really pin down and make no sense of… loading the following two files (a stanmodel and standata object), log_prob and the gradient work fine, but constrain_pars generates a nan cholesky issue. I have managed to change something seemingly unrelated and make the glitch go away, I just wonder if a) I’m misunderstanding something, or b) there is a bug somewhere. I thought if the gradient was successfully computed, and it’s not an issue in generated quantities, there should be no reason for a cholesky failure during constrain_pars .
[https://www.dropbox.com/s/gazx9nlkccj0iel/sd.rda?dl=0]
[https://www.dropbox.com/s/ab6y95ktu1b2tyf/sm.rda?dl=0]
library(rstan)
sf <- sampling(sm,iter=0,chains=0,init=0,data=sd,check_data=FALSE,
control=list(max_treedepth=0),save_warmup=FALSE,test_grad=FALSE)
pars <- rep(0,get_num_upars(sf))
log_prob(sf,pars,gradient=TRUE)
constrain_pars(sf,pars)
Error in object@.MISC$stan_fit_instance$constrain_pars(upars) :
Exception: cholesky_decompose: m is not symmetric. m[1,2] = nan, but m[2,1] = nan (in ‘model_ctsm’ at line 882)