Sorry if this has been posted before, been googling to try and find an answer.

Let’s say I have a model with a random effect (in this case, a random slope for a signal detection theory model). In this case, each subject (indexed by subno) has their own slope for cond.

Now let’s say i want to expand this model so that I can test how other predictors (e.g. age) predict the random participant slope for cond.

Or, perhaps, i would like to use the random slope for cond as a predictor for some other variable y.

```
# devtools::install_github("cran/sdtalt") (not on CRAN)
# Using example data set
library(sdtalt)
library(tidyverse)
library(brms)
library(tidybayes)
data(confcontr)
dat_long = confcontr %>%
mutate(cond = isold - 1/2)
m1 = brm(
sayold ~ 1 + cond + (0 + cond | subno),
data = dat_long,
family = bernoulli(link = "probit"),
warmup = 1000,
iter = 3000,
chains = 4,
init = "0",
cores = 4,
seed = 11
)
```

What is commonly done, is to extract the samples from this model and calculate each participant’s mean/median cond score (pps_cond). Then, use these estimates in a second, seperate model (e.g., y ~ pps_cond) or (pps_cond ~ age).

However, this approach wouldn’t account for uncertainty in the pps_cond scores. Alternatively, I was thinking i could randomly draw pps_cond scores for each participant from the posterior, and use brms multiple imputation function to run lots of models across different random of pps_cond scores, but I’m sure there’s a more elegant solution.

I’ve been looking into brms latent variable syntax, and I’m a little confused how it could apply it in the above situation.