create_folder() is deprected. Provide a path directly in chkpt_brms()', or chkpt_stan() instead and a folder will be created automatically.'

create_folder(folder_name = "cp_folder", path = NULL)

Arguments

folder_name

Character string. Desired name for the 'parent' folder (defaults to cp_folder).

path

Character string, when specified. Defaults to NULL, which then makes the folder in the working directory.

Value

the path to the main parent folder containing the four subfolders. This path should be used as the path argument in chkpt_brms. If return_relative = TRUE, the relative path to the current working directory is returned. If path is specified or return_relative = FALSE, the full path is returned.

Note

This creates a directory with four folders:

  • cmd_output: The cmdstanr output_files (one for each checkpoint and chain).

  • cp_info: Mass matrix, step size, and initial values for next checkpoint (last iteration from previous checkpoint).

  • cp_samples: Samples from the posterior distribution (post warmup)

  • stan_model: Complied Stan model

-------------------

Create the folder for checkingpointing, which will 'house' additional folders for the .stan model, checkpointing information, and draws from the posterior distribution.

Examples

# create initial folder
path <- create_folder(folder_name = 'cp_folder')
#> Warning: create_folder() is deprected. Provide a path directly in chkpt_brms() or chkpt_stan() instead and a folder will be created automatically.
path
#> [1] "cp_folder"
unlink('cp_folder', recursive = TRUE) # remove folder

# remove folder
unlink('cp_folder', recursive = TRUE)
identical(dir(path), character(0))
#> [1] TRUE

# repeat - no warning
path <- create_folder(folder_name = 'cp_folder')
#> Warning: create_folder() is deprected. Provide a path directly in chkpt_brms() or chkpt_stan() instead and a folder will be created automatically.

# repeat - warning, but folders are kept
path <- create_folder(folder_name = 'cp_folder')
#> Warning: create_folder() is deprected. Provide a path directly in chkpt_brms() or chkpt_stan() instead and a folder will be created automatically.
identical(dir(path), c('cmd_output', 'cp_info', 'cp_samples', 'stan_model'))
#> [1] TRUE

unlink('cp_folder', recursive = TRUE)

# specify nested folder
path <- create_folder(folder_name = 'nested_folder/cp_folder')
#> Warning: create_folder() is deprected. Provide a path directly in chkpt_brms() or chkpt_stan() instead and a folder will be created automatically.
path
#> [1] "nested_folder/cp_folder"
unlink('nested_folder', recursive = TRUE) # remove folder