Say I specify a blavaan model with named and derived parameters, such as with the simple mediation model below.
model_str <- 'mpg ~ 1 + b11*cyl + b12*hp
hp ~ 1 + b21*cyl
mpg ~~ mpg
hp ~~ hp
direct := b11
indirect := b21 * b12
total := b11 + b21 * b12'
mod <- blavaan(model_str, data = mtcars)
I can’t figure out how (if it is possible) to extract the draws of the named and derived parameters. I can summarize them with summary(mod). I can get the draws of the underlying model parameters with blavInspect(mod, "mcmc"). And I can get their point estimates through other means by way of coef(mod, type = "user"). But I can’t quite figure out this last bit. Looking at the underlying Stan code, it looks like these derivations are done after-the-fact. So unfortunately it doesn’t seem possible to pull them directly from the model results.
You are right that derived parameters are not in the blavaan model, because that model is pre-compiled. The estimates you see from summary() and others are based on the delta method. This post shows how to extract the posterior samples and do things with them yourself: https://groups.google.com/g/blavaan/c/69ukdYLpHXI/m/Ed6oQn94AAAJ
Edit: And easier than I was expecting! In case it’s helpful to others, I’ve put a first pass at a function that is working well in my case. Can’t guarantee it’s generalizable or tested, but hopefully it’s helpful. Thanks again, Ed.