Cmdstanr loo_moment_match

You can create a ‘dummy’ fit object using the Stan code and data, and then replace its draws with those from the existing CSVs:

fit_csv <- as_cmdstan_fit(list.files(pattern = ".csv"))

mod1 <- cmdstan_model("model.stan", force_recompile = TRUE)
fit_dummy <- mod1$sample(data = "model.data.json",
                         iter_warmup = 1,
                         iter_sampling = 1)

fit_dummy$.__enclos_env__$private$draws_ <- fit_csv$.__enclos_env__$private$draws_
fit_dummy$loo(moment_match = TRUE)
4 Likes