CmdstanR - Error in validate_sample_args

Hi all,

While waiting for the rstan issues for windows+R4.0.2 to get resolved, I’ve been trying to work with cmdstan instead,
and am getting a strange error.
I can run cmdstan_model just fine, but when trying to run the $sample() function, it seems I have to specify all parameters, or it fails. Example:

                           refresh = NULL,
                           thin=1,max_treedepth = NULL,
                           init=Guesses,parallel_chains =getOption("mc.cores", 1),
                           threads_per_chain = NULL,save_warmup = FALSE,
                           save_latent_dynamics = FALSE,output_dir = NULL)
Error in validate_sample_args(self, num_procs) : 
  Assertion on 'self$adapt_engaged' failed: Must be of type 'integerish' (or 'NULL'), not 'CmdStanModel/R6'.

Does anyone have an idea about what’s going on? I can work around by specifying each argument explicitely, but it get’s tedious. It’s v0.0.0.9008 fwiw.

Thanks in Advance,

Edit: Another similar, but not identical error message after I’ve added all missing default arguments:

Error in seir_stan$sample(seir_stan, data = stan_data, iter_warmup = 400,  : 
  Assertion on 'parallel_chains' failed: Must be of type 'integerish' (or 'NULL'), not 'CmdStanModel/R6'.
In addition: Warning message:
In seir_stan$sample(seir_stan, data = stan_data, iter_warmup = 400,  :
  'cores' is deprecated. Please use 'parallel_chains' instead.

The odd thing here is that I haven’t specified a core argument, only parallel_chains.

Sorry, all - false alarm. In the first line, I used


out of habit from using standard functions. This caused the seir_stan to be assigned to the first missing argument, e.g cores=, and thus the rest of the confusion. It’s running fine now.

No worries! Glad it’s working now. It can definitely take a little while to get used to accessing methods via $ and not needing to specify the object as the first argument. That’s happened to me too.