Hello @LachlanC, there was some discussion on a related topic before here Brms & pk models? which is a part of PK model workflow (the dataset is per-observation but post-processing is per-subject).
I think your need is a bit different, which is to express two simultaneous models where a predictor variable in the second model is the response variable from the first model. In your syntax the first part of the model predicts the latent true value for each observation \mu_{1i}, and then that latent value is the predictor in the second part.
I wonder if there is a way that the complete length dataset could be populated with the predicted value at each replicate, in the non-linear syntax (so that no row reduction is required). Personally I think I’d do this directly in Stan though. You can define the latent variable in the transformed parameters
block, and then pass it directly to the second component of your model. Maybe using the brms
code from make_stancode()
for your two submodels would be convenient.