I have tried to experiment with the pathfinder algorithm with brms (2.23.0) and the cmdstan (2.38.0) backend, and run into
Error: Can’t find the following variable(s) in the output: path__
Here is a minimalist example :
library(brms)
library(cmdstanr)
set.seed(1)
N <- 100
dat <- data.frame(
x = rnorm(N)
)
dat$y <- 1 + 2 * dat$x + rnorm(N, sd = 0.5)
m_frm <- bf(y ~ 1 + x)
m_prior <- c(
prior(normal(0, 5), class = "Intercept"),
prior(normal(0, 5), class = "b"),
prior(exponential(1), class = "sigma")
)
fit_pf <- brm(
formula = m_frm,
data = dat,
family = gaussian(),
prior = m_prior,
backend = "cmdstanr",
algorithm = "pathfinder",
seed = 123
)
And here is the putput:
Model executable is up to date!
Start samplingPath [1] :Initial log joint density = -245.677287
Path [1] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes
8 -7.416e+01 2.190e-03 4.058e-03 1.000e+00 1.000e+00 277 -7.992e+01 -7.990e+01
Path [1] :Best Iter: [8] ELBO (-79.898117) evaluations: (277)
Path [2] :Initial log joint density = -256.288260
Path [2] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes
9 -7.416e+01 1.305e-04 3.638e-03 1.000e+00 1.000e+00 372 -7.992e+01 -8.005e+01
Path [2] :Best Iter: [8] ELBO (-79.921340) evaluations: (372)
Path [3] :Initial log joint density = -322.887346
Path [3] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes
17 -7.416e+01 9.268e-05 3.530e-04 1.000e+00 1.000e+00 643 -8.004e+01 -8.003e+01
Path [3] :Best Iter: [17] ELBO (-80.026751) evaluations: (643)
Path [4] :Initial log joint density = -1581.358110
Path [4] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes
14 -7.416e+01 7.399e-05 3.752e-03 1.000e+00 1.000e+00 566 -7.997e+01 -8.003e+01
Path [4] :Best Iter: [12] ELBO (-79.972363) evaluations: (566)
Finished in 0.3 seconds.
Error: Can't find the following variable(s) in the output: path__