Hi All,
I am implementing the zero trick for a non-standard prior for a variance matrix. The matrix is restricted because of some symmetry conditions which result in the restricted sample spaces for the values of 4 correlation parameters. I have used the zero-trick (on the sample space for correlations) to implement the condition that the variance matrix be positive-definite. The zero trick is supposed to help in the generation of values of the correlation parameters so that only legal values are generated. What happens is that sometimes illegal values are picked up and as a result the updater stops with a trap message because the variance matrix generated is not positive definite.
Appended below is a OpenBUGS code along with the data and initial values. The code works for a while but then the updater crashes. Blue Diamonds in OpenBUGS enable me to find the root cause of the problem - it takes me to illegitimate set of values of correlation parameters phi1, phi2, phi3, phi4 in this model.
The question is why the zero-trick prevent does not a sampler to generate illegitimate values for the phi parameters.
Paramjit Gill
++++++++++++++++++++++++++++++++++++++++++++++++++++
# OpenBUGS code
model
{
for (i in 1:n) {
y[i,1:4] ~ dmnorm(mu[1:4], Sinv[,])
}
# Priors
for (i in 1:4) {mu[i] ~ dnorm(0, 0.01) }
# Get the precision matrix Sinv from the var-cov matrix
Sinv[1:4,1:4] <- inverse(Sig[1:4,1:4])
# Inverse Gamma priors for variance parameters sigma1, sigma2
tau1 ~ dgamma(1,1)
tau2 ~ dgamma(1,1)
sigma1 <- 1/tau1
sigma2 <- 1/tau2
# Build the var-cov matrix Sig from variances and correlations (phi's)
Sig[1,1] <- sigma1
Sig[2,2] <- sigma1
Sig[3,3] <- sigma2
Sig[4,4] <- sigma2
# Create the off-diagonal entries of Sig
Sig[1,2] <- sigma1*phi1
Sig[2,1] <- Sig[1,2]
Sig[1,3] <- sqrt(sigma1*sigma2)*phi2
Sig[3,1] <- Sig[1,3]
Sig[1,4] <- sqrt(sigma1*sigma2)*phi3
Sig[4,1] <- Sig[1,4]
Sig[2,3] <- sqrt(sigma1*sigma2)*phi3
Sig[3,2] <- Sig[2,3]
Sig[2,4] <- sqrt(sigma1*sigma2)*phi2
Sig[4,2] <- Sig[2,4]
Sig[3,4] <- sigma2*phi4
Sig[4,3] <- Sig[3,4]
# Constrained priors for phi's using the "Zero-trick"
phi1 ~ dunif(-.99,.99)
phi2 ~ dunif(-.99,.99)
phi3 ~ dunif(-.99,.99)
phi4 ~ dunif(-.99,.99)
# Implement the zero trick to force phi1, phi2, phi3, phi4 in the restricted paramter space
# This is done by forcing two determinats to have values > 0
O1 <- 0
O1 ~ dbern(cons1)
cons1 <- step(phi1*phi1+phi2*phi2 +phi3*phi3 -2*phi1*phi2*phi3 -1)
O2 <- 0
O2 ~ dbern(cons2)
cons2 <- step(phi1*phi1 +2*phi2*phi2 +2*phi3*phi3 +phi4*phi4 -4*phi1*phi2*phi3
-4*phi2*phi3*phi4 -phi1*phi1*phi4*phi4 +2*phi2*phi2*phi3*phi3 +2*phi1*phi3*phi3*phi4 +2*phi1*phi2*phi2*phi4 -phi2*phi2*phi2*phi2 -phi3*phi3*phi3*phi3 -1)
} # End model
# Initial values
list(mu = c(0,0,0,0),
tau1=1,tau2=1,
phi1=0, phi2=0, phi3 = 0, phi4 =0)
# This dataset causes OpenBUGS code to crash
list(n=5,
y = structure(.Data = c(
5.8, 2.7, 9.9, 8.2, 2.9,
1.3, 5.2, 5.1, 6.0, 7.8,
9.1, 7.9, 4.1, 0.7, 6.3,
8.5, 7.6, 6.5, 6.4,10.5),
.Dim = c(5,4)))
-------------------------------------------------------------------
This list is for discussion of modelling issues and the BUGS software.
For help with crashes and error messages, first mail [log in to unmask]
To mail the BUGS list, mail to [log in to unmask]
Before mailing, please check the archive at www.jiscmail.ac.uk/lists/bugs.html
Please do not mail attachments to the list.
To leave the BUGS list, send LEAVE BUGS to [log in to unmask]
If this fails, mail [log in to unmask], NOT the whole list
|