Created
December 12, 2019 14:11
-
-
Save fusaroli/642f6813857d860490909cbdd57eb0f6 to your computer and use it in GitHub Desktop.
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
# 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