Skip to content

PosteriorDB.jl

Documentation for PosteriorDB.jl ↗

If you have loaded a PosteriorDB.ReferencePosterior, you can transform it into a FlexiChain using FlexiChains.from_posteriordb_ref:

julia
using PosteriorDB, FlexiChains

pdb = PosteriorDB.database()
post = PosteriorDB.posterior(pdb, "eight_schools-eight_schools_centered")
ref = PosteriorDB.reference_posterior(post)

chn = FlexiChains.from_posteriordb_ref(ref)
╭─FlexiChain (1000 iterations, 10 chains) ─────────────────────────────────────
 ↓ iter  = 10010:10:20000
 → chain = 1:10

 Parameters (10) ── String
  Float64  theta[1], theta[2], theta[3], theta[4], theta[5], theta[6],        
           theta[7], theta[8], mu, tau                                        

 Extras (0)
  (none)
╰──────────────────────────────────────────────────────────────────────────────╯

You can then use all the functionality of FlexiChains on chn:

julia
summarystats(chn)
╭─FlexiSummary (9 statistics) ─────────────────────────────────────────────────
   iter    collapsed
   chain   collapsed
 ↓ stat  = [mean, std, mcse, ess_bulk, ess_tail, rhat, q5, q50, q95]

 Parameters (10) ── String
  Float64  theta[1], theta[2], theta[3], theta[4], theta[5], theta[6],        
           theta[7], theta[8], mu, tau                                        

 Extras (0)
  (none)

 Summary
      param    mean     std    mcse    ess_bulk    ess_tail    rhat
   theta[1]  6.1505  5.6159  0.0559  10049.2107   9629.8020  0.9999
   theta[2]  4.9396  4.6456  0.0464   9996.0196  10089.3722  1.0001
   theta[3]  3.9059  5.2807  0.0545   9441.0149   8985.2446  1.0000
   theta[4]  4.7960  4.7709  0.0476   9991.7265   9631.6656  1.0001
   theta[5]  3.6144  4.6147  0.0462   9886.2569  10175.6473  1.0000
   theta[6]  4.0511  4.7962  0.0486   9746.7818  10004.1962  0.9999
   theta[7]  6.3172  5.0029  0.0500  10007.4700   9549.1189  0.9999
   theta[8]  4.8840  5.3177  0.0544   9569.4428   9828.3536  1.0003
         mu  4.4105  3.3093  0.0331   9994.5870   9919.6914  1.0000
        tau  3.6021  3.1985  0.0320   9954.0515   9873.9898  1.0002
╰──────────────────────────────────────────────────────────────────────────────╯

Docstrings

FlexiChains.from_posteriordb_ref Function
julia
FlexiChains.from_posteriordb_ref(
    ref::PosteriorDB.ReferencePosterior
)::FlexiChain{String}

Load a PosteriorDB.ReferencePosterior into a FlexiChain. The keys are stored as strings, which matches the storage format in PosteriorDB.jl.

source