# PIECEWISE STRUCTURAL EQUATION MODELING with brms and family=cumulative()

**URL:** <https://discourse.mc-stan.org/t/piecewise-structural-equation-modeling-with-brms-and-family-cumulative/34853>\
**Category:** Modeling\
**Tags:** brms\
**Created:** [April 19, 2024, 11:01am UTC](https://discourse.mc-stan.org/t/piecewise-structural-equation-modeling-with-brms-and-family-cumulative/34853 "2024-04-19T11:01:36Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![RubenST](https://avatars.discourse-cdn.com/v4/letter/r/a5b964/32.png) [@RubenST](https://discourse.mc-stan.org/u/RubenST)\
**Post date:** [April 19, 2024, 11:01am UTC](https://discourse.mc-stan.org/t/piecewise-structural-equation-modeling-with-brms-and-family-cumulative/34853/1 "2024-04-19T11:01:36Z")

</div>

I am very new to this, but I have manage to run this code:

bf\_1 ← bf(Response ~ Type + gender + treatment+ Exam + (1|Course:ID)) + gaussian()  
bf\_2 ← bf(Score ~ Response + Exam + (1|Course:ID)) + gaussian()

fit3 ← brm(  
bf\_1 + bf\_2 + set\_rescor(FALSE),  
data = base.analysis,  
chains = 6, cores = 6,  
control = list(adapt\_delta = 0.95)  
)

Response = answeres of a survey I gave my students. This is a 1-7 respons (Likert scale).

Type = The questions they ansered is categorized into two “types”.

treatment = some of them is in a treatment group, given an intervention (0 = control, 1=treatment).

Exam = The first or second exam (1 or 2). I want to see if students improved their score, specially if they were in the treatment group.

I am also interested to see if the treatment changed how they answered (Response) between the first and second exam. The questions are about their anxiety towards the test, and my hypothesis is that the treatment group will have lower respons (lower anxiety) and score better.

But! since the responses are on a Likert scale, I was hoping to use family = cumulative() on the first model (bf\_1). But when I run it with family = cumulative() it doesnt seem to work correctly… For example it is not able to draw the predictions.  
Again, I am very new to this, so maybe I am doing something stupid. But I think the problem is that when calling for cumulative, it gives multiple intercepts, and that might be the issue when it then tries to use those predicted intercepts to the response “Score” in the next model?

I appreciate all the help I get get.  
Thanks

-R

---

<div class="post-metadata">

**Author:** ![zacho](https://avatars.discourse-cdn.com/v4/letter/z/ccd318/32.png) [@zacho](https://discourse.mc-stan.org/u/zacho)\
**Post date:** [April 25, 2024, 12:03am UTC](https://discourse.mc-stan.org/t/piecewise-structural-equation-modeling-with-brms-and-family-cumulative/34853/2 "2024-04-25T00:03:39Z")

</div>

Welcome Ruben.  
You may need to flesh out your question with an example or fake dataset. Can you get a simple example with `family = cumulative()` working?

> But I think the problem is that when calling for cumulative, it gives multiple intercepts, and that might be the issue when it then tries to use those predicted intercepts to the response “Score” in the next model?

I may be wrong here, but I don’t think `brms` will connect the two models like you’re thinking (piecewise SEM) since residual correlation was turned off (`set_rescor(FALSE)`) – hopefully someone else advises here. Does the model for `bf_2` on its own match what you’re seeing?
