I’m trying to figure out if STAN can do the following: I need to fit a logistic regression model, then use the beta coefficients to predict the response (1/0) on new data, segregate and count the response (1/0) based on certain conditions, then plug in those counted / segregated predicted responses into a 2nd model. I need all of these steps to occur within each iteration of the chain.
I’m working on creating a rather specific Bayesian model (a unique case of a Binary Diagnostic Test for the Two Tests, Two Populations scenario). Instead of having 2 tests, the plan is to have 1 test and use a predictive model to simulate results for the 2nd test (based on old data from the same populations). The test results are binary (0 or 1).
The motivation for having this all happen within each iteration, rather than simply plugging in the average 1s/0s from the predicted model, is to capture the extra uncertainty that comes from the predictive model that wouldn’t occur if we had an actual 2nd test. Having the predicted test results change at every iteration is my proposal to account for this variability.
My understanding of STAN is that predictions are recommended to be made in the generated quantities block. Is there a way to then pull these predictions from the generated quantities block back into the model statement for input into a second model (within the same iteration)?
Thanks very much for your time. Happy Holidays!