Hello,

I’m new to Bayessian statistics and I would like to know how it is possible to test particular hypotheses in brms. The code of my model is the following:

```
fit <- brm(response ~ 0 + Intercept + contrast + group.IQ + (1 | subject), data = test, family = bernoulli("logit"), prior = prior, sample_prior = "yes")
```

```
Family: bernoulli
Links: mu = logit
Formula: response ~ 0 + Intercept + contrast + group.IQ + (1 | subject)
Data: test (Number of observations: 960)
Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
total post-warmup draws = 4000
Group-Level Effects:
~subject (Number of levels: 20)
Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
sd(Intercept) 1.03 0.22 0.67 1.55 1.00 1012 1433
Population-Level Effects:
Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
Intercept -0.98 0.40 -1.77 -0.19 1.01 862 1376
contrasthead_heed 5.45 0.57 4.43 6.68 1.00 3055 2343
contrasthid_heed -0.49 0.30 -1.08 0.09 1.00 2541 2630
contrasthoard_hod 1.12 0.26 0.61 1.65 1.00 2345 2829
contrasthud_hard 0.72 0.26 0.21 1.23 1.00 2358 2748
contrastwhod_hood 0.00 0.27 -0.54 0.54 1.00 2406 2822
group.IQlow -0.74 0.49 -1.66 0.23 1.00 829 1192
```

I would like to test whether there are differences between the two levels of group.IQ, that is, group.IQlow vs groupIQhigh (for all contrasts).

Any suggestions on the code using the hypothesis function?

Would `hyp1 <- c(hyp1 = " group.IQlow + Intercept = 0")`

be ok?

Best,

George

Assuming you have used R’s standard dummy coding for the factors, in order to test the difference between `group.IQlow`

and `group.IQhigh`

(the reference level) you just need to test `"group.IQlow = 0"`

(or `"group.IQlow < 0"`

if you had a directional hypothesis). There’s no interaction between `contrast`

and `group.IQ`

specified in the model, so this hypothesis test applies to all contrasts.

If you had `contrast * group.IQ`

in the model formula, you could test the effect of `group.IQ`

in each `contrast`

accordingly:

```
c("group.IQlow = 0", # effect of group.IQ in reference contrast
"group.IQlow + contrasthead_heed:group.IQlow = 0", # effect of group.IQ in head_heed contrast
"group.IQlow + contrasthid_heed:group.IQlow = 0", # effect of group.IQ in hid_heed contrast
"group.IQlow + contrasthoard_hod:group.IQlow = 0", # effect of group.IQ in hoard_hod contrast
etc ...)
```

1 Like

Many thanks for your response! I have a couple of some other questions to ask (sorry for that, I’m a beginner)

- Should I use “Intercept” in hypothesis testing, e.g.,
`Intercept + group.IQlow < 0`

?
- What would be the code for the examination of differences between contrasthead_heed and contrasthad_hard (the reference level)?

`Intercept + group.IQlow < 0`

would be testing whether the predicted `response`

is less than zero for the `group.IQlow`

group. Similarly `Intercept < 0`

would be testing whether the predicted `response`

is below zero for the reference IQ group. That is why just `group.IQlow`

tests the difference between the two groups (because `Intercept + group.IQlow - Intercept = group.IQlow`

).

In your model, the difference between `contrasthead_heed`

and `contrasthad_hard`

would be tested with `"contrasthead_heed > 0"`

(or `"contrasthead_heed = 0"`

). This uses the same logic as for IQ: the model’s predicted `response`

for reference IQ and reference contrast is simply `Intercept`

; the predicted `response`

for reference IQ and `contrasthead_heed`

is given by `Intercept + contrasthead_heed`

. So, subtracting one from the other, `Intercept`

drops out. If you were comparing responses for lowIQ between the two contrasts, `group.IQlow`

would drop out for the same reason (it is in both terms). And, of course, that would have to be the case because there is no interaction between `contrast`

and `group.IQ`

specified in the model.

1 Like