Access parameters from stanvars in brms

Consider the MWE

fit <- brm(bf(y~x), 
           stanvars=stanvar(block="parameters",scode="simplex[2] ss;"),
           data=lst(x=1:10, y=2*x+rnorm(10,1,1)))

Do I need to use the rstanfit obj fit$fit or is there a brms function to extract the ss samples?
@paul.buerkner

methods such as as.data.frame and friends should work I think.

Is there a way to get it through posterior_epred or alike? I don’t think dpar or nlpar there would work.

What are you trying to achieve?

Context: in my model a latent variable L is described by predictors x_i, nonlinear function f, and parameters \theta: L=f(x_1, x_2,\dots;\theta). L in turn affects two observables A and B, e.g., A \sim \mathcal{N}(L, \sigma) and B=\text{ordered_logstic}(L, \text{cut}). I don’t think brms supports this kind of model through formula (does it?), so I simply write the model for A in brms and add stan code related to B using stanvars, only that now after fitting I need extract params such as \text{cut}.

Indeed, brms does not support such a model yet. I don’t think that methods such a posterior_epred and friends are easy to enable for models that include manual stanvars parameters affecting predictions.

1 Like

Thanks. This still helps me a lot!