easystats / bayestestR

:ghost: Utilities for analyzing Bayesian models and posterior distributions
https://easystats.github.io/bayestestR/
GNU General Public License v3.0
563 stars 55 forks source link

mediation with censored data using brm and bayestestR #631

Open shakhlonematova opened 11 months ago

shakhlonematova commented 11 months ago

Describe the bug When trying to run a mediation analysis with a censored outcome variable in one of the models using brms (2.20.4) and bayestestR (0.13.1), I am getting the following error:

Error in .subset2(x, i, exact = exact) : subscript out of bounds

To Reproduce

f1 <-bf(pa_comp_transformed ~ composite)
f2 <- bf(dscore | cens(dscore>=4) ~ modality*pa_comp_transformed+modality*composite+(1|subject))
m2 <- brm(f1 + f2 + set_rescor(FALSE), data = test_df, refresh = 0)
mediation_result <- bayestestR::mediation(m2)

Expected behaviour I expected the mediation() function to handle the models with censored data

Specifiations (please complete the following information): R Studio Version 2023.09.0+463 R version 4.3.1 (2023-06-16) brms (2.20.4) bayestestR (0.13.1)