I’m fitting a multinomial (by means of Poisson) IRT/ideal point model for category counts in policy documents with
Count(document, category) ~ Poisson(exp(alpha_doc + psi_cat + beta_cat*theta_doc))
As constraints, one psi and one beta are set to zero, and the ideal points theta receive a standard normal prior. A conditional statement based on the order of two betas is used to reverse the scale when necessary (I know that half-normal priors might be better for that, but I had mixed experiences when working with those).
It seems
that the constraints are sufficient to identify the model, at least I get very
similar results across different runs. It seems to work since the standard
normal prior on the ideal points theta apparently leads to a standard normal posterior
distribution of the ideal points. Is there a simple answer why this happens? I
would not necessarily have expected that, and when I code the same model in
Jags, theta does not come out standardized in the posterior and the model lacks
identification. Is it ok to rely on the prior doing the job in Stan or would it
still be better to standardize the ideal points deterministically (probably at
the expense of speed?)? Any hints appreciated.
Code is as follows:
data {
int<lower=1> dir[2]; // doc id pair to set direction
int<lower=1> D; // number of docs
int<lower=1> T; // number of terms/categories
int<lower=1> N; // number of obs = number of docs * number of cats
int<lower=1> doc[N]; // doc id
int<lower=1> term[N]; // cat id
int<lower=0> y[N]; // counts as one long vector
}
parameters {
vector<lower=-20, upper=20>[D] alpha;
vector[T-1] psi_rest; // unconstrained elements of psi
vector[D] theta;
vector[T-1] beta_raw; // unconstrained elements of beta
real<lower=0> tau_psi;
real<lower=0> tau_beta;
}
transformed parameters {
vector[T] psi;
vector[T] beta;
real<lower=0> sigma_psi;
real<lower=0> sigma_beta;
psi[1] <- 0; // first cat. as reference cat.
beta[1] <- 0;
for (t in 2:T){
psi[t] <- psi_rest[t-1];
if (beta_raw[dir[2]-1]-beta_raw[dir[1]-1] > 0) {
beta[t] <- beta_raw[t-1];
}
else {
beta[t] <- -beta_raw[t-1];
}
}
sigma_beta <- 1/sqrt(tau_beta);
sigma_psi <- 1/sqrt(tau_psi);
}
model {
vector[N] logmu;
// alpha ~ uniform(-20,20); implicit above
psi_rest ~ normal(0,sigma_psi);
beta_raw ~ normal(0,sigma_beta);
theta ~ normal(0,1);
tau_beta ~ gamma(.01,.01);
tau_psi ~ gamma(.01,.01);
for(n in 1:N){
logmu[n] <- alpha[doc[n]] + psi[term[n]] + theta[doc[n]] * beta[term[n]];
}
y ~ poisson_log(logmu) ;
}
--
You received this message because you are subscribed to a topic in the Google Groups "Stan users mailing list" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/stan-users/pt34sBaCHk8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to stan-users+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To unsubscribe from this group and all its topics, send an email to stan-users+unsubscribe@googlegroups.com.
You received this message because you are subscribed to the Google Groups "Stan users mailing list" group.
To unsubscribe from this group and stop receiving emails from it, send an email to stan-users+...@googlegroups.com.