diff --git a/DESCRIPTION b/DESCRIPTION index 3d55cb48..7ce3e65e 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -29,7 +29,7 @@ URL: https://mc-stan.org/cmdstanr/, https://discourse.mc-stan.org BugReports: https://github.com/stan-dev/cmdstanr/issues Encoding: UTF-8 LazyData: true -RoxygenNote: 7.3.0 +RoxygenNote: 7.3.1 Roxygen: list(markdown = TRUE, r6 = FALSE) SystemRequirements: CmdStan (https://mc-stan.org/users/interfaces/cmdstan) Depends: diff --git a/R/generics.R b/R/generics.R index 663cb859..656cf9a1 100644 --- a/R/generics.R +++ b/R/generics.R @@ -1,9 +1,8 @@ - #' Coercion methods for CmdStan objects #' -#' These methods are used to coerce objects into `cmdstanr` objects. -#' Primarily intended for other packages to use when interfacing -#' with `cmdstanr`. +#' These are generic functions intended to primarily be used by developers of +#' packages that interface with on CmdStanR. Developers can define methods on +#' top of these generics to coerce objects into CmdStanR's fitted model objects. #' #' @param object to be coerced #' @param ... additional arguments diff --git a/R/options.R b/R/options.R new file mode 100644 index 00000000..b5e39663 --- /dev/null +++ b/R/options.R @@ -0,0 +1,39 @@ +#' CmdStanR global options +#' +#' These options can be set via [options()] for an entire \R session. +#' +#' @name cmdstanr_global_options +#' +#' @details +#' +#' * `cmdstanr_draws_format`: Which format provided by the \pkg{posterior} +#' package should be used when returning the posterior or approximate posterior +#' draws? The default depends on the model fitting method. See +#' [draws][fit-method-draws] for more details. +#' +#' * `cmdstanr_force_recompile`: Should the default be to recompile models +#' even if there were no Stan code changes since last compiled? See +#' [compile][fit-method-compile] for more details. The default is `FALSE`. +#' +#' * `cmdstanr_max_rows`: The maximum number of rows of output to print when +#' using the [`$print()`][fit-method-summary] method. The default is 10. +#' +#' * `cmdstanr_no_ver_check`: Should the check for a more recent version of +#' CmdStan be disabled? The default is `FALSE`. +#' +#' * `cmdstanr_verbose`: Should more information be printed +#' when compiling or running models, including showing how CmdStan was called +#' internally? The default is `FALSE`. +#' +#' * `cmdstanr_warn_inits`: Should a warning be thrown if initial values are +#' only provided for a subset of parameters? The default is `TRUE`. +#' +#' * `cmdstanr_write_stan_file_dir`: The directory where [write_stan_file()] +#' should write Stan files. The default is [tempdir()]. +#' +#' * `mc.cores`: The number of cores to use for various parallelization tasks +#' (e.g. running MCMC chains, installing CmdStan). The default depends on the +#' use case and is documented with the methods that make use of `mc.cores`. +#' +#' +NULL diff --git a/R/zzz.R b/R/zzz.R index 0a255258..860eb894 100644 --- a/R/zzz.R +++ b/R/zzz.R @@ -10,9 +10,16 @@ startup_messages <- function() { } skip_version_check <- isTRUE(getOption( - "CMDSTANR_NO_VER_CHECK", - default = identical(tolower(Sys.getenv("CMDSTANR_NO_VER_CHECK")), "true") + "cmdstanr_no_ver_check", + default = identical(tolower(Sys.getenv("cmdstanr_no_ver_check")), "true") )) + if (!skip_version_check) { + # check if they used the old all caps version + skip_version_check <- isTRUE(getOption( + "CMDSTANR_NO_VER_CHECK", + default = identical(tolower(Sys.getenv("CMDSTANR_NO_VER_CHECK")), "true") + )) + } if (!skip_version_check) { latest_version <- try(suppressWarnings(latest_released_version(retries = 0)), silent = TRUE) current_version <- try(cmdstan_version(), silent = TRUE) @@ -21,7 +28,7 @@ startup_messages <- function() { && latest_version > current_version) { packageStartupMessage( "\nA newer version of CmdStan is available. See ?install_cmdstan() to install it.", - "\nTo disable this check set option or environment variable CMDSTANR_NO_VER_CHECK=TRUE." + "\nTo disable this check set option or environment variable cmdstanr_no_ver_check=TRUE." ) } } diff --git a/man/cmdstan_coercion.Rd b/man/cmdstan_coercion.Rd index d2d2b483..33a36d3a 100644 --- a/man/cmdstan_coercion.Rd +++ b/man/cmdstan_coercion.Rd @@ -31,7 +31,7 @@ as.CmdStanDiagnose(object, ...) \item{...}{additional arguments} } \description{ -These methods are used to coerce objects into \code{cmdstanr} objects. -Primarily intended for other packages to use when interfacing -with \code{cmdstanr}. +These are generic functions intended to primarily be used by developers of +packages that interface with on CmdStanR. Developers can define methods on +top of these generics to coerce objects into CmdStanR's fitted model objects. } diff --git a/man/cmdstanr_global_options.Rd b/man/cmdstanr_global_options.Rd new file mode 100644 index 00000000..dda64c88 --- /dev/null +++ b/man/cmdstanr_global_options.Rd @@ -0,0 +1,33 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/options.R +\name{cmdstanr_global_options} +\alias{cmdstanr_global_options} +\title{CmdStanR global options} +\description{ +These options can be set via \code{\link[=options]{options()}} for an entire \R session. +} +\details{ +\itemize{ +\item \code{cmdstanr_draws_format}: Which format provided by the \pkg{posterior} +package should be used when returning the posterior or approximate posterior +draws? The default depends on the model fitting method. See +\link[=fit-method-draws]{draws} for more details. +\item \code{cmdstanr_force_recompile}: Should the default be to recompile models +even if there were no Stan code changes since last compiled? See +\link[=fit-method-compile]{compile} for more details. The default is \code{FALSE}. +\item \code{cmdstanr_max_rows}: The maximum number of rows of output to print when +using the \code{\link[=fit-method-summary]{$print()}} method. The default is 10. +\item \code{cmdstanr_no_ver_check}: Should the check for a more recent version of +CmdStan be disabled? The default is \code{FALSE}. +\item \code{cmdstanr_verbose}: Should more information be printed +when compiling or running models, including showing how CmdStan was called +internally? The default is \code{FALSE}. +\item \code{cmdstanr_warn_inits}: Should a warning be thrown if initial values are +only provided for a subset of parameters? The default is \code{TRUE}. +\item \code{cmdstanr_write_stan_file_dir}: The directory where \code{\link[=write_stan_file]{write_stan_file()}} +should write Stan files. The default is \code{\link[=tempdir]{tempdir()}}. +\item \code{mc.cores}: The number of cores to use for various parallelization tasks +(e.g. running MCMC chains, installing CmdStan). The default depends on the +use case and is documented with the methods that make use of \code{mc.cores}. +} +} diff --git a/man/model-method-check_syntax.Rd b/man/model-method-check_syntax.Rd index a646a5e1..68366fb5 100644 --- a/man/model-method-check_syntax.Rd +++ b/man/model-method-check_syntax.Rd @@ -86,8 +86,8 @@ Other CmdStanModel methods: \code{\link{model-method-laplace}}, \code{\link{model-method-optimize}}, \code{\link{model-method-pathfinder}}, -\code{\link{model-method-sample_mpi}}, \code{\link{model-method-sample}}, +\code{\link{model-method-sample_mpi}}, \code{\link{model-method-variables}}, \code{\link{model-method-variational}} } diff --git a/man/model-method-compile.Rd b/man/model-method-compile.Rd index d295eedc..7bfa47d7 100644 --- a/man/model-method-compile.Rd +++ b/man/model-method-compile.Rd @@ -157,8 +157,8 @@ Other CmdStanModel methods: \code{\link{model-method-laplace}}, \code{\link{model-method-optimize}}, \code{\link{model-method-pathfinder}}, -\code{\link{model-method-sample_mpi}}, \code{\link{model-method-sample}}, +\code{\link{model-method-sample_mpi}}, \code{\link{model-method-variables}}, \code{\link{model-method-variational}} } diff --git a/man/model-method-diagnose.Rd b/man/model-method-diagnose.Rd index 9a0acd31..99043501 100644 --- a/man/model-method-diagnose.Rd +++ b/man/model-method-diagnose.Rd @@ -129,8 +129,8 @@ Other CmdStanModel methods: \code{\link{model-method-laplace}}, \code{\link{model-method-optimize}}, \code{\link{model-method-pathfinder}}, -\code{\link{model-method-sample_mpi}}, \code{\link{model-method-sample}}, +\code{\link{model-method-sample_mpi}}, \code{\link{model-method-variables}}, \code{\link{model-method-variational}} } diff --git a/man/model-method-expose_functions.Rd b/man/model-method-expose_functions.Rd index a62f7bb8..b7d42231 100644 --- a/man/model-method-expose_functions.Rd +++ b/man/model-method-expose_functions.Rd @@ -77,8 +77,8 @@ Other CmdStanModel methods: \code{\link{model-method-laplace}}, \code{\link{model-method-optimize}}, \code{\link{model-method-pathfinder}}, -\code{\link{model-method-sample_mpi}}, \code{\link{model-method-sample}}, +\code{\link{model-method-sample_mpi}}, \code{\link{model-method-variables}}, \code{\link{model-method-variational}} } diff --git a/man/model-method-format.Rd b/man/model-method-format.Rd index 2aa34f18..d24010a4 100644 --- a/man/model-method-format.Rd +++ b/man/model-method-format.Rd @@ -106,8 +106,8 @@ Other CmdStanModel methods: \code{\link{model-method-laplace}}, \code{\link{model-method-optimize}}, \code{\link{model-method-pathfinder}}, -\code{\link{model-method-sample_mpi}}, \code{\link{model-method-sample}}, +\code{\link{model-method-sample_mpi}}, \code{\link{model-method-variables}}, \code{\link{model-method-variational}} } diff --git a/man/model-method-generate-quantities.Rd b/man/model-method-generate-quantities.Rd index bf25602e..23acba19 100644 --- a/man/model-method-generate-quantities.Rd +++ b/man/model-method-generate-quantities.Rd @@ -178,8 +178,8 @@ Other CmdStanModel methods: \code{\link{model-method-laplace}}, \code{\link{model-method-optimize}}, \code{\link{model-method-pathfinder}}, -\code{\link{model-method-sample_mpi}}, \code{\link{model-method-sample}}, +\code{\link{model-method-sample_mpi}}, \code{\link{model-method-variables}}, \code{\link{model-method-variational}} } diff --git a/man/model-method-laplace.Rd b/man/model-method-laplace.Rd index b033fbe3..253d67f5 100644 --- a/man/model-method-laplace.Rd +++ b/man/model-method-laplace.Rd @@ -214,8 +214,8 @@ Other CmdStanModel methods: \code{\link{model-method-generate-quantities}}, \code{\link{model-method-optimize}}, \code{\link{model-method-pathfinder}}, -\code{\link{model-method-sample_mpi}}, \code{\link{model-method-sample}}, +\code{\link{model-method-sample_mpi}}, \code{\link{model-method-variables}}, \code{\link{model-method-variational}} } diff --git a/man/model-method-optimize.Rd b/man/model-method-optimize.Rd index dcf77444..b9b53454 100644 --- a/man/model-method-optimize.Rd +++ b/man/model-method-optimize.Rd @@ -332,8 +332,8 @@ Other CmdStanModel methods: \code{\link{model-method-generate-quantities}}, \code{\link{model-method-laplace}}, \code{\link{model-method-pathfinder}}, -\code{\link{model-method-sample_mpi}}, \code{\link{model-method-sample}}, +\code{\link{model-method-sample_mpi}}, \code{\link{model-method-variables}}, \code{\link{model-method-variational}} } diff --git a/man/model-method-pathfinder.Rd b/man/model-method-pathfinder.Rd index 85fc9236..41504358 100644 --- a/man/model-method-pathfinder.Rd +++ b/man/model-method-pathfinder.Rd @@ -357,8 +357,8 @@ Other CmdStanModel methods: \code{\link{model-method-generate-quantities}}, \code{\link{model-method-laplace}}, \code{\link{model-method-optimize}}, -\code{\link{model-method-sample_mpi}}, \code{\link{model-method-sample}}, +\code{\link{model-method-sample_mpi}}, \code{\link{model-method-variables}}, \code{\link{model-method-variational}} } diff --git a/man/model-method-variables.Rd b/man/model-method-variables.Rd index dc80ed9a..87e9d73e 100644 --- a/man/model-method-variables.Rd +++ b/man/model-method-variables.Rd @@ -46,8 +46,8 @@ Other CmdStanModel methods: \code{\link{model-method-laplace}}, \code{\link{model-method-optimize}}, \code{\link{model-method-pathfinder}}, -\code{\link{model-method-sample_mpi}}, \code{\link{model-method-sample}}, +\code{\link{model-method-sample_mpi}}, \code{\link{model-method-variational}} } \concept{CmdStanModel methods} diff --git a/man/model-method-variational.Rd b/man/model-method-variational.Rd index 3678f11e..1b2d9a74 100644 --- a/man/model-method-variational.Rd +++ b/man/model-method-variational.Rd @@ -333,8 +333,8 @@ Other CmdStanModel methods: \code{\link{model-method-laplace}}, \code{\link{model-method-optimize}}, \code{\link{model-method-pathfinder}}, -\code{\link{model-method-sample_mpi}}, \code{\link{model-method-sample}}, +\code{\link{model-method-sample_mpi}}, \code{\link{model-method-variables}} } \concept{CmdStanModel methods}