Skip to content

Commit

Permalink
Added Gelman diagnostics in returned variable of estim_param
Browse files Browse the repository at this point in the history
  • Loading branch information
sbuis committed Sep 10, 2024
1 parent 7829427 commit 7b1724b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
11 changes: 9 additions & 2 deletions R/bayesian_functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#'
#' @param optim_results Results list returned by bayesian method wrappers
#'
#' @return Prints results of bayesian methods
#' @return Prints results of bayesian methods and return Gelman diagnostics
#' @keywords internal
#'
summary_bayesian <- function(optim_options, param_info, optim_results) {
Expand All @@ -30,6 +30,13 @@ summary_bayesian <- function(optim_options, param_info, optim_results) {
"Complementary graphs and results can be found in ",
path_results, "\n\n"
))

## Compute Gelman Diagnostics
if (is.null(optim_options$thin)) optim_options$thin <- 1
gelman_diags <- gelmanDiagnostics(out, thin = optim_options$thin, plot = F)

return(gelman_diags)

}


Expand All @@ -40,7 +47,7 @@ summary_bayesian <- function(optim_options, param_info, optim_results) {
#'
#' @param optim_results Results list returned by bayesian method wrappers
#'
#' @return Save plots in optim_options$path_results.
#' @return List of plot objects
#'
#' @keywords internal
#'
Expand Down
2 changes: 1 addition & 1 deletion R/optim_switch.R
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ optim_switch <- function(...) {
optim_options = optim_options,
param_info = param_info, optim_results = res
)
summary_bayesian(
res$gelman_diags <- summary_bayesian(
optim_options = optim_options, param_info = param_info,
optim_results = res
)
Expand Down

0 comments on commit 7b1724b

Please sign in to comment.