data modeling - WinBUGS error: vector valued relation z must involve consecutive elements of variable -
i trying model multivariate probit model binary data. have been trying winbugs in return gives me error. ideas or suggestion warmly welcomed.
model{ (i in 1:ns){ ## loop on studies
for (k in 1:2){ ### loop on arm (j in 1:2){ ### loop on outcomes r[i,k,j] ~ dbin(p[i,k,j],n[i,k,j]); ## likelihood function p[i,k,j] <- phi(z[i,k,j]) z[i,k,1:2] ~ dmnorm(theta[i,1:2],with[i,,])i(-5, 5) #latent variable (z<0) or probit link theta[i,1] <- alpha[i,k,1] + beta[i,k,1] theta[i,2] <- alpha[i,k,2] + beta[i,k,2] } ###close loop on outcomes } ###close loop on arms alpha[i,2,1] <- 0 alpha[i,2,2] <- 0 alpha[i,1,1:2] ~ dnorm(0,.0001) beta[i,2,1:2] ~ dmnorm(d[1:2],prec[,]) beta[i,1,1] <- 0 beta[i,1,2] <- 0 ## priors on within study cov matrix with[i,1:2,1:2] <- inverse(cov.mat[i,1:2,1:2]) #define elements of within-study covariance matrix cov.mat[i,1,1] <- 1 cov.mat[i,2,2] <- 1 ### prior ipd data ###### cov.mat[i,1,2] ~ dbeta(a[i],b[i]) cov.mat[i,2,1] <- cov.mat[i,1,2] a[i]<-31.97 b[i]<- 4.52 }#### close loop on studies (i in 1:2) { d[i] ~ dnorm(0.0000e+00, 0.0001) # overall treatment effects } ## priors on between study cov matrix prec[1:2,1:2]<-inverse(tau[1:2,1:2]) pi<-3.14/2 a1~dunif(0, pi) rho.tau<-cos(a1) sd[1]~dunif(0,2) sd[2]~dunif(0,2) tau[1,1]<-pow(sd[1],2) tau[2,2]<-pow(sd[2],2) tau[2,1]<-tau[1,2] tau[1,2]<-sd[1]*sd[2]*rho.tau } #end model
these data:
list(ns=2) t[,1,1] t[,1,2] t[,2,1] t[,2,2] r[,1,1] n[,1,1] r[,2,1] n[,2,1] r[,1,2] n[,1,2] r[,2,2] n[,2,2] 1 0 1 0 19 77 23 77 60 82 70 82 1 0 1 0 27 199 54 199 231 393 318 393 end
the model syntactically correct , allows me load data. once compile error in title. thank given
it looks if inputting 2 2 matrix mean of multivariate normal distribution right here.
z[i,1:2,k] ~ dmnorm(theta[i,,],with[i,,])i(-5, 5) #latent variable (z<0) or probit link
however, appears if z
vector of length 2. need input vector mean of dmnorm
, give associated variance covariance matrix (i.e. if supply vector of length 3, needs have 3 3 variance covariance matrix). right have 2 2 matrix input mean (4 parameters) , 2 2 variance covariance matrix. not know motivation behind model can't provide suggestions on how fix per se, seems me need index theta
bit more in order prevent putting matrix dmnorm
.
Comments
Post a Comment