-
Thank you for this package! I started using it a couple of days ago, and I'm impressed how simple and intuitive it makes MCMC model fitting. If I want to get the data behind the fit quantiles shown in the plot, how would you recommend to do that? I'm exploring reimplementing parts of the Does it maybe make sense in the medium term to split these summary statistics into separate functions for a user to be able to access too? |
Beta Was this translation helpful? Give feedback.
Replies: 6 comments
-
Thanks a lot for the encouraging words! All the MCMC data is in But I'm eager to hear if you have a use case that would benefit from And yes, splitting out some of the functionality from |
Beta Was this translation helpful? Give feedback.
-
BTW, are you aware that
|
Beta Was this translation helpful? Give feedback.
-
Thank you, this is very helpful! A
I'm trying to extract the best fitted value and its confidence intervals on the domain of the original data. I have read up a bit on pars_pop = paste0(fit$pars$population, collapse = "|")
samples = tidybayes::spread_draws(fit$mcmc_post, !!rlang::sym(pars_pop), regex=TRUE) %>%
tidybayes::sample_draws(1000) %>%
tidyr::expand_grid(x=seq(min(fit$data$x), max(fit$data$x), length.out=30)) %>%
dplyr::mutate(low = rlang::exec(fit$simulate, !!!., type="fitted",
quantile=0.05, add_attr=FALSE)) %>%
high = rlang::exec(fit$simulate, !!!., type="fitted",
quantile=0.95, add_attr=FALSE)) %>%
dplyr::group_by(x) %>%
dplyr::summarize(low = mean(low),
high = mean(high)) This does, however, seem to fit only the median and not the high/low quantiles: ggplot(samples, aes(x=x)) +
geom_point(aes(y=low), color="green") +
geom_line(aes(y=high), color="red") whereas if I use your plotting function I get: plot(fit, q_fit=c(0.05,0.95)) I guess |
Beta Was this translation helpful? Give feedback.
-
In the meantime, try replacing the last part of your first code chunk with:
(untested, so let me know if this solves it) |
Beta Was this translation helpful? Give feedback.
-
That works perfectly, thank you! |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
mcp
0.3 has now been published on CRAN. You can usepredict(fit)
andfitted(fit)
to get quantiles. See more in this article and in the documentation for these functions.