Skip to content

Latest commit

 

History

History
72 lines (51 loc) · 1.61 KB

output-numerical.md

File metadata and controls

72 lines (51 loc) · 1.61 KB
CurrentModule = Pigeons

[Numerical outputs and diagnostics](@id output-numerical)

Use sample_array() to convert target chain samples into a format that can then be consumed by the third party package MCMCChains.jl. We outline some useful features here, read
the MCMCChains.jl documentation for more information.

Quick summary of ESS, moments, etc

Make sure to have the third party packages DynamicPPL and MCMCChains installed via

using Pkg; Pkg.add("DynamicPPL", "MCMCChains")

Also make sure to record the trace, with record = [traces]:

using DynamicPPL
using Pigeons
using MCMCChains

# example target: Binomial likelihood with parameter p = p1 * p2
an_unidentifiable_model = Pigeons.toy_turing_unid_target(100, 50)

pt = pigeons(
        target = an_unidentifiable_model, 
        record = [traces; round_trip; record_default()]
    )

# collect the statistics and convert to MCMCChains' Chains
# to have axes labels matching variable names in Turing and Stan
samples = Chains(pt)

samples

Accessing individual diagnostics and summaries

Computing a mean (but see [online statistics](@ref output-online) for a constant memory alternative):

using Statistics 
m = mean(samples)

to access an individual entry in this example and the following ones:

m[:p1, :mean]

Highest posterior density interval:

hpd(samples, alpha = 0.05)

For ESS estimates:

ess(samples)