Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
# Load libraries
library(brms)
library(tidyverse)
# Load data
data <- read_csv("temp_data.csv")
# Define model
Model2_Language_f <- bf(Outcome ~ 0 + language + language:Diagnosis +
(1 | p | gr(ID, by=group)),
sigma ~ 0 + language + language:Diagnosis +
(1 | p | gr(ID, by=group))
)
# Define priors
PriorLS <- c(
prior(normal(0, .01), class = sd),
prior(normal(0, .05), class = b),
prior(normal(0,.05), class=b, dpar = sigma),
prior(normal(0,.01), class=sd, dpar = sigma),
prior(lkj(5), class = cor)
)
InformedPriorLS <- c(
prior(normal(0, 0.1), class = sd) ,
prior(normal(0.38, 0.11), class = b),
prior(normal(-0.17, 0.11), class = b, coef = languagedk),
prior(normal(-0.17, 0.11), class = b, coef = languageus), #0.0763
prior(normal(0, 0.05), class = b, dpar = sigma),
prior(normal(0, 0.01), class = sd, dpar = sigma),
prior(lkj(5), class = cor)
)
# Run model
m <- brm(Model2_Language_f,
data = data,
family = gaussian,
prior = PriorLS,
sample_prior = T
)
# No errors
m <- brm(Model2_Language_f,
data = data,
family = gaussian,
prior = InformedPriorLS,
sample_prior = T
)
# Error
#Error in parse(text = expr) : <text>:6:5: unexpected ')'
#5: b_sigma
#6: sd_1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.