My model only seems to work well with large sample size, am I making a simple mistake?

I have been trying to get this model to work for some time now, but it seems that in order for the model to return estimates that are close to my true generating ones, I have to set 15+ items per item type. I was told that if it requires this many items per type to work, then something is wrong with my model but I am not sure how to solve something like that. I have tried sum to 0 constraints but that does not seem to have a significant effect on the estimates.

The data that works well may be for instance, 200 people, 60 items, and 3 item types, such that there are 20 items of each type. However, if i do 200 people, 18 items, 3 item types, such that there are 6 items per type, there is too much error between the estimated and true parameters for beta and gamma. What can I do to solve this (if anything)?

data {
  int<lower=1> I;  // number of observations
  int<lower=1> J;  // number of items
  int<lower=1> T;  // total number of item types
  int<lower=1> N;  // total number of counts
  int<lower=0> Y[N];  // observed counts
  int<lower=1, upper=I> person_id[N]; // person id for each observation
  int<lower=1, upper=J> item_id[N]; // item id for each observation
  int<lower=1, upper=T> type[N]; // type id for each item type
}

parameters {
  vector[I] theta; 
  vector[T] gamma; 
  vector[J] beta;
}

model {
  // Priors
  theta ~ normal(0,1);
  beta ~ normal(0,1);
  gamma ~ normal(0,1);

  //sum(beta) ~ normal(0,.001*J);

  for (n in 1:N) {
    real lambda = exp(theta[person_id[n]] + beta[item_id[n]] + gamma[type[n]]);
    target += poisson_lpmf(Y[n] | lambda);
  }
}

Could you tell a bit more about your data and what about them you are trying to model? Knowing what you are trying to achieve makes it a lot easier to be helpful. I can’t really figure out what this model is meant to be used for just looking at it. The variable labels make me think of item response models (that’s what such labels would point to in my field), but that’s clearly not what you are doing. Is it about modeling purchasing behaviour or something like that?

1 Like