Skip to content

Commit

Permalink
Correct chains handling for draws
Browse files Browse the repository at this point in the history
  • Loading branch information
andrjohns committed Dec 26, 2023
1 parent 6867b6d commit 9f20da4
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions R/sample.R
Original file line number Diff line number Diff line change
Expand Up @@ -211,9 +211,10 @@ stan_sample <- function(fn, par_inits, additional_args = list(),
metadata <- all_samples[[1]]$metadata
adaptation <- lapply(all_samples, function(chain) { chain$adaptation })
timing <- lapply(all_samples, function(chain) { chain$timing })
par_cols <- grep("pars", draw_names)
draws <- lapply(all_samples, function(chain) {
setNames(data.frame(chain$samples), chain$header)
draws <- lapply(seq_len(num_chains), function(chain) {
dr_df <- setNames(data.frame(all_samples[[chain]]$samples), draw_names)
dr_df$.chain <- chain
dr_df
})
diagnostic_vars <- c("accept_stat__", "stepsize__", "treedepth__", "n_leapfrog__", "divergent__", "energy__")
par_vars <- draw_names[!(draw_names %in% diagnostic_vars)]
Expand Down

0 comments on commit 9f20da4

Please sign in to comment.