SHARE
TWEET

Untitled

a guest Sep 19th, 2019 194 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. library(rjags)
  2.  
  3. mod_cat <- "model{
  4.  
  5. # for(i in 1:n){
  6. # y[i,1:2] ~ dmnorm.vcov(mu[], Sigma[1:2,1:2])
  7. # }
  8.  
  9.  
  10. mu[1] <- 0
  11. mu[2] <- 0
  12.  
  13. IndA ~ dcat(PInd[])
  14.  
  15. PInd[1] <- 0.33333
  16. PInd[2] <- 0.33333
  17. PInd[3] <- 0.33333
  18.  
  19.  
  20. z ~ dnorm(0, pow(0.5, -2))T(T1[IndA],T2[IndA])
  21. rho <- tanh(z)
  22.  
  23. sigma_11 ~  dgamma(1, 1/5)
  24. sigma_22 ~  dgamma(1, 1/5)
  25.  
  26. Sigma[1,1] <- pow(sigma_11, 2)
  27. Sigma[2,2] <- pow(sigma_22, 2)
  28.  
  29. Sigma[1,2] <- (rho[1] * sigma_11 * sigma_22)
  30. Sigma[2,1] <- Sigma[1,2]
  31.  
  32. TauM[1] <- pow(0.001, -2);    
  33. TauM[2] <- pow(0.4, - 2);
  34.  
  35. T1[1] <- -0.01
  36. T1[2] <- 0
  37. T1[3] <- -1
  38.  
  39. T2[1] <- 0.01
  40. T2[2] <- 1
  41. T2[3] <- 0
  42.  
  43. }"
  44.  
  45.  
  46. fit <- jags.model(textConnection(mod_cat))
  47.  
  48. codaSamples = coda.samples(fit,
  49.                            variable.names=c("IndA", "rho"),
  50.                            n.iter= 500000)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top