Skip to content

Commit

Permalink
Put func_MCMC() progressbar under verbose (#14)
Browse files Browse the repository at this point in the history
Otherwise, the `pb` would be drawn even if the user sets `verbose = FALSE` on `BayesSurvive()` (which I assume is not the intended behaviour).
  • Loading branch information
wleoncio committed Aug 15, 2024
1 parent 5fb4e4a commit a42dadd
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions R/func_MCMC.R
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,10 @@ func_MCMC <- function(survObj, hyperpar, initial,
# MCMC sampling

# Initializes the progress bar
if (verbose) cat(" Running MCMC iterations ...\n")
pb <- txtProgressBar(min = 0, max = nIter, style = 3, width = 50, char = "=")
if (verbose) {
cat(" Running MCMC iterations ...\n")
pb <- txtProgressBar(min = 0, max = nIter, style = 3, width = 50, char = "=")
}

for (M in 1:nIter) {
# if (method %in% c("CoxBVSSL", "Sub-struct") ||
Expand Down Expand Up @@ -284,9 +286,9 @@ func_MCMC <- function(survObj, hyperpar, initial,
# }

# Sets the progress bar to the current state
setTxtProgressBar(pb, M)
if (verbose) setTxtProgressBar(pb, M)
} # the end of MCMC sampling
close(pb) # Close the connection of progress bar
if (verbose) close(pb) # Close the connection of progress bar

if (S == 1 && MRF_G) {
mcmcOutcome$gamma.margin <- mcmcOutcome$gamma.margin / (nIter - burnin)
Expand Down

0 comments on commit a42dadd

Please sign in to comment.