Forming a hypothesis with interactions

186 views
Skip to first unread message

Kyle Andrews

unread,
Nov 9, 2017, 11:00:49 AM11/9/17
to brms-users
How would I evaluate the hypothesis that a treatment is better than another treatment when there is an interaction?

For example, I was playing around with the sleepstudy example from lme4.

data(sleepstudy, package = "lme4")
library
(dplyr)
library
(brms)
options
(auto_write = TRUE)
options
(mc.cores = parallel::detectCores())

sleepstudy
%>%
  filter
(Subject %excluding% c(308, 351, 372, 371)) %>%
  mutate
(treatment = as.factor(ifelse(row_number(Subject) < 91, "1", "2"))) -> ss2

m_slp_br
<- brm(Reaction ~ Days * treatment + (Days |Subject),
                data
= ss2,
                family
= gaussian(),
                iter
= 4000,
                control
= list(adapt_delta = 0.9))


I know I can test the main effect simply with:

hypothesis(m_slp_br, "treatment2 < 0")



It tells me that the second level of treatment is probably worse than the first level.

But I also see that the interaction term is almost certainly positive:

hypothesis(m_slp_br, "Days:treatment2 > 0")



My guess is that to test this, I need:

hypothesis(m_slp_br, "treatment2 + Days:treatment2*5 < 0")



Which I think tells me that by day 5, there is a significant improvement with treatment2 vs treatment 1.

Am I interpreting that correctly?

Paul Buerkner

unread,
Nov 9, 2017, 11:04:54 AM11/9/17
to Kyle Andrews, brms-users
Yes, this looks correct to me.

--
You received this message because you are subscribed to the Google Groups "brms-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to brms-users+unsubscribe@googlegroups.com.
To post to this group, send email to brms-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/brms-users/30a5c82e-4fdc-41cb-b661-5104a52cf26b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Kyle Andrews

unread,
Nov 9, 2017, 11:29:41 AM11/9/17
to brms-users
Thanks!
To unsubscribe from this group and stop receiving emails from it, send an email to brms-users+...@googlegroups.com.

Julin Maloof

unread,
Nov 9, 2017, 1:22:51 PM11/9/17
to Kyle Andrews, brms-users
This is slightly off topic but where does the %excluding% functionality come from?  Not working for me (R3.4.2, dplyr_0.7.4  )

Julin Maloof
Professor
Department of Plant Biology
1 Shields Ave
University of California, Davis
Davis, CA 95616
(530) 752 8077

To unsubscribe from this group and stop receiving emails from it, send an email to brms-users+unsubscribe@googlegroups.com.

To post to this group, send email to brms-...@googlegroups.com.

Julin Maloof

unread,
Nov 9, 2017, 1:52:34 PM11/9/17
to brms-users
Back on topic, let's discuss the interpretation of those hypothesis test more:

When I run this I get:

> hypothesis(m_slp_br, "treatment2 < 0")
Hypothesis Tests for class b:
                 Estimate Est.Error l-95% CI u-95% CI Evid.Ratio Star
(treatment2) < 0   -20.82     20.83     -Inf    13.67       6.17     
---
'*': The expected value under the hypothesis lies outside the 95% CI.> 

Is that what you see?  Because the 95%CI includes 0 my interpretation is that we CANNOT conclude that treatment 2 is different from treatment 1.  (Also note that in this case a negative value for the effect would, I think, be better since the measurement is reaction time and faster reaction times are better).

For the interaction term:
> hypothesis(m_slp_br, "Days:treatment2 > 0")
Hypothesis Tests for class b:
                      Estimate Est.Error l-95% CI u-95% CI Evid.Ratio Star
(Days:treatment2) > 0     8.17      3.62     2.39      Inf       66.8    *
---
'*': The expected value under the hypothesis lies outside the 95% CI.
Here the confidence intervals are both greater than 0 (and we have a "star") giving evidence for a positive interaction


However, for the interaction effect at day 5:
> hypothesis(m_slp_br, "treatment2 + Days:treatment2*5 < 0")
Hypothesis Tests for class b:
                         Estimate Est.Error l-95% CI u-95% CI Evid.Ratio Star
(treatment2+Days:... < 0    20.02      28.6     -Inf    66.89        0.3     
---
'*': The expected value under the hypothesis lies outside the 95% CI.> 
The confidence interval includes zero so there is NOT evidence that treatment 2 affects outcomes by day 5.

 


Paul Buerkner

unread,
Nov 9, 2017, 2:56:50 PM11/9/17
to Julin Maloof, brms-users
Why are you using '<' in hypothesis(m_slp_br, "treatment2 + Days:treatment2*5 < 0")

Wouldn't we expect "treatment2 + Days:treatment2*5 > 0"?

--
You received this message because you are subscribed to the Google Groups "brms-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to brms-users+unsubscribe@googlegroups.com.
To post to this group, send email to brms-...@googlegroups.com.

Julin Maloof

unread,
Nov 9, 2017, 3:03:35 PM11/9/17
to Paul Buerkner, brms-users
I think you are right...I was following Kyle's code but yes ">" makes sense to me

Kyle Andrews

unread,
Nov 9, 2017, 3:11:55 PM11/9/17
to brms-users
Sorry Julin. I hate the !(x %in% things) syntax so defined it.

`%excluding%` <- Negate(`%in%`)
Reply all
Reply to author
Forward
0 new messages