Hi!
I’m having some trouble using the hypothesis function with a multivariate model. In brief, I have recorded activity rates of animals from multiple populations across 2 contexts. A simplified version of my dataset is as follows:
ID Population Activity_context1 Activity_context2 Trial
1 A 25 32 1
1 A 16 22 2
2 B 11 07 1
2 B 27 23 2
3 C 41 29 1
3 C 17 45 2
I’m interested in looking at among-individual correlations across the contexts and therefore want to run a multivariate model. A simplified version of my model is as below:
act1<- bf(Activity_context1 ~ Population + Trial + (1|id), family= gaussian)
act2<- bf(Activity_context2 ~ Population + Trial + (1|id), family= gaussian)
act.model<- brm(act1+ act2+ set_rescor(FALSE),
data = mydata,
cores = 4,
chains = 4,
warmup = 500,
iter = 3000,
seed = 12345)
If possible, I would like to use the hypothesis function to look at 1) whether populations differ in their activity in context 1, and 2) whether populations change their behaviour across the contexts. I have seen a similar post on using the hypothesis with multivariate models (Comparing posteriors of predictors in brms using hypothesis - #2 by martinmodrak), however, I still had a few questions.
In regards to questions 1, I have used the following hypotheses:
# Comparing Population A and B
hyp1 = c(hyp1 = "Activity_context1_Intercept + Activity_context1_PopulationB = Activity_context1_Intercept ")
hyp1 <- hypothesis(act.model, hyp1, alpha = 0.05)
This gives me essentially the same output as the summmary() function and I think this seems to be coded correctly.
However, I am having difficulty in answering question 2. I have coded the contrasts across the two response variables within each population as follows:
# Comparing Population A (context 1) and A (context 2)
hyp2 = c(hyp1 = "Activity_context1_Intercept = Activity_context2_Intercept ")
hyp2 <- hypothesis(act.model, hyp2, alpha = 0.05)
The output does not seem correct when looking at the figures, so I am wondering if this is the best way to code this contrast?
Alternatively, I could convert my data into long format and run a separate model with context as a predictor, however, I would prefer to do it with my multivariate model if possible.
Any help would be greatly appreciated!
Thanks in advance!