I’m trying to replicate the analysis from this code (OSF) and compare two models that have either 2 or 6 predictor variables, but I don’t really understand the syntax for setting the priors.
My models are:
prior1 <- c(prior(normal(0, 1), class="b"),
#prior(normal(0, 1), class="b", coef="varA"),
#prior(normal(0, 1), class="b", coef="varB"),
prior(normal(0, 1), class="b", coef="WORDTYPE:varA"),
prior(normal(0, 1), class="b", coef="WORDTYPE:varB"),
prior(normal(0.5, 1), class="b", coef="WORDTYPE"))
prior2 <- c(prior(normal(0, 1), class="b"),
prior(normal(0, 1), class="b", coef="varA"),
prior(normal(0, 1), class="b", coef="varB"),
prior(normal(0, 1), class="b", coef="varC"),
prior(normal(0, 1), class="b", coef="varD"),
prior(normal(0, 1), class="b", coef="varE"),
prior(normal(0, 1), class="b", coef="varF"),
prior(normal(0.5, 1), class="b", coef="WORDTYPE"))
null_model <- brm(WordResp ~ 1 + WORDTYPE*varA+ WORDTYPE*varB + (1|PsNumber)+(1|WordNumber),
data=MemoryData, family=bernoulli(link="probit"), prior=prior1,
control=list(adapt_delta=.99), init=0, cores=4, iter=1000,
sample_prior=TRUE)
Step2_model <- brm(WordResp ~ 1 + WORDTYPE*varA+ WORDTYPE*varB +WORDTYPE*varC+ WORDTYPE*varD +WORDTYPE*varE+ WORDTYPE*varF+ (1|PsNumber) + (1|WordNumber),
data=MemoryData, family=bernoulli(link="probit"), prior=prior2,
control=list(adapt_delta=.99), init=0, cores=4, iter=1000,
sample_prior=TRUE)
all the variables are standardised to have normal distribution and mean at 0. I want to set the same prior for all of them, but I’m confused as to whether I need to enumerate them in the syntax, with or without interaction, or if maybe setting priors for all coefficients (class=b) in one line of code is enough?
The reason I’m struggling is that whenever I try to run a bayes factor comparison, I get a null result as if the model is not read correctly, even though it seems like a simple procedure. That suggests that something is wrong with the model even though it runs and produces an output properly, so I suspect the problem is with the priors. More specifically when I run the code above for bayes factor my R session typically crashes, and when I try:
exp(Step2_model$ml - null_model$ml)
I get “numeric(0)” as a result.
any advice would be appreciated!