Hi,
It seems rename_pars (Rename parameters) does not work with backend = “cmdstanr”. Or perhaps I am missing something here.
It works well with default backend = “rstan”. Please see below an example.
cmdstanr version 0.2.0
cmdstan version 2.25.0
brms version 2.14.4
library(cmdstanr)
library(brms)
scode <- make_stancode(count ~ Trt, data = epilepsy)
sdata <- make_standata(count ~ Trt, data = epilepsy)
# rstan fit
stanfit <- rstan::stan(model_code = scode, data = sdata)
# feed the Stan model back into brms
fit <- brm(count ~ Trt, data = epilepsy, empty = TRUE)
fit$fit <- stanfit
fit <- rename_pars(fit)
summary(fit)
# cmdstanr fit
csdata <- list()
for (t in names(sdata)) {
csdata[[t]] <- sdata[[t]]
}
cmod <- cmdstan_model(write_stan_file(scode))
cfit <- cmod$sample(data= csdata)
# feed the Stan model back into brms
fit <- brm(count ~ Trt, data = epilepsy, empty = TRUE, backend = "cmdstanr")
fit$fit <- cfit
fit <- rename_pars(fit)
summary(fit)
Error in rename_pars(fit) :
trying to get slot "sim" from an object (class "CmdStanMCMC") that is not an S4 object
If you need to use math formula, use Latex syntax:
Don’t forget to attach tags (top right of this form) for application area/class of models or other general subject areas your topic touches on.