Hello all,
I have been trying to implement a hierarchical Dirichlet-Categorical model in stan to model spatial variation in fish diets. Specifically, my interest is to obtain the probabilities of encounter for each prey category at a given site (theta). The hierarchical structure of the model needs to include a linear model with an intercept and a continuous covariate (fish size) with the softmax link function, which I did not manage to include. I have the model implemented in JAGS, but I’m having trouble translating it to STAN. What follows is what I have so far:
data {
int<lower=1> N_obs; // number of observations
int<lower=1> N_prey; // number of categories
int site[N_obs] ; // categorical covariate
int N_sites; // number of sites
int y[N_obs]; // outcomes
}
parameters {
simplex[N_prey] theta[N_sites];
vector<lower=0>[N_prey] alpha;
}
model {
for (k in 1:N_prey) {
alpha ~ uniform(0,100); // weak prior on alpha
}
for (n in 1:N_sites) {
theta[n] ~ dirichlet(alpha);
}
for (i in 1:N_obs)
y ~ categorical(theta[site[i]]);
}
I would greatly appreciate if anyone could show me how to expand the model!