Skip to content

mediation with censored data using brm and bayestestR #631

@shakhlonematova

Description

@shakhlonematova

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)
  • if we the model is run without censoring, the mediation() function works fine

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions