Created
October 24, 2016 20:58
-
-
Save ericnovik/81a8cf0048d0e782859fce7b5b701950 to your computer and use it in GitHub Desktop.
Helper R function to read output csv files generated by CmdStan
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
read_cmd_stan_output <- function (dir, file_prefix, n_chains = 4) { | |
csvfiles <- character(n_chains) | |
for (i in 1:n_chains) | |
csvfiles[i] <- paste0(dir, file_prefix, i, ".csv") | |
stan_fit <- rstan::read_stan_csv(csvfiles) | |
return(stan_fit) | |
} | |
# Assume /my/base/dir/ contains stan_output_model_1.csv, | |
# stan_output_model__2.csv, stan_output_model_3.csv, | |
# stan_output_model_4.csv | |
base_dir <- "/my/base/dir/" | |
prefix <- "stan_output_model_" | |
fit <- read_cmd_stan_output(base_dir, prefix, n_chains = 4) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment