Hello all,

I have a model in JAGS that I am willing to convert in Stan.

Basically, it adapts the IRT framework to measure policy mood using aggregate survey response data. It models the proportion of left-wing responses in each given year *y* giving response to question *q* which are repeated at different points over time.

The full model graph looks like this :

A detailed description of the IRT model can be found in this paper by McGann (2014).

Do you think it is possible to convert this JAGS code (below) in Stan?

Thank you in advance for your help. I have no idea where to start to build the model in Stan, so any tips will be helpful.

JAGS Model

```
data{
for (i in 1:len){
leftr[i]<-round(leftp[i]*n[i]/100)
}
secondyear<-startyear+1
}
model{
##loop over the data
for (i in 1:len){
sqresid[i]<-(leftp[i]-leftp.rep[i])^2
leftp.exp[i]<-m[i]*100
leftp.rep[i]<-leftr.rep[i]/n[i]*100
leftr.rep[i]~dbin(p[i], n[i])
p.rep[i]~dbeta(a[i], b)
leftr[i]~dbin(p[i], n[i])
p[i]~dbeta(a[i], b)
a[i]<--b*m[i]/(m[i]-1)
m[i]<-phi(x[i])
x[i]<-(mu[year[i]] - lambda[q[i]]) / sqrt((alpha[q[i]])^2+(sigma[year[i]])^2)
}
##priors for this model
##mu[endyear]<-0
##mu[3]<- -1
b~dunif(0, 100)
##lambda[1]<-0
##alpha[1]<-0.25
for (i in 1:nquest){
lambda[i]~dunif(-10,10)
alpha[i]~dunif(0,10)
}
for (i in 1947:1978){
mu[i]~dunif(-10, 10)
}
for (i in 1980:1996){
mu[i]~dunif(-10, 10)
}
for (i in 1998:2005){
mu[i]~dunif(-10, 10)
}
for (i in startyear:(endyear)){
sigma[i]~dunif(0,10)
}
mu[1979]<--1
mu[1997]<-1
}
```