Hurdle Model with Matrices

I am trying to create a hurdle model with simulated matrix data. I am using this site as a basis for setting up my hurdle model: 5.6 Zero-Inflated and Hurdle Models | Stan User’s Guide but I am running into an error that says:
"SYNTAX ERROR, MESSAGE(S) FROM PARSER: No matches for: poisson_lpmf(vector, vector) "
Is there another way to run the poissonlmpf with two vectors? Below is my model code.

  Pop <- matrix(rpois(c(100*200), matrix.1), nrow= 200) // simulated matrix of 100 by 200
lambda // data matrix that is 100 by 200

// simulated portion of model
target += poisson_lpmf(pop[,j] | lambda[,j]) - log1m_exp(-lambda[,j]);
1 Like

The issue is that the poisson distribution expects the outcome pop to be an integer (i.e., count data), but I would guess that you’ve declared it as:

matrix[R,C] pop;

Instead, declare it as a two-dimensional array of integers:

int pop[R,C];
1 Like

Thanks for your response. Both lambda and pop were formatted as matrix, but if I format pop as you suggested and lambda as a matrix, it works.

1 Like