Created
December 21, 2022 11:24
-
-
Save oliviergimenez/b91c81f56ffe410bb02feb1a03d23601 to your computer and use it in GitHub Desktop.
Converts MCMC output list into dataframe with better column names for plotting
This file contains hidden or 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
# from Cole Monnahan https://github.com/colemonnahan/fcwhales | |
convert_to_df <- function(fit, name = NULL){ | |
fit <- as.mcmc(fit) | |
post <- data.frame(do.call(rbind, fit)) | |
new <- gsub('[.]$', '', names(post)) | |
new <- gsub('[.]','_', new) | |
names(post) <- new | |
if(!is.null(name)) post$model <- name | |
return(post) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment