# Categorical and continuous variables in a DAG

Hello,

May I ask a question about how to transfer DAG into logistic regression? I have a few categorical and continuous variables in a DAG. For one continuous variable’s causal effect on the outcome (binomial), it tells me I will need to control two categorical variables. I wonder if I should just put these two categorical variables as varying intercept like in mod1 below, or use them to build a multilevel model for both intercept and slope of the logistic regression? For instance, if I got A and B as two categorical variables, X as the continuous variable and DAG tells me to control A and B for X → outcome. Which model would make sense? Thank you very much.

``````mod1 <- brm(
data = df, family = bernoulli(link = "logit"),
bf(outcome ~ a + b + c,
a ~ 0 + A,
b ~ 0 + B,
c ~ 0 + X,
nl = TRUE),
prior = c(prior(normal(0, 1.5), nlpar = a),
prior(normal(0, 1.5), nlpar = b),
prior(normal(0, 1.5), nlpar = c)),
iter = 2000, warmup = 1000, chains = 4, cores = 4)
``````
``````mod2 <- brm(
data = df, family = bernoulli(link = "logit"),
bf(outcome ~ a + b + c + d,
a ~ 0 + A,
b ~ 0 + B,
c ~ 0 + (X || A),
d ~ 0 + (X || B),
nl = TRUE),
prior = c(prior(normal(0, 0.8), nlpar = a),
prior(normal(0, 0.8), nlpar = b),
prior(normal(0, 0.8), nlpar = c),
prior(normal(0, 0.8), nlpar = d)),
iter = 2000, warmup = 1000, chains = 4, cores = 4)
``````
``````mod3 <- brm(
data = df, family = bernoulli(link = "logit"),
bf(outcome ~ 1 + A + B + X + (1 | A) + (1 | B) + (X || A) + (X || B)),
prior = c(prior(normal(0, 1.5), class = Intercept),
prior(normal(0, 0.5), class = b),
prior(normal(0, 1), class = sd)),
iter = 2000, warmup = 1000, chains = 4, cores = 4)
``````