Hi Everyone. I’m trying to figure out how to generate 100 random values from a categorical distribution with a fixed parameter set. However, I appear to be stuck and google and the manual have returned nothing I can piece together.
I am almost certain that it doesn’t appreciate my definition of the constant simplex[3] theta = {0.5,0.3,0.2};
line, in fact it tells me so, but I do not know how to properly define it so this runs correctly. Any suggestions?
Stan Code
data {
int N;
}
generated quantities {
simplex[3] theta = {0.5,0.3,0.2};
int y[N];
for (i in 1:N){
y[i] = categorical_rng( theta );
}
}
R code
simu_data <- list(N = 100)
fit <- sampling(generative2, data=simu_data, iter=1000, algorithm = 'Fixed_param')
Any assistance is greatly appreciated.