When I run this command:
fit <- mod$sample(
data = ds,
seed = 123,
chains = 1,
refresh = 500,
adapt_delta = 0.975,
step_size = 0.1
)
I get this error message:
Error in lapply(X = X, FUN = FUN, ...) :
anyNA() applied to non-(list or vector) of type 'closure'
that isn’t very informative for me as it arises from somewhere within the CmdStanR method sample
.
Although @Jonah has very helpfully posted the coding for CmdStanR on Github [GitHub - stan-dev/cmdstanr: CmdStanR: the R interface to CmdStan ], I can’t find the code for the sample
method.
Can someone tell me where it is, please?
#' @template model-common-args
#' @template model-sample-args
#' @param cores,num_cores,num_chains,num_warmup,num_samples,save_extra_diagnostics,max_depth,stepsize
#' Deprecated and will be removed in a future release.
#'
#' @return A [`CmdStanMCMC`] object.
#'
#' @template seealso-docs
#' @inherit cmdstan_model examples
#'
sample <- function(data = NULL,
seed = NULL,
refresh = NULL,
init = NULL,
save_latent_dynamics = FALSE,
output_dir = NULL,
output_basename = NULL,
sig_figs = NULL,
chains = 4,
parallel_chains = getOption("mc.cores", 1),
chain_ids = seq_len(chains),
Maybe there should be checks for data types.
2 Likes
EDIT: Ari beat me to it :)
That function would be here: cmdstanr/model.R at master · stan-dev/cmdstanr · GitHub
Most arguments look good to me, the only think that could be causing issue is ds
. Is it a list?
Try running cmdstanr::write_stan_json(ds)
.
1 Like
Many thanks for such a quick response.
A good second place! I will try what you suggest. Thanks.