Error : Error in function stan::prob::multi_normal_log(d): Covariance matrix is not positive definite. Covariance matrix(0,0) is 2.4779795485011187.
error occurred during calling the sampler; sampling not done
albMRegMod = '
data {
int<lower=1> nData;
int<lower=1> nVars;
real x3[nData];
matrix[nData, nVars] y;
matrix[nVars, nVars] Imat;
vector[nVars] b3p;
}
parameters {
vector[nVars] b0;
vector[nVars] b3;
cov_matrix[nVars] Omega3;
real<lower=0, upper=100> sd[nVars];
}
transformed parameters {
vector[nVars] mu[nData];
for ( np in 1:nVars){
for ( i in 1:nData){
mu[i, np] <- b0[np] + b3[np] * x3[i];
}
}
}
model {
//Priors
b0 ~ normal( 0 , 10);
b3 ~ multi_normal(b3p , Omega3);
Omega3 ~ inv_wishart(nVars+1, Imat);
//Likelihood
for(np in 1:nVars){
for(i in 1:nData){
y[i, np] ~ normal(mu[i, np], sd[np]);
}
}
}
'
seed = 666
nVars = 15 #12 works, 13:14 give lots of warning messages, 15+ gives errors
nData = 300
b0p = rep(0, nVars)
b3p = rep(0, nVars)
Imat <- diag(1, nVars)
y <- matrix(rnorm(nVars*nData), nrow=nData, ncol=nVars)
x3 <- rnorm(nData)
dataList = list( y = y, x3 = x3,
Imat = Imat, b0p = b0p, b3p = b3p,
nVars = nVars, nData = nData)
f1 <- stan(model_code = albMRegMod, data = dataList, chains = 1, iter=500,
seed = seed, chain_id = 1,
pars = c("b0", "b3"))
I was running into problems with a more complex model when I started adding in more dependent variables. So I simplified it down to try and isolate where the problem might be. It seems as though stan has a limit of approximately 15 dependent variables for a multi-normal IV node, and at 15 DVs it starts to struggle.
I get the following error for the seed set at 666 and 15 DVs:Error : Error in function stan::prob::multi_normal_log(d): Covariance matrix is not positive definite. Covariance matrix(0,0) is 2.4779795485011187.
error occurred during calling the sampler; sampling not done
And sometimes it starts eating massive amounts of memory at around 20 DVs (compared to JAGS which handles a similar specification with much less memory) - I think it also doesn't release the memory from the run when it doesn't complete, but this may be an RStudio - Rstan interface issue not related to stan. Possibly also related to this last post here?
Omega3 ~ inv_wishart(nVars+1, Imat);Thanks Ben. The re-parameterisation with multi_normal_cholesky works well from the optimizing section, but I haven't yet figured out how to successfully use the inverse Wishart re-parameterisation (the last attempt exhausted my RAM). Will keep tweaking.
Any plans for a multi_student_t_cholesky?
--
You received this message because you are subscribed to the Google Groups "stan users mailing list" group.
To unsubscribe from this group and stop receiving emails from it, send an email to stan-users+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.