Reshape estimations with multiple iterations (draws) to long format
Reshape a wide data.frame of iterations (such as posterior draws or bootsrapped samples) as columns to long format. Instead of having all iterations as columns (e.g., iter_1, iter_2, ...), will return 3 columns with the \*_index (the previous index of the row), the \*_group (the iteration number) and the \*_value (the value of said iteration).
reshape_iterations(x, prefix = c("draw", "iter", "iteration", "sim"))
reshape_draws(x, prefix = c("draw", "iter", "iteration", "sim"))x |
A data.frame containing posterior draws obtained from |
prefix |
The prefix of the draws (for instance, |
Data frame of reshaped draws in long format.
if (require("rstanarm")) {
model <- stan_glm(mpg ~ am, data = mtcars, refresh = 0)
draws <- insight::get_predicted(model)
long_format <- reshape_iterations(draws)
head(long_format)
}Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.