I am developing a structured model that has a latent variable portion. I am taking the approach outlined in Full Luxury Bayesian SEM. Models will be of the form (stealing from the link):
bf_lv <-
# The LV itself - performance given missingness
bf(performance | mi() ~ 0) +
# latent variable indicators
bf(clonediam_s ~ 0 + mi(performance)) +
bf(numbstems_s ~ 0 + mi(performance)) +
bf(numbinfl_s ~ 0 + mi(performance)) +
set_rescor(FALSE)
# priors
priors_lv <- prior(constant(1),
coef = "miperformance",
resp = "clonediams") +
prior(gamma(11, 11), class = "sigma", resp = "performance")
# now the fit - note, we have to add an NA
# for performance column
b_lv <- brm(bf_lv,
data = spartina |>
mutate(performance = as.numeric(NA)),
prior = priors_lv,
file = "fit_models/b_lv.rds"
)
My question is if priorsense will work to evaluate prior-data conflict in these models, which types of parameters can be assessed (e.g., Can the effect of the prior on the coefficient from performance to height be assessed? If performance is then used to predict some other measured variable, could the effect of the prior on that effect be examined?), and how to structure the call or pull out the necessary information from the brmsfit object to use priorsense?
In short, yes it should be possible to use priorsense with this type of model. I will write a detailed explanation shortly after going through it myself. But note that there are a few relevant recently added features and bug fixes in brms and priorsense so that the github versions of both packages likely need to be used
Will definitely use the github versions. Yeah, I saw the change that was required to brms to produce _lprior that happened recently, so I anticipated as much. Thanks!
I’m currently working on a vignette which will show selection of priors to power-scale and specifying posterior quantities to check. But in the meantime, here are brief answers to your questions. These will require the development branch of priorsense until it is merged to main (hopefully tomorrow).
Can the effect of the prior on the coefficient from performance to height be assessed?
I believe that if you specify a prior tag like so, then this is getting at what you want:
prior(
normal(0, 10),
class = "b",
coef = "miperformance",
resp = "meanhts",
tag = "bsp_meanhts_miperformance"
)
You can then check this prior with priorsense:
powerscale_sensitivity(
mod_spartina,
variable = "bsp_meanhts_miperformance",
prior_selection = "bsp_meanhts_miperformance",
resp = c("meanhts") # here might alternatively be all the non-missing responses
)
If performance is then used to predict some other measured variable, could the effect of the prior on that effect be examined?
(I took this to mean checking the effect of power-scaling the bsp_meanhts_miperformance prior on the posterior of some other parameter, let me know if you meant something else). You can do this by specifying a different variable but keeping prior_selection = "bsp_meanhts_miperformance". If you want to check the sensitivity of predictions, there is the predictions_as_draws function, which you can use to wrap around a function from brms like posterior_epred.
Hope this helps, and let me know if you would like more info.