The $command() method returns the command line
CmdStanR ran for each CmdStan run. A few things to know before
running one again:
The paths are the ones R used. Input files CmdStanR wrote for the run (data passed as a list, inits, an inverse metric, the CSV files
$laplace()and$generate_quantities()read) are in a temporary directory, even whenoutput_diris set, and don't outlive the R session.The output paths are this fit's CSV files, so running the line again overwrites them unless you change the paths after
output.threads_per_chain(orthreads) reaches CmdStan as theSTAN_NUM_THREADSenvironment variable, not an argument, so set it first.$sample_mpi()runs the line through the MPI launcher, which the line doesn't include.On Windows CmdStanR puts the TBB library on
PATHfor the run, so the terminal needs it there too.On WSL the command runs inside the Linux distribution, where the paths are already spelled for it.
Examples
# \dontrun{
fit <- cmdstanr_example("logistic", method = "sample")
fit$command()
#> [1] "'/tmp/RtmpwHIm89/logistic' 'id=1' 'random' 'seed=1199584326' 'data' 'file=/home/runner/work/_temp/Library/cmdstanr/logistic.data.json' 'output' 'file=/tmp/RtmpwHIm89/logistic-202610151525-01-6cf609.csv' 'profile_file=/tmp/RtmpwHIm89/logistic-profile-202610151525-01-0a0e76.csv' 'save_cmdstan_config=0' 'method=sample' 'save_warmup=0' 'algorithm=hmc' 'engine=nuts' 'adapt' 'engaged=1' 'save_metric=0'"
#> [2] "'/tmp/RtmpwHIm89/logistic' 'id=2' 'random' 'seed=1199584326' 'data' 'file=/home/runner/work/_temp/Library/cmdstanr/logistic.data.json' 'output' 'file=/tmp/RtmpwHIm89/logistic-202610151525-02-6cf609.csv' 'profile_file=/tmp/RtmpwHIm89/logistic-profile-202610151525-02-0a0e76.csv' 'save_cmdstan_config=0' 'method=sample' 'save_warmup=0' 'algorithm=hmc' 'engine=nuts' 'adapt' 'engaged=1' 'save_metric=0'"
#> [3] "'/tmp/RtmpwHIm89/logistic' 'id=3' 'random' 'seed=1199584326' 'data' 'file=/home/runner/work/_temp/Library/cmdstanr/logistic.data.json' 'output' 'file=/tmp/RtmpwHIm89/logistic-202610151525-03-6cf609.csv' 'profile_file=/tmp/RtmpwHIm89/logistic-profile-202610151525-03-0a0e76.csv' 'save_cmdstan_config=0' 'method=sample' 'save_warmup=0' 'algorithm=hmc' 'engine=nuts' 'adapt' 'engaged=1' 'save_metric=0'"
#> [4] "'/tmp/RtmpwHIm89/logistic' 'id=4' 'random' 'seed=1199584326' 'data' 'file=/home/runner/work/_temp/Library/cmdstanr/logistic.data.json' 'output' 'file=/tmp/RtmpwHIm89/logistic-202610151525-04-6cf609.csv' 'profile_file=/tmp/RtmpwHIm89/logistic-profile-202610151525-04-0a0e76.csv' 'save_cmdstan_config=0' 'method=sample' 'save_warmup=0' 'algorithm=hmc' 'engine=nuts' 'adapt' 'engaged=1' 'save_metric=0'"
# one line per chain
cat(fit$command(), sep = "\n")
#> '/tmp/RtmpwHIm89/logistic' 'id=1' 'random' 'seed=1199584326' 'data' 'file=/home/runner/work/_temp/Library/cmdstanr/logistic.data.json' 'output' 'file=/tmp/RtmpwHIm89/logistic-202610151525-01-6cf609.csv' 'profile_file=/tmp/RtmpwHIm89/logistic-profile-202610151525-01-0a0e76.csv' 'save_cmdstan_config=0' 'method=sample' 'save_warmup=0' 'algorithm=hmc' 'engine=nuts' 'adapt' 'engaged=1' 'save_metric=0'
#> '/tmp/RtmpwHIm89/logistic' 'id=2' 'random' 'seed=1199584326' 'data' 'file=/home/runner/work/_temp/Library/cmdstanr/logistic.data.json' 'output' 'file=/tmp/RtmpwHIm89/logistic-202610151525-02-6cf609.csv' 'profile_file=/tmp/RtmpwHIm89/logistic-profile-202610151525-02-0a0e76.csv' 'save_cmdstan_config=0' 'method=sample' 'save_warmup=0' 'algorithm=hmc' 'engine=nuts' 'adapt' 'engaged=1' 'save_metric=0'
#> '/tmp/RtmpwHIm89/logistic' 'id=3' 'random' 'seed=1199584326' 'data' 'file=/home/runner/work/_temp/Library/cmdstanr/logistic.data.json' 'output' 'file=/tmp/RtmpwHIm89/logistic-202610151525-03-6cf609.csv' 'profile_file=/tmp/RtmpwHIm89/logistic-profile-202610151525-03-0a0e76.csv' 'save_cmdstan_config=0' 'method=sample' 'save_warmup=0' 'algorithm=hmc' 'engine=nuts' 'adapt' 'engaged=1' 'save_metric=0'
#> '/tmp/RtmpwHIm89/logistic' 'id=4' 'random' 'seed=1199584326' 'data' 'file=/home/runner/work/_temp/Library/cmdstanr/logistic.data.json' 'output' 'file=/tmp/RtmpwHIm89/logistic-202610151525-04-6cf609.csv' 'profile_file=/tmp/RtmpwHIm89/logistic-profile-202610151525-04-0a0e76.csv' 'save_cmdstan_config=0' 'method=sample' 'save_warmup=0' 'algorithm=hmc' 'engine=nuts' 'adapt' 'engaged=1' 'save_metric=0'
# }