# Using \`brms:hypothesis\` correctly with interactions

**URL:** <https://discourse.mc-stan.org/t/using-brms-hypothesis-correctly-with-interactions/30036>\
**Category:** brms\
**Tags:** hypothesis-testing, brms\
**Created:** [January 12, 2023, 12:26pm UTC](https://discourse.mc-stan.org/t/using-brms-hypothesis-correctly-with-interactions/30036 "2023-01-12T12:26:09Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![striatum](https://avatars.discourse-cdn.com/v4/letter/s/ac8455/32.png) [@striatum](https://discourse.mc-stan.org/u/striatum)\
**Post date:** [January 12, 2023, 12:26pm UTC](https://discourse.mc-stan.org/t/using-brms-hypothesis-correctly-with-interactions/30036/1 "2023-01-12T12:26:09Z")

</div>

This question is about the correct use of `brms`’s `hypothesis()` when a model has interaction. This is an example model:

```plaintext
summary(brm1.q <- brm(bf(DV ~
    A * B +
    (1|RanEff),
    ...
    ))

```

where the critical part of the summary table would look like this:

```plaintext
# 
# Population-Level Effects: 
# Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
# Intercept ... ... ... ... ... ... ...
# Aj ... ... ... ... ... ... ...
# Ak ... ... ... ... ... ... ...
# Bn ... ... ... ... ... ... ...
# Bo ... ... ... ... ... ... ...
# Aj:Bn ... ... ... ... ... ... ...
# Ak:Bn ... ... ... ... ... ... ...
# Aj:Bo ... ... ... ... ... ... ...
# Ak:Bo ... ... ... ... ... ... ...

```

Since effects are _relative wrt the Intercept_, if one wishes to contrast `Aj:Bn` and `Aj:Bn`, this, for example, would give the correct result:

```plaintext
hy1 = c(hy1 = 'Aj < Aj:Bn')
hypothesis(brm1.q, hy1)

```

Does anyone have general (blanked) advice on how to help students wrap their heads around this and not make errors? This can become pretty hairy if the model would have higher-order interactions etc.

(Btw, this is similar, with similar “struggles”, if one would use `linearHypothesis()` from the `car` package.)

Thanks!
