I am having a problem with identifiability when using non centered parameters. My beta and type parameters (when i use real data) will likely be positive, lets say normal(1,.5) for beta and normal(2,.5) for type. And so, since neither are centered at 0 it is making it difficult to model this. My data is structured as follow: theta = people, beta = test item difficulty, type = item type effect. So i could have 100 people taking 40 items, where each item is 1 of 4 types. Important to also note that the type an item is does not change between persons, so item 1 for instance, if type 3, is always type 3.
I have tried to use a sum to 0 constraint on type or beta, however i run into problems when doing that. Because my beta parameters are mostly all positive, the pinned last beta value to be the - sum ends up being a large negative number which makes it difficult to estimate the type parameter that contains that constrained beta. Similarly with type. I then tried to pin a value of beta or type to 0, but it does not seem to consistently work well. What else can i do in this case?
here is my data generation
J <- 150
I <- 40
K <- 4
theta <- rnorm(J, 0, .4)
beta <- rnorm(I, .7, .5)
type <- rnorm(K, 2, .5)
type[1] <- 0
N <- I*J
ii <- rep(1:I, times = J)
jj <- rep(1:J, each = I)
kk <- rep(1:K, times = N/K)
y <- numeric(N)
for(n in 1:N){
y[n] <- rpois(1,exp(theta[jj[n]] + beta[ii[n]] + type[kk[n]]))
}
fit <- sampling(mod, data = list(I = I,
J = J,
N = N,
ii = ii,
jj = jj,
kk = kk,
K = K,
y = y),
iter = 4000)
data {
int<lower=0> I;
int<lower=0> J;
int<lower=0> K;
int<lower=1> N;
int<lower=1,upper=I> ii[N];
int<lower=1,upper=J> jj[N];
int<lower=1,upper=K> kk[N];
int<lower=0> y[N];
}
parameters {
vector[J] theta;
vector[K] type;
vector[I-1] b_free;
real<lower=0> sigma_beta;
real<lower=0> sigma_type;
real<lower=0> sigma_theta;
real mu_type;
real mu_beta;
}
transformed parameters{
vector[I] beta = append_row(0, b_free);
}
model {
sigma_theta ~ cauchy(0,2);
sigma_beta ~ cauchy(0,2);
sigma_type ~ cauchy(0,2);
mu_type ~ normal(0,3);
mu_beta ~ normal(0,3);
theta ~ normal(0,sigma_theta);
beta ~ normal(mu_beta,sigma_beta);
type ~ normal(mu_type,sigma_type);
y ~ poisson_log(theta[jj] + beta[ii] + type[kk]);
}