Run FACTS trial simulations.

run_facts(
  facts_file,
  output_path = tempfile(),
  log_path = output_path,
  n_burn = NULL,
  n_mcmc = NULL,
  n_weeks_files = 10000,
  n_patients_files = 10000,
  n_mcmc_files = 0,
  n_mcmc_thin = NULL,
  flfll_seed = NULL,
  flfll_offset = NULL,
  n_sims,
  ...
)

Arguments

facts_file

Character, name of a FACTS file. Usually has a *.facts file extension.

output_path

Character, directory path to the files to generate.

log_path

Character, path to the log file generated by FLFLL.

n_burn

Number of burn-in iterations for the MCMC.

n_mcmc

Number of MCMC iterations used in inference.

n_weeks_files

Number of weeks*.csv files to save in output_path.

n_patients_files

Number of patients*.csv files to save in output_path.

n_mcmc_files

Number of mcmc*.csv files to save in output_path.

n_mcmc_thin

Number of thinning iterations for the MCMC.

flfll_seed

Positive integer, random number generator seed for FLFLL. This seed is only used for stochastic preprocessing steps for generating the *.param files. It is not the random number generator seed for the actual trial simulations. To set the trial simulation seed, use the seed argument of run_facts(), run_engine(), or one of the specific run_engine*() functions.

flfll_offset

Integer, offset for the random number generator.

n_sims

Positive integer, number of simulations per param file.

...

Named arguments to the appropriate FACTS engine function. Use get_facts_engine() to identify the appropriate engine function and then open the help file of that function to read about the arguments, e.g. ?run_engine_contin.

Value

Character, path to the directory with FACTS output.

Details

run_facts() calls run_flfll() and then run_engine(). For finer control over trial simulation, you can call these latter two functions individually.

Examples

# Can only run if system dependencies are configured:
if (file.exists(Sys.getenv("RFACTS_PATHS"))) {
facts_file <- get_facts_file_example("contin.facts") # example FACTS file
out <- run_facts(
  facts_file,
  n_sims = 4,
  verbose = FALSE
)
# What results files do we have?
head(get_csv_files(out))
# Read all the "patients*.csv" files with `read_patients(out)`.
# For each scenario, we have files named
# patients00001.csv, patients00002.csv, patients00003.csv,
# and patients00004.csv.
read_patients(out)
}