Hi all,

I want to use brms to model a DAG like the one below:

Where the subscripts \{1, 2, 3\} represent time.

Suppose this is my data:

```
print(XY)
X1 X2 X3 Y1 Y2 Y3
1 108.2 110.9 131.0 162.2 143.1 89.1
2 89.8 88.1 87.7 156.5 248.6 287.6
3 97.7 102.7 125.5 235.0 415.4 657.1
4 98.4 84.1 84.6 226.3 375.5 506.0
5 85.1 97.2 125.3 202.6 274.9 269.6
```

Where the model looks something like this:

Basically, the aim is to do partial pooling for the \alpha, \beta, \lambda coefficients across time, and to understand their correlation across time also. What I am struggling to do in brms is passing in multiple dataframes, say, a dataframe each for X_1, X_2, X_3, Y_1, Y_2, Y_3 so that each dataframe can have another column to indicate the time index and the dependent variable for that node.

So far, because I do not know how to pass in multiple dataframes into brms, the code I have put together below does not do partial pooling:

```
x2 = bf(X2 ~ 0 + X1)
x3 = bf(X3 ~ 0 + X2)
y1 = bf(Y1 ~ 0 + X1)
y2 = bf(Y2 ~ 0 + Y1 + X2)
y3 = bf(Y3 ~ 0 + Y2 + X3)
fit1 = brm(data = XY,
family = gaussian,
formula = y1 + x2 + y2 + x3 + y3 + set_rescor(TRUE),
prior = c(
# x2 model
prior(normal(0, 1), class = b, resp = X2),
prior(exponential(1), class = sigma, resp = X2),
# x3 model
prior(normal(0, 1), class = b, resp = X3),
prior(exponential(1), class = sigma, resp = X3),
# y1 model
prior(normal(0, 1), class = b, resp = Y1),
prior(exponential(1), class = sigma, resp = Y1),
# y2 model
prior(normal(0, 1), class = b, resp = Y2),
prior(exponential(1), class = sigma, resp = Y2),
# y3 model
prior(normal(0, 1), class = b, resp = Y3),
prior(exponential(1), class = sigma, resp = Y3),
# rho
prior(lkj(2), class = rescor)
)
)
```

Or, is there a way to manually create a grouping column with levels within the brmsformula? That way, I do not need to pass in multiple dataframes and a single dataframe will do. An example may be something like this (the non-working code below is just to demonstrate what I mean):

```
x2 = bf(X2 ~ 0 + (0 + X1 | level = "1", group = "alpha"))
x3 = bf(X3 ~ 0 + (0 + X2 | level = "2", group = "alpha"))
y1 = bf(Y1 ~ 0 + (0 + X1 | level = "1", group = "lambda"))
y2 = bf(Y2 ~ 0 + (0 + Y1 | level = "1", group = "beta") + (0 + X2 | level = "2", group = "lambda"))
y3 = bf(Y3 ~ 0 + (0 + Y2 | level = "2", group = "beta") + (0 + X3 | level = "3", group = "lambda"))
```

P.S. I am still new to brms and Bayesian modelling, so feel free to correct me or give feedback on my math notation and brms code.

Any help will be appreciated.

- Operating System: 64-bit operating system, x64-based processor
- brms Version: brms_2.15.0