Hi,
I’m following Stan’s manual (Latent Discrete Parameters) to estimate a discrete parameter. All chains converge and the method seems to recover the ground truth. At least visually, but I don’t know how to summarise it with a probability statement. Let’s assume that the parameter of interest is \tau, which can take values between 360 and 4920. I have evaluated the likelihood at discrete points of this interval in increments of 120.
This is the Stan code that generates the probabilities and draws. According to Stan’s manual, sim_cp
should only be used for visual inspection, but for precise calculations (expectations), I should use prob_cp
. I would like a statement that says “There is a 95% chance that the change point (cp) is between a & b”. Any pointers as to how to do that will be highly appreciated. I got lost with the notation in the section “estimating expectations”.
generated quantities {
array[n_i_y] int sim_cp;
array[n_i_y] vector[n_cp] prob_cp;
for(i in 1:n_i_y) {
sim_cp[i] = cp[categorical_logit_rng(lp[i, ])];
prob_cp[i] = softmax(lp[i]);
}
}
In R, for a given individual i, I have a data frame with three columns (sample.csv (1.3 KB)), where j
is the index of the change point, prob_cp the
probability, and .iter
the iteration.
Thanks.