Error: Can't find the following sampler diagnostic(s) in the output: treedepth__, divergent__

I’m getting the above error when running some models but not others under cmdstanr. For example the simple Bernoulli example runs fine:

But the attached model appear to run but errors out at the last moment simuGP.stan (381 Bytes)

N = 551
x <- 22 * (0:(N - 1)) / (N - 1) - 11
alpha_true <- 3
rho_true <- 5.5

file <- file.path("simuGP.stan")

# Data as a named list (like RStan)
simu_data <- list(alpha=alpha_true, rho=rho_true, N=N, x=x)

# Run MCMC using the 'sample' method
fit_mcmc <- mod$sample(
    data = simu_data,
    seed = 123,
    chains = 2,
    parallel_chains = 2
)

A search of the error led me here: Error: Can't find the following sampler diagnostic(s) in the output: treedepth__, divergent__ · Issue #364 · stan-dev/cmdstanr · GitHub - > but its apparently been fixed already. I tried remove my rstan, cmdstanr and StanHeaders and reinstalling them all but to no avail

This is a new bug, can you please make an issue so we dont forget. Thank you!

The problem is that with 2.27.0, cmdstan switches to fixed_param algorithm when there are no parameters.

And that means sampler diagnostics are missing.

Current workaround before we fix it is to set fixed_param = TRUE in the $sample() call by yourself when there are no parameters.

1 Like

Done: Error: Can’t find the following sampler diagnostic(s) in the output: treedepth__, divergent__ · Issue #547 · stan-dev/cmdstanr · GitHub

1 Like

Thanks!

Fix should be in soon: Set fixed_param = TRUE when the model has no parameters by rok-cesnovar · Pull Request #548 · stan-dev/cmdstanr · GitHub

1 Like