@@ -593,18 +593,22 @@ mcmc_intervals_data <- function(x,
593593 prob = 0.5 ,
594594 prob_outer = 0.9 ,
595595 point_est = c(" median" , " mean" , " none" ),
596- rhat = numeric ()) {
596+ rhat = numeric (),
597+ .data_long = NULL ) {
597598 check_ignored_arguments(... )
598599 probs <- check_interval_widths(prob , prob_outer )
599600 prob <- probs [1 ]
600601 prob_outer <- probs [2 ]
601602
602- x <- prepare_mcmc_array(x , pars , regex_pars , transformations )
603- x <- merge_chains(x )
604-
605- data_long <- melt_mcmc(x ) %> %
606- dplyr :: as_tibble() %> %
607- rlang :: set_names(tolower )
603+ if (is.null(.data_long )) {
604+ x <- prepare_mcmc_array(x , pars , regex_pars , transformations )
605+ x <- merge_chains(x )
606+ data_long <- melt_mcmc(x ) %> %
607+ dplyr :: as_tibble() %> %
608+ rlang :: set_names(tolower )
609+ } else {
610+ data_long <- .data_long
611+ }
608612
609613 probs <- c(0.5 - prob_outer / 2 ,
610614 0.5 - prob / 2 ,
@@ -691,17 +695,17 @@ mcmc_areas_data <- function(x,
691695 point_est <- match.arg(point_est )
692696 temp_point_est <- if (point_est == " none" ) " median" else point_est
693697
694- intervals <- mcmc_intervals_data(x , pars , regex_pars , transformations ,
695- prob = probs [1 ], prob_outer = probs [2 ],
696- point_est = temp_point_est , rhat = rhat )
697-
698698 x <- prepare_mcmc_array(x , pars , regex_pars , transformations )
699699 x <- merge_chains(x )
700700
701701 data_long <- melt_mcmc(x ) %> %
702702 dplyr :: as_tibble() %> %
703703 rlang :: set_names(tolower )
704704
705+ intervals <- mcmc_intervals_data(x , prob = probs [1 ], prob_outer = probs [2 ],
706+ point_est = temp_point_est , rhat = rhat ,
707+ .data_long = data_long )
708+
705709 # Compute the density intervals
706710 data_inner <- data_long %> %
707711 compute_column_density(
0 commit comments