Hi all!
I am glad to have found this community to discuss tricky issues with the experts!
I carefully read another post on longitudinal mediation using BRMS (Longitudinal mediation analysis), and came up with an additional question.
But since that post dates back quite some time, I thought it would be beneficial to create a new post!
So, I am trying to estimate a longitudinal mediation where the mediator itself is time-varying.
I built the code based on the suggestion from the previous post!(Longitudinal mediation analysis)
a <- bf(health ~ gp(time) + gp(time, by = status_dum) + gp(time, by = poverty)+ (1 | id))
b <- bf(status_dum ~ gp(time) + gp(time, by = poverty) + (1 | id))
brm(a + b + set_rescor(FALSE), data = dts)
In my model using panel data that were annually surveyed, health is the dependent variable (continuous), poverty is the independent variable (continuous), and status_dum is the mediator (dichotomous).
While in the previous post, it was recommended to use either s (spline) or gp (gaussian) as the estimator (?), since my mediator is a dichotomous variable, I believe both these options are not appropriate.
Actually, ChatGPT… suggested estimating the model with the following code:
model ← brm(
formula = c(a, b),
family = c(“gaussian”, “bernoulli”),
data = your_data
)
However, since GPT’s suggestion differs too much from the expert suggestion from the previous post, I am opening a new post , seeking advice from the experts!
I would really appreciate the help from the community.
Thank you so much!!
Updated (Feb.12)
I built the following code by trying to include the family inside bf(), but I am not at all sure if it makes sense… I would really appreciate if someone could review it…!
a ← bf(health~ time + status_dum+ poverty+ (1 | id), family = “gaussian”)
b ← bf(status_dum~ time + poverty+ (1 | id), family = “bernoulli”)
brm(a + b + set_rescor(FALSE), data = dts)
- Operating System: R
- brms Version: latest