From ce8694fb9f0a5ab6d69c8138e133aec7e5d6448e Mon Sep 17 00:00:00 2001 From: Marco Colombo Date: Tue, 17 Dec 2024 20:09:49 +0100 Subject: [PATCH] Rename the seed parameter for loo_R2() and add docs. --- R/loo_predict.R | 8 +++++--- man/loo_R2.brmsfit.Rd | 5 ++++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/R/loo_predict.R b/R/loo_predict.R index bf9af93c..b955795d 100644 --- a/R/loo_predict.R +++ b/R/loo_predict.R @@ -170,6 +170,8 @@ E_loo_value <- function(x, psis_object, type = "mean", probs = 0.5) { #' @aliases loo_R2 #' #' @inheritParams bayes_R2.brmsfit +#' @param seed Optional integer used to initialize the random number +#' generator. #' @param ... Further arguments passed to #' \code{\link[brms:posterior_epred.brmsfit]{posterior_epred}} and #' \code{\link[brms:log_lik.brmsfit]{log_lik}}, @@ -214,7 +216,7 @@ E_loo_value <- function(x, psis_object, type = "mean", probs = 0.5) { #' @export loo_R2.brmsfit <- function(object, resp = NULL, summary = TRUE, robust = FALSE, probs = c(0.025, 0.975), - brms_seed = NULL, ...) { + seed = NULL, ...) { contains_draws(object) object <- restructure(object) resp <- validate_resp(resp, object) @@ -242,12 +244,12 @@ loo_R2.brmsfit <- function(object, resp = NULL, summary = TRUE, } # set the random seed if required - if (!is.null(brms_seed)) { + if (!is.null(seed)) { if (exists(".Random.seed", envir = .GlobalEnv)) { rng_state_old <- get(".Random.seed", envir = .GlobalEnv) on.exit(assign(".Random.seed", rng_state_old, envir = .GlobalEnv)) } - set.seed(brms_seed) + set.seed(seed) } args_y <- list(object, warn = TRUE, ...) diff --git a/man/loo_R2.brmsfit.Rd b/man/loo_R2.brmsfit.Rd index 0d838f53..2da06fcd 100644 --- a/man/loo_R2.brmsfit.Rd +++ b/man/loo_R2.brmsfit.Rd @@ -11,7 +11,7 @@ summary = TRUE, robust = FALSE, probs = c(0.025, 0.975), - brms_seed = NULL, + seed = NULL, ... ) } @@ -33,6 +33,9 @@ Only used if \code{summary} is \code{TRUE}.} \item{probs}{The percentiles to be computed by the \code{quantile} function. Only used if \code{summary} is \code{TRUE}.} +\item{seed}{Optional integer used to initialize the random number +generator.} + \item{...}{Further arguments passed to \code{\link[brms:posterior_epred.brmsfit]{posterior_epred}} and \code{\link[brms:log_lik.brmsfit]{log_lik}},