Unable to find appropriate sampler - Wishart

Help
2013-11-17
2013-11-22
  • Richard James

    Richard James - 2013-11-17

    Hello,

    I'm running the below model, but keep receiving the message: "Error in node OmegaZ: Unable to find appropriate sampler". I also get the same error for Omegares.

    This appears to be related to the parametrization of OmegaZ and Omegares as wishart distributions, as when they are fixed (e.g. OmegaZ <-0), the model runs fine. Is there a way around this problem with the Wishart distribution?

    I have tried using a gamma distribution instead, but this throws up a "Cannot invert matrix: not positive definite" error. Is there a way to ensure positive-(semi)-definiteness of matrices in JAGS?

    Thanks for any help.

    model {
    
      ## measurement error SigmaZ
       for(j in 1:J) {
        muZ[j] <- 0 
        }
    
      # covariance matrix
      OmegaZ ~ dwish(R.Sigma,k.Sigma) 
      SigmaZ<-inverse(OmegaZ)
    
      # lab replicates likelihood
      for(iz in 1:Nz) {
        Z[iz,1:J] ~ dmnorm(muZ,OmegaZ) 
      }
      ## end measurement error SigmaZ
    
      ## proportions p
      # hyperparameters
      for(k in 1:(K-1)) {
        muPhi[k] ~ dnorm(alpha.clr[k],0.001) 
        tauPhi[k] ~ dgamma(0.001,0.001) 
        sigma2Phi[k] <- 1/tauPhi[k] 
      }
    
      # Prior on p
      for(i in 1:N) {
        p[i,1:K] <- expphiV[i,1:K]/sum(expphiV[i,1:K])
        phiV[i,1:K] <- Phi[i,1:(K-1)]%*%tV
        for(k in 1:K) {
          expphiV[i,k] <- exp(phiV[i,k])
        }
      }
    
      # Prior on phi
      for(i in 1:N) {
        for(k in 1:(K-1)) {
          Phi[i,k] ~ dnorm(muPhi[k],tauPhi[k])
        }
        philast[i] <- -sum(Phi[i,1:(K-1)])
      }
    
      ## end proportions p
    
      # covariance matrix residual error
      Omegares ~ dwish(R.Sigma,k.Sigma)
    
      Sigmares <- inverse(Omegares)
    
       ## end residual error
    
      ## targets
      for(i in 1:N) {
        for(j in 1:J) {
          muj[i,j] <- p[i,]%*%muS[,j] 
        }
    
        # combined covariance matrix of source variation (propagated through mixing model)
        for(k in 1:K) {
          for(j1 in 1:J) {
            for(j2 in 1:J) {
              SigmaSp[j1,j2,k,i] <- SigmaS[j1,j2,k]*p[i,k]^2 # HF16
            }
          }
        }
    
        # combined covariance matrix of source variation (propagated through mixing model), measurement error and residual error (covariances additive)
        for(j1 in 1:J) {
          for(j2 in 1:J) {
            SigmajresZ[j1,j2,i] <- sum(SigmaSp[j1,j2,,i]) + SigmaZ[j1,j2] + Sigmares[j1,j2] # HF15,16
            }
        }
    
        # combined precision matrix
        OmegajresZ[1:J,1:J,i] <- inverse(SigmajresZ[,,i])
    
        # target data likelihood
        Y[i,1:J] ~ dmnorm(muj[i,],OmegajresZ[,,i]) 
      }
      ## end targets
    
    }
    
     
  • Martyn Plummer

    Martyn Plummer - 2013-11-22

    The only sampling method available for Wishart distributions is the conjugate Wishart sampler and your model falls outside of its scope. The Wishart distribution is also the only one that will generate a positive definite symmatrix matrix required by the multivariate normal distribution.

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks