# X - observed conservative statements about issue # n - number of statements (conservative + liberal) made about issue # Z - Latent Left-Right Placement # Beta - Coefficient relating latent variable to observed variable model{ for(i in 1:npe){ #loop through party-elections for(j in 1:ncolx){ #loop through issues X[i,j] ~ dbin(p[i,j], n[i,j]) logit(p[i,j]) <- alpha[j] + beta[j] * Z[party[i], elec[i]] } } beta[1] <- 1 alpha[1] ~ dnorm(0,1) for(i in 2:ncolx){ beta[i] ~ dnorm(0, 1)I(0, ) # Here, betas are truncated to be positve, theoretically defensible alpha[i] ~ dnorm(0,1) } for(j in 1:nparty){ Z[j, 1] ~ dnorm(0, tau.Z[1]) for(i in 2:nelec){ Z[j, i] ~ dnorm(Z[j, i-1], tau.Z[2]) } } tau.Z[1] ~ dgamma(1, .1) tau.Z[2] ~ dgamma(1, .1) }