I have two models that I want to compare using bayes_factor
. The first model predicts a continuous variable (y) using two categorical predictors (x, z) and their interaction. This is data from a psycholinguistic study, so there are random slopes and intercepts for subjects and items.
y ~ x * z +
(1 + x * z | subject) +
(1 + x * z | item)
The second model adds a continuous predictor, f, which is an estimate of a frequency-related measure. It is measured with a known uncertainty, sd.f.
y ~ x * z + me(f, sd.f) +
(1 + x * z + me(f, sd.f) | subject) +
(1 + x * z + me(f, sd.f) | item)
I fit these models to a dataset with ~2500 observations of y. For model 1, I used 10k iterations; and for model 2, I used 20k iterations. I made sure to set save_pars = save_pars(all = TRUE)
to be able to run bayes_factor
.
When I run bayes_factor(fit1, fit2)
, it takes a long time, and says that it was unable to estimate the logml within maxiter.
I’ve seen in other threads where people report the same warning message that the solution is to just run more iterations. I tried running 40k iterations for model 2, and while I didn’t see the warning message, I’ve been getting bizarre and huge estimates of the Bayes factor that don’t make sense to me (ranging from actually getting Inf
to getting very very large values in the ~1B range), and I’ve noticed that the model with f runs up to 1000 iterations (the default maxiter for bridge_sampler
).
I also tried this simpler model using 10k iterations for comparison:
y ~ x * z + f +
(1 + x * z + f | subject) +
(1 + x * z + f | item)
In this case, bayes_factor(fit1, fit3)
produced something reasonable, and didn’t give any error message. But this model isn’t great, since it doesn’t take into account the known measurement error of f.
Is this just again a case of needing many more samples for the measurement error model (100k?), or is there something special about the measurement error model that would require a different solution? Do I need to set save_pars = save_pars(all = TRUE, latent = TRUE)
?
I haven’t been able to find anyone specifically discussing this in the context of measurement error models, so I wanted to see if running more iterations would even help. I’m in the process of trying different things, but it takes a long time to fit the models, so if there’s someone who knows the answer so I don’t have to waste lots of time on dead ends, I would be incredibly grateful!