Sunteți pe pagina 1din 1

## Graded response model to handle ordinal forecasts

model{
for (i in 1:nr){ ## Rows of data matrix
of[i] ~ dcat( p[i, 1:ncat] )
## Q represents cumulative probabilities of responding
## to a particular category or below; see, e.g.,
## Smithson & Merkle, 2014; Gelman & Hill, 2007
Q[i, 1] <- 0
for (m in 1:(ncat-1)){
probit(Q[i, (m+1)]) <- b0[ifpidx[i], m] + (b1[ifpidx[i]] - b0[ifpidx[i], m
])*exp(b2*nd[i]) + lambda[ifpidx[i]] * theta[uidx[i]]
p[i, m] <- Q[i, (m+1)] - Q[i, m]
}
p[i, ncat] <- 1 - Q[i, ncat]
}
for (j in 1:n){ ## Users
thetstar[j] ~ dnorm(0, thetprec)
theta[j] <- sgn * thetstar[j] / thetsd
}
thetprec ~ dgamma(.01, .01)
thetsd <- 1/sqrt(thetprec)
sgn <- ifelse(lamstar[1] < 0, -1, 1)
for (k in 1:K){ ## IFPs
lamstar[k] ~ dnorm(0,1)
lambda[k] <- sgn * lamstar[k] * thetsd
## Convert to threshold estimate
## would have to consider unique thresholds
## for each category
##thresh[k] <- -b0[k] ## Starting threshold
##thresh2[k] <- -b1[k] ## Ending threshold
## Convert to IRT parameters (slope/intercept form)
##delta[k] <- -thresh[k] / sd[k]
##delta2[k] <- -thresh2[k] / sd[k]
##alpha[k] <- lambda[k] / sd[k]
## Intercept priors
for (m in 1:(ncat-1)){
b00[k, m] ~ dnorm(0, .01)
}
b0[k, 1:(ncat-1)] <- sort(b00[k, 1:(ncat-1)])
b1[k] ~ dnorm(0, .5)
}
## Time effect
b2 ~ dnorm(0, .5)
}

S-ar putea să vă placă și