njtierney / mmcc

Fast, tidy functions for mcmc diagnostics and summaries, built with data.table
http://mmcc.njtierney.com/
Other
24 stars 5 forks source link

Allow multiple confidence intervals #46

Closed bquilty25 closed 4 years ago

bquilty25 commented 4 years ago

Added the ability to provide a vector of length 2 to the conf_level argument in tidy.mcmc.list, for example, c(0.95, 0.50), to produce the 95% and 50% interval. Useful when it's not necessarily appropriate to report the mean or median.

njtierney commented 4 years ago

Hi there,

Thanks so much for this contribution, it's a great idea!

I actually get this error when trying out your code, can you confirm, and potentially fix?

library(coda)
library(mmcc)
data(line)
tidy(line)
#>    parameter      mean        sd      2.5%    median    97.5%
#> 1:     alpha 2.9875644 0.4983950 1.9650403 3.0188300 3.876589
#> 2:      beta 0.7991864 0.3366834 0.1430713 0.7962500 1.469723
#> 3:     sigma 0.9680519 0.7413014 0.4249618 0.7911975 2.559520
# can provide two levels of confidence:
tidy(line, conf_level = c(0.95, 50))
#> Error in quantile.default(value, q[1]): 'probs' outside [0,1]

Created on 2020-06-03 by the reprex package (v0.3.0)

Thanks again, really appreciate it!

bquilty25 commented 4 years ago

Thanks! I think you've just made a little typo - 50 should be 0.50.

njtierney commented 4 years ago

Ah, indeed!

Thanks for picking up on that, saved me a trip down a rabbit hole.

I think this is all good now, thanks again!