I've started developing my own modules implementing functions and distributions to be used in JAGS. So far, they work properly for univariate distributions. After that, I tried to implement multivariate cases. As a start, I focused on simply implementing the multivariate normal distribution, using the class ArrayDist, which is located in the JAGS subfolder /srs/include/distribution. By Inheriting from this class, I'm required to implement a random sampler for this distribution within the function randomsample(...). Based on the DMNorm class, which is in the JAGS subfolder /src/modules/bugs/distributions/DMNorm.h, I've implemented (just for testing) my own version of this distribution called dmnorm2 (which has exactly the same code as dmnorm). After having installed my module, I was able to sample from my distribution (using R2jags R package) in a simple model such as the following
model{theta[1:n]~dmnorm2(zero,sigma)}
where zero is a vector of zeros and sigma is a precision matrix. However, when I try to run a full Bayesian model including the likelihood and prior distributions, I get the following error
Error in jags.model(model.file, data = data, inits = init.values, n.chains = n.chains, :
Error in node theta
Unable to find appropriate sampler)
which I believe it is related to JAGS not being able to sample from the posterior distribution when using my module. I'd like to emphasize two points: (i) the original dmnorm function works properly in the experiments above; (ii) my module is installing properly (no error messages for instalation). Do you have any idea of what is missing in the development of my multivariate distribution for JAGS?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Dear all,
I've started developing my own modules implementing functions and distributions to be used in JAGS. So far, they work properly for univariate distributions. After that, I tried to implement multivariate cases. As a start, I focused on simply implementing the multivariate normal distribution, using the class ArrayDist, which is located in the JAGS subfolder /srs/include/distribution. By Inheriting from this class, I'm required to implement a random sampler for this distribution within the function randomsample(...). Based on the DMNorm class, which is in the JAGS subfolder /src/modules/bugs/distributions/DMNorm.h, I've implemented (just for testing) my own version of this distribution called dmnorm2 (which has exactly the same code as dmnorm). After having installed my module, I was able to sample from my distribution (using R2jags R package) in a simple model such as the following
where zero is a vector of zeros and sigma is a precision matrix. However, when I try to run a full Bayesian model including the likelihood and prior distributions, I get the following error
which I believe it is related to JAGS not being able to sample from the posterior distribution when using my module. I'd like to emphasize two points: (i) the original dmnorm function works properly in the experiments above; (ii) my module is installing properly (no error messages for instalation). Do you have any idea of what is missing in the development of my multivariate distribution for JAGS?