Posterior statistics

The methods listed below are defined in src/stats.jl.

StatsBase.autocorFunction
autocor(
    chains;
    append_chains = true,
    demean = true,
    [lags,]
    kwargs...,
)

Compute the autocorrelation of each parameter for the chain.

The default lags are [1, 5, 10, 50], upper-bounded by n - 1 where n is the number of samples used in the estimation.

Setting append_chains=false will return a vector of dataframes containing the autocorrelations for each chain.

source
DataAPI.describeFunction
describe(io, chains[;
         q = [0.025, 0.25, 0.5, 0.75, 0.975],
         etype = :bm,
         kwargs...])

Print the summary statistics and quantiles for the chain.

source
StatsBase.summarystatsFunction
function summarystats(
    chains;
    sections = _default_sections(chains),
    append_chains= true,
    autocov_method::AbstractAutocovMethod = AutocovMethod(),
    maxlag = 250,
    kwargs...
)

Compute the mean, standard deviation, Monte Carlo standard error, bulk- and tail- effective sample size, and $\widehat{R}$ diagnostic for each parameter in the chain.

Setting append_chains=false will return a vector of dataframes containing the summary statistics for each chain.

When estimating the effective sample size, autocorrelations are computed for at most maxlag lags.

source
Statistics.quantileFunction
quantile(chains[; q = [0.025, 0.25, 0.5, 0.75, 0.975], append_chains = true, kwargs...])

Compute the quantiles for each parameter in the chain.

Setting append_chains=false will return a vector of dataframes containing the quantiles for each chain.

source
MCMCChains.hpdFunction
hpd(chn::Chains; alpha::Real=0.05, kwargs...)

Return the highest posterior density interval representing 1-alpha probability mass.

Note that this will return a single interval and will not return multiple intervals for discontinuous regions.

Examples

julia> val = rand(500, 2, 3);
julia> chn = Chains(val, [:a, :b]);

julia> hpd(chn)
HPD
  parameters     lower     upper 
      Symbol   Float64   Float64 

           a    0.0554    0.9944
           b    0.0114    0.9460
source