I am trying to estimate a simple mediation model with random intercepts grouped by participant (id
) . My mediating variable (m
) is in [0,1]
and my outcome variable (y
) is measured on the ratio level, in range[0,35]
(see toy data below). I am working in brms
and have tried to solve for my use case by implementing logistic regression on my x - > m
regression and ordinary regression on my x + m -> y
regression.
This is the code I’ve used:
#define formulae
mod_y = bf(y ~ x + m + (1 | id))
mod_m = bf(m ~ x + (1|id), family=bernoulli(link = "logit"))
#estimate
fit = brm(mod_y +
mod_m +
set_rescor(FALSE),
data = dat,
warmup = 2000,
iter = 8000,
chains = 2,
inits= "0",
cores=4,
seed = 123,
sample_prior = TRUE,
save_pars = save_pars("all"))
My question is how do I interpret the Estimate
column in summary(fit)
. My understanding of OLS style regressions is that in this case the x -> y
estimates should capture change in y
as a function of change of 1 in x, whereas the x -> m
estimates should capture change in the log-odds of m = 1
as a function of change of 1 in x
. Is this still true in the brms
output, i.e. do different rows in the Estimate
column have different concrete interpretations?
As a corollary, given the model specified above, what is the correct way to concretely interpret products of paths given the estimates may be measured on different scales? For example, to test whether the indirect effect
(x -> m -> y
, or ab in mediation terminology) is negative I would use the method, hypothesis(fit, 'y_m*m_x< 0')
. Is this still correct and how would I interpret the resulting CI in terms of unit change in y
as a function of change in x
?
Here’s my toy data for purposes of clarity:
dat = structure(list(id = c("2552a7771658870ed27965140ecff784", "2552a7771658870ed27965140ecff784",
"2552a7771658870ed27965140ecff784", "2552a7771658870ed27965140ecff784",
"2552a7771658870ed27965140ecff784", "2552a7771658870ed27965140ecff784",
"2552a7771658870ed27965140ecff784", "2552a7771658870ed27965140ecff784",
"2552a7771658870ed27965140ecff784", "2552a7771658870ed27965140ecff784",
"2552a7771658870ed27965140ecff784", "2552a7771658870ed27965140ecff784",
"2552a7771658870ed27965140ecff784", "2552a7771658870ed27965140ecff784",
"2552a7771658870ed27965140ecff784", "2552a7771658870ed27965140ecff784",
"2552a7771658870ed27965140ecff784", "2552a7771658870ed27965140ecff784",
"2552a7771658870ed27965140ecff784", "2552a7771658870ed27965140ecff784",
"2552a7771658870ed27965140ecff784", "2552a7771658870ed27965140ecff784",
"2552a7771658870ed27965140ecff784", "2552a7771658870ed27965140ecff784",
"2552a7771658870ed27965140ecff784", "2552a7771658870ed27965140ecff784",
"2552a7771658870ed27965140ecff784", "2552a7771658870ed27965140ecff784",
"2552a7771658870ed27965140ecff784", "2552a7771658870ed27965140ecff784",
"2552a7771658870ed27965140ecff784", "2552a7771658870ed27965140ecff784",
"2552a7771658870ed27965140ecff784", "2552a7771658870ed27965140ecff784",
"2552a7771658870ed27965140ecff784", "2552a7771658870ed27965140ecff784",
"2552a7771658870ed27965140ecff784", "2552a7771658870ed27965140ecff784",
"2552a7771658870ed27965140ecff784", "2552a7771658870ed27965140ecff784",
"2552a7771658870ed27965140ecff784", "2552a7771658870ed27965140ecff784",
"2552a7771658870ed27965140ecff784", "2552a7771658870ed27965140ecff784",
"2552a7771658870ed27965140ecff784", "2552a7771658870ed27965140ecff784",
"2552a7771658870ed27965140ecff784", "2552a7771658870ed27965140ecff784",
"2552a7771658870ed27965140ecff784", "2552a7771658870ed27965140ecff784",
"2552a7771658870ed27965140ecff784", "2552a7771658870ed27965140ecff784",
"2552a7771658870ed27965140ecff784", "2552a7771658870ed27965140ecff784",
"2552a7771658870ed27965140ecff784", "2552a7771658870ed27965140ecff784",
"2552a7771658870ed27965140ecff784", "2552a7771658870ed27965140ecff784",
"2552a7771658870ed27965140ecff784", "2552a7771658870ed27965140ecff784",
"2552a7771658870ed27965140ecff784", "2552a7771658870ed27965140ecff784",
"2552a7771658870ed27965140ecff784", "2552a7771658870ed27965140ecff784",
"2552a7771658870ed27965140ecff784", "2552a7771658870ed27965140ecff784",
"2552a7771658870ed27965140ecff784", "2552a7771658870ed27965140ecff784",
"2552a7771658870ed27965140ecff784", "2552a7771658870ed27965140ecff784",
"0fcc6d692248cb88026632598ee93a22", "0fcc6d692248cb88026632598ee93a22",
"0fcc6d692248cb88026632598ee93a22", "0fcc6d692248cb88026632598ee93a22",
"0fcc6d692248cb88026632598ee93a22", "0fcc6d692248cb88026632598ee93a22",
"0fcc6d692248cb88026632598ee93a22", "0fcc6d692248cb88026632598ee93a22",
"0fcc6d692248cb88026632598ee93a22", "0fcc6d692248cb88026632598ee93a22",
"0fcc6d692248cb88026632598ee93a22", "0fcc6d692248cb88026632598ee93a22",
"0fcc6d692248cb88026632598ee93a22", "0fcc6d692248cb88026632598ee93a22",
"0fcc6d692248cb88026632598ee93a22", "0fcc6d692248cb88026632598ee93a22",
"0fcc6d692248cb88026632598ee93a22", "0fcc6d692248cb88026632598ee93a22",
"0fcc6d692248cb88026632598ee93a22", "0fcc6d692248cb88026632598ee93a22",
"0fcc6d692248cb88026632598ee93a22", "0fcc6d692248cb88026632598ee93a22",
"0fcc6d692248cb88026632598ee93a22", "0fcc6d692248cb88026632598ee93a22",
"0fcc6d692248cb88026632598ee93a22", "0fcc6d692248cb88026632598ee93a22",
"0fcc6d692248cb88026632598ee93a22", "0fcc6d692248cb88026632598ee93a22",
"0fcc6d692248cb88026632598ee93a22", "0fcc6d692248cb88026632598ee93a22",
"0fcc6d692248cb88026632598ee93a22", "0fcc6d692248cb88026632598ee93a22",
"0fcc6d692248cb88026632598ee93a22", "0fcc6d692248cb88026632598ee93a22",
"0fcc6d692248cb88026632598ee93a22", "0fcc6d692248cb88026632598ee93a22",
"0fcc6d692248cb88026632598ee93a22", "0fcc6d692248cb88026632598ee93a22",
"0fcc6d692248cb88026632598ee93a22", "0fcc6d692248cb88026632598ee93a22",
"0fcc6d692248cb88026632598ee93a22", "0fcc6d692248cb88026632598ee93a22",
"0fcc6d692248cb88026632598ee93a22", "0fcc6d692248cb88026632598ee93a22",
"0fcc6d692248cb88026632598ee93a22", "0fcc6d692248cb88026632598ee93a22",
"0fcc6d692248cb88026632598ee93a22", "0fcc6d692248cb88026632598ee93a22",
"0fcc6d692248cb88026632598ee93a22", "0fcc6d692248cb88026632598ee93a22",
"0fcc6d692248cb88026632598ee93a22", "0fcc6d692248cb88026632598ee93a22",
"0fcc6d692248cb88026632598ee93a22", "0fcc6d692248cb88026632598ee93a22",
"0fcc6d692248cb88026632598ee93a22", "0fcc6d692248cb88026632598ee93a22",
"0fcc6d692248cb88026632598ee93a22", "0fcc6d692248cb88026632598ee93a22",
"0fcc6d692248cb88026632598ee93a22", "0fcc6d692248cb88026632598ee93a22",
"0fcc6d692248cb88026632598ee93a22", "0fcc6d692248cb88026632598ee93a22",
"0fcc6d692248cb88026632598ee93a22", "0fcc6d692248cb88026632598ee93a22",
"0fcc6d692248cb88026632598ee93a22", "0fcc6d692248cb88026632598ee93a22",
"0fcc6d692248cb88026632598ee93a22", "0fcc6d692248cb88026632598ee93a22",
"0fcc6d692248cb88026632598ee93a22", "0fcc6d692248cb88026632598ee93a22"
), x = structure(c(2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L), .Label = c("A", "B"), class = "factor", contrasts = structure(c(0,
1), .Dim = 2:1, .Dimnames = list(c("A", "B"), "B"))), m = c(0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1,
1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 0,
0, 1, 1, 1, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0,
0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0,
1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0), y = c(26.796875, 16.953125,
1.640625, 16.953125, 34.453125, 13.671875, 16.953125, 13.671875,
3.828125, 18.046875, 14.765625, 10.390625, 12.578125, 13.671875,
18.046875, 16.953125, 18.046875, 16.953125, 26.796875, 21.328125,
12.578125, 10.390625, 16.953125, 31.171875, 13.671875, 16.953125,
0.546875, 13.671875, 20.234375, 34.453125, 26.796875, 13.671875,
16.953125, 16.953125, 12.578125, 27.890625, 34.453125, 16.953125,
34.453125, 34.453125, 16.953125, 24.609375, 18.046875, 22.421875,
16.953125, 22.421875, 16.953125, 16.953125, 26.796875, 16.953125,
26.796875, 24.609375, 24.609375, 24.609375, 24.609375, 24.609375,
24.609375, 24.609375, 23.515625, 24.609375, 31.171875, 24.609375,
24.609375, 24.609375, 24.609375, 28.984375, 25.703125, 31.171875,
31.171875, 24.609375, 18.046875, 0.546875, 0.546875, 0.546875,
0.546875, 0.546875, 0.546875, 0.546875, 0.546875, 0.546875, 0.546875,
0.546875, 0.546875, 0.546875, 0.546875, 0.546875, 0.546875, 0.546875,
0.546875, 0.546875, 0.546875, 0.546875, 0.546875, 0.546875, 0.546875,
0.546875, 0.546875, 0.546875, 0.546875, 0.546875, 0.546875, 0.546875,
0.546875, 0.546875, 0.546875, 34.453125, 34.453125, 0.546875,
34.453125, 33.359375, 0.546875, 0.546875, 0.546875, 0.546875,
0.546875, 0.546875, 0.546875, 0.546875, 0.546875, 0.546875, 0.546875,
0.546875, 0.546875, 0.546875, 1.640625, 0.546875, 0.546875, 0.546875,
0.546875, 0.546875, 0.546875, 0.546875, 0.546875, 0.546875, 0.546875,
0.546875, 0.546875, 0.546875, 1.640625, 1.640625)), row.names = c(1L,
2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L,
16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L, 27L, 28L,
29L, 30L, 31L, 32L, 33L, 34L, 35L, 43L, 44L, 45L, 46L, 47L, 48L,
49L, 50L, 51L, 52L, 53L, 54L, 55L, 56L, 57L, 58L, 59L, 60L, 61L,
62L, 63L, 64L, 65L, 66L, 67L, 68L, 69L, 70L, 71L, 72L, 73L, 74L,
75L, 76L, 77L, 85L, 86L, 87L, 88L, 89L, 90L, 91L, 92L, 93L, 94L,
95L, 96L, 97L, 98L, 99L, 100L, 101L, 102L, 103L, 104L, 105L,
106L, 107L, 108L, 109L, 110L, 111L, 112L, 113L, 114L, 115L, 116L,
117L, 118L, 119L, 127L, 128L, 129L, 130L, 131L, 132L, 133L, 134L,
135L, 136L, 137L, 138L, 139L, 140L, 141L, 142L, 143L, 144L, 145L,
146L, 147L, 148L, 149L, 150L, 151L, 152L, 153L, 154L, 155L, 156L,
157L, 158L, 159L, 160L, 161L), class = "data.frame")