From a102b15c07b16633e05c17dfd04b27caeb8c5af3 Mon Sep 17 00:00:00 2001 From: Jim Thorson Date: Tue, 17 Sep 2024 13:50:02 -1000 Subject: [PATCH] add track_progress argument to loo_residuals --- R/utility.R | 5 +++++ man/loo_residuals.Rd | 10 +++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/R/utility.R b/R/utility.R index bd7ea99..0bf90af 100644 --- a/R/utility.R +++ b/R/utility.R @@ -10,6 +10,7 @@ #' @param what whether to return quantile residuals, or samples from the leave-one-out predictive #' distribution of data, or a table of leave-one-out predictions and standard errors for the #' latent state +#' @param track_progress whether to track runtimes on terminal #' @param ... Not used #' #' @details @@ -31,6 +32,7 @@ loo_residuals <- function( object, nsim = 100, what = c("quantiles","samples","loo"), + track_progress = TRUE, ... ){ # Extract and make object @@ -44,6 +46,9 @@ function( object, # Loop through observations for(r in 1:nrow(df) ){ + if( (r %% floor(nrow(df)/10))==1 ){ + if(isTRUE(track_progress)) message("Running leave-one-out fit ",r," of ",nrow(df)," at ",Sys.time()) + } ts_r = tsdata ts_r[match(df[r,1],time(tsdata)),match(df[r,2],colnames(tsdata))] = NA diff --git a/man/loo_residuals.Rd b/man/loo_residuals.Rd index 260891e..bb1c65b 100644 --- a/man/loo_residuals.Rd +++ b/man/loo_residuals.Rd @@ -4,7 +4,13 @@ \alias{loo_residuals} \title{Calculate leave-one-out residuals} \usage{ -loo_residuals(object, nsim = 100, what = c("quantiles", "samples", "loo"), ...) +loo_residuals( + object, + nsim = 100, + what = c("quantiles", "samples", "loo"), + track_progress = TRUE, + ... +) } \arguments{ \item{object}{Output from \code{\link{dsem}}} @@ -16,6 +22,8 @@ such that simulation residuals are required.} distribution of data, or a table of leave-one-out predictions and standard errors for the latent state} +\item{track_progress}{whether to track runtimes on terminal} + \item{...}{Not used} } \value{