Hi,
I'm in a process of building a large spatial covariance matrix with lots of blocks. There is a correlation parameter (\gamma) for the off diagonal blocks which need to be constrained such that the resulting covariance matrix is positive definite.
Unfortunately, there is no closed form to get the support of \gamma to ensure the positive definiteness. The support is between -1 and 1 with holes inside. What I did in R is during the sampling, if non-positive definiteness is found (catch the error message from a Cholesky decomposition), I will set the joint log density to the smallest number in log scale (i.e. zero density). Then that proposed \gamma will be declined and keep the previous \gamma.
I'm interested in implementing my model in Rstan to check my own coding (it's so easy to make some small bugs when programming my sampling procedure with such a complicated model, and the convergence is not good so far). But I got stuck when dealing with theses issues.
1. I notice that I can calculate the eigenvalues of a matrix and then check if all positive( or simply the first one, since it's been ordered). But I'm wondering if there be some machine error going on if I'm using this method.
2. Also, if I find a good way to check positive definiteness, is there a way for me to set the joint density to 0 (let stan stay with the previous sample and move on)? Or do I have other ways to address my unknown support issue?
Thanks,
Jiang