Use the set_cmdstan_path() function to tell CmdStanR where the CmdStan installation in located. Once the path has been set, cmdstan_path() will return the full path to the CmdStan installation and cmdstan_version() will return the CmdStan version number. See Details for how to avoid manually setting the path in each R session.

set_cmdstan_path(path = NULL)

cmdstan_path()

cmdstan_version()

## Arguments

path The full file path to the CmdStan installation as a string. If NULL (the default) then the path is set to the default path used by install_cmdstan() if it exists.

## Value

A string. Either the file path to the CmdStan installation or the CmdStan version number.

## Details

Before the package can be used it needs to know where the CmdStan installation is located. When the package is loaded it tries to help automate this to avoid having to manually set the path every session:

• If the environment variable "CMDSTAN" exists at load time then its value will be automatically set as the default path to CmdStan for the R session.

• If no environment variable is found when loaded but any directory in the form ".cmdstanr/cmdstan-[version]", for example ".cmdstanr/cmdstan-2.23.0", exists in the user's home directory (Sys.getenv("HOME"), not the current working directory) then the path to the cmdstan with the largest version number will be set as the path to CmdStan for the R session. This is the same as the default directory that install_cmdstan() would use to install the latest version of CmdStan.

It is always possible to change the path after loading the package using set_cmdstan_path(path).