Last active
November 20, 2023 14:09
-
-
Save JimGrange/2e9e730365abe1034ba3dc4a9a35a943 to your computer and use it in GitHub Desktop.
interaction term in brms
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(brms) | |
library(tidyverse) | |
set.seed(123) | |
# generate some subject-averaged data | |
n_subjects <- 100 | |
data <- tibble( | |
id = 1:n_subjects, | |
congruent_informative = rnorm(n_subjects, 500, 60), | |
incongruent_informative = rnorm(n_subjects, 500, 60), | |
congruent_noninformative = rnorm(n_subjects, 500, 60), | |
incongruent_noninformative = rnorm(n_subjects, 500, 60), | |
) |> | |
pivot_longer(cols = congruent_informative:incongruent_noninformative, | |
names_sep = "_", | |
names_to = c("congruency", "cue"), | |
values_to = "rt") | |
# fit the model | |
# of course, ex-G is bad choice for this subject-averaged simulated data | |
model <- brm(rt ~ congruency * cue + (1|id), | |
data = data, | |
family = exgaussian(), | |
cores = 4) | |
summary(model) | |
# Population-Level Effects: | |
# Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS | |
# Intercept 505.59 5.79 494.38 517.35 1.00 3755 2505 | |
# congruencyincongruent -12.24 8.33 -29.04 3.86 1.00 3511 2635 | |
# cuenoninformative 1.68 8.26 -14.45 17.67 1.00 3552 2613 | |
# congruencyincongruent:cuenoninformative 2.53 11.57 -20.01 25.80 1.00 3098 2293 | |
# | |
# Family Specific Parameters: | |
# Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS | |
# sigma 55.01 3.71 46.66 60.88 1.00 2638 2786 | |
# beta 15.10 9.73 2.03 35.04 1.00 1975 2215 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment