I am modelling a forced-choice task with two alternatives where each alternative is characterized by two parameters that are supposed to reflect some underlying signals. Since these parameters have the same effect on each alternative, I want to plot the model predictions using the average of the coefficients for each alternative. How to do it?
Below I show how I compute the hypothesis but I struggle to plot the predictions for the same hypothesis.
library(data.table) library(brms) # example data object_set <- data.table(object_id = 1:800, mean_val = rnorm(800), unc = rgamma(800, 1, 2)) pairs <- object_set[, CJ(id1 = object_id, id2 = object_id)][id1 < id2] pairs <- pairs[object_set,on = .(id1=object_id)][object_set, on = .(id2 = object_id)][!is.na(mean_val)] setnames(pairs, 3:6, c('mean1','unc1','mean2','unc2')) sample_data <- pairs[sample(1000)] sample_data[,evidence:=rnorm(.N, mean1, unc1)-rnorm(.N, mean2, unc2), by = .(id1, id2)] sample_data[,choice:=as.numeric(evidence>0)] brm_simple <- brm(choice~mean1+mean2+mean1*unc1+mean2*unc2, sample_data, family = bernoulli()) hypothesis(brm_simple, '(mean1-mean2)/2>0') hypothesis(brm_simple, '(mean1:unc1-mean2:unc2)/2<0')
So I want to plot, for example, the choice probability as a function of the mean for or the interaction of the mean and uncertainty regardless of alternative number. This would be similar to an average of the plots given by conditional effects here:
conditional_effects(brm_simple, 'mean1:unc1') conditional_effects(brm_simple, 'mean2:unc2')
with the x-axis reversed for the second plot.