I am trying to fit a series of models to different data subsets using the targets, tarchetypes, and stantargets packages. I cannot figure out how to access the targets created by stantargets::tar_stan_mcmc
. The below will create targets like fit_mcmc_mod1_case1
and so on. But I cannot find a way to access these targets in subsequent targets. For example, how would I call fit_mcmc_mod1_case1$loo()
further down in the list of targets? I always get an object-not-found error when trying to name the targets generated by stantargets::tar_stan_mcmc
.
Thanks.
models <- c("mod1", "mod2")
list (
targets::tar_target(
name = the_data_file,
command = "data/data.zip",
format = "file"
),
targets::tar_target(
name = the_data,
command = get_the_data(the_data_file),
),
tarchetypes::tar_map(
values = list(case = c("case1", "case2"),
stantargets::tar_stan_mcmc(
name = fit,
stan_files = file.path("stan_models", paste0(models, ".stan")),
data = get_case_data(the_data, case),
stdout = R.utils::nullfile(),
stderr = R.utils::nullfile()
)
)
)