Baytes.Baytes
— ModuleBayesian inference on state space models
Baytes.PrintedParameter
— Typestruct PrintedParameter{A<:Tuple, B<:Tuple}
Contains several useful information for sampled parameter.
Fields
tagged::Tuple
: Unique tagged parameter of all kernels.printed::Tuple
: Parameter names based on their dimension
Baytes.SampleInfo
— Typestruct SampleInfo{A<:Baytes.PrintedParameter, U<:UpdateBool, B<:UpdateBool}
Contains several useful information for constructing sampler.
Fields
printedparam::Baytes.PrintedParameter
: Parameter settings for printing.iterations::Int64
: Total number of sampling iterations.burnin::Int64
: Burnin iterations.thinning::Int64
: Number of consecutive samples taken for diagnostics output.Nalgorithms::Int64
: Number of algorithms used while sampling.Nchains::Int64
: Number of chains used while sampling.captured::UpdateBool
: Boolean if sampler need to be updated after a proposal run. This is the case for, e.g. PMCMC., or for adaptive tempering.tempered::UpdateBool
: Boolean if temperature is adapted for target function.
Baytes.Trace
— Typestruct Trace{C<:TraceSummary, A<:NamedTuple, B}
Contains sampling chain and diagnostics for given algorithms.
Fields
val::Array{Vector{A}, 1} where A<:NamedTuple
: Model samples ~ out vector for corresponding chain, inner vector for iterationdiagnostics::Vector
: Algorithm diagnostics ~ out vector for corresponding chain, inner vector for iterationsummary::TraceSummary
: Information about trace used for postprocessing.
Baytes.TraceSummary
— Typestruct TraceSummary{A<:TemperingMethod, B<:Union{DataTune, Vector{<:DataTune}}, D<:SampleDefault, S<:SampleInfo}
Contains useful information for post-sampling analysis. Also allows to continue sampling with given sampler.
Fields
tempertune::TemperingMethod
: Tuning container for temperature temperingdatatune::Union{DataTune, Vector{<:DataTune}}
: Tuning container for data temperingdefault::SampleDefault
: Default settings used for sample functioninfo::SampleInfo
: Information about trace used for postprocessing.progress::ProgressMeter.Progress
: Progress Log while sampling.
Baytes.TraceTransform
— Typestruct TraceTransform{T<:ModelWrappers.Tagged, P}
Contains arguments for trace to extract parameter from a 'Trace'.
Fields
tagged::ModelWrappers.Tagged
: Contains parameter where output information is printed.paramnames::Any
: Parameter names based on tagged model parameter.chains::Vector{Int64}
: Chain indices that are used for output diagnostics.algorithms::Vector{Int64}
: Algorithm indices that are used for output diagnostics.burnin::Int64
: Number of burnin steps before output diagnostics are taken.thinning::Int64
: Number of steps that are set between 2 consecutive samples.maxiterations::Int64
: Maximum number of iterations to be collected for each chain.effective_iterations::StepRange{Int64, Int64}
: StepRange for indices of effective samples
Baytes.TransformInfo
— Typestruct TransformInfo
Contains arguments for trace to extract parameter. Used to construct a 'TraceTransform'.
Fields
chains::Vector{Int64}
: Chain indices that are used for output diagnostics.algorithms::Vector{Int64}
: Algorithm indices that are used for output diagnostics.burnin::Int64
: Number of burnin steps before output diagnostics are taken.thinning::Int64
: Number of steps that are set between 2 consecutive samples.maxiterations::Int64
: Maximum number of iterations to be collected for each chain.effective_iterations::StepRange{Int64, Int64}
: StepRange for indices of effective samples
Base.summary
— Functionsummary(trace, algorithmᵛ, transform)
summary(trace, algorithmᵛ, transform, printdefault)
Print summary of parameter chain and diagnostics to REPL.
Examples
Baytes.chainparamdiagnostics
— Methodchainparamdiagnostics(arr, computingtime)
Compute cross-chain diagnostics for parameter.
Examples
Baytes.chainsummary
— Functionchainsummary(trace, transform)
chainsummary(trace, transform, printdefault)
Return summary for trace parameter chains. 'printdefault' defines quantiles and number of digits for printing.
Examples
Baytes.construct
— Methodconstruct(tempering, model, chains)
Construct a Tempering tuning struct with the appropriate type for model parameter.
Examples
Baytes.construct
— Methodconstruct(model, datatune, chains, args)
Construct separate models and data tuning container for each chain.
Examples
Baytes.construct
— Methodconstruct(
_rng,
model,
data,
default,
tempering,
datatune,
chains,
updatesampler,
args
)
Construct chains
MCMC chains and initiate all algorithms stated in args
separately. A separate model for each chain is provided to avoid pointer issues. If args
is a single SMC
algorithm, chains will not be separately allocated but instead used within the algorithm. Note that smc still works as intended if used alongside other mcmc sampler in args
.
Examples
Baytes.diagnosticsbuffer
— Methoddiagnosticsbuffer(diagtypes, iterations, Nchains, args)
Return buffer vector of type diagtypes
. Comes from function infer
.
Examples
Baytes.flatten_chainvals
— Methodflatten_chainvals(trace, transform)
Flatten Vector of Parameter NamedTuples into a Matrix, where each row represents draws for a single parameter.
Examples
Baytes.get_chaindiagnostics
— Methodget_chaindiagnostics(
diagnostics,
chain,
Nalgorithm,
effective_iterations
)
Obtain parameter diagnostics from trace at chain chain
, excluding first burnin
samples.
Examples
Baytes.get_chainvals
— Methodget_chainvals(val, chain, effective_iterations)
Return a view of a specific index 'chain' for Vector of Parameter chains of NamedTuples with index 'effective_iterations'.
Examples
Baytes.is_stuck
— Methodis_stuck(arr3D)
Check if any parameter has been stuck at each iteration in any chain, in which case chainsummary will skip computations.
Examples
Baytes.maxiterations
— Methodmaxiterations(datatune, iterations)
Obtain maximum number of iterations based on datatune. This will always be user input, except if rolling/expanding data is used, in which case iterations are capped.
Examples
Baytes.merge_chainvals
— Methodmerge_chainvals(trace, transform)
Merge Vector of Parameter chains of NamedTuples into a single vector.
Examples
Baytes.mergediagnostics
— Methodmergediagnostics(
paramdiagnostic,
paramquantiles,
chainparamdiagnostic
)
Merge all statistics for all parameter.
Examples
Baytes.paramdiagnostics
— Methodparamdiagnostics(arr)
Compute in-chain diagnostics for parameter.
Examples
Baytes.paramquantiles
— Methodparamquantiles(vec, printdefault)
Compute quantiles provided by printdefault
for parameter.
Examples
Baytes.printchainsummary
— Functionprintchainsummary(model, trace, transform, backend)
printchainsummary(
model,
trace,
transform,
backend,
printdefault;
kwargs...
)
Add a ModelWrapper struct 'model' as a function argument to print model.val as "true" parameter in table.
Examples
Baytes.printchainsummary
— Functionprintchainsummary(trace, transform, backend)
printchainsummary(
trace,
transform,
backend,
printdefault;
kwargs...
)
Print summary for trace parameter chains. backend
may be Val(:text), or Val(:latex).
Examples
Baytes.printdiagnosticssummary
— Functionprintdiagnosticssummary(
trace,
algorithmᵛ,
transform,
backend
)
printdiagnosticssummary(
trace,
algorithmᵛ,
transform,
backend,
printdefault;
kwargs...
)
Return summary for trace parameter diagnostics, backend
may be Val(:text), or Val(:latex).
Examples
Baytes.printedparam
— Methodprintedparam(datatune, sym, algorithm)
Obtain all parameter where output diagnostics can be printed. Separate step to showparam in case parameter is increasing over time and cannot be printed
Examples
Baytes.progress
— Methodprogress(report, info)
Return Progress
struct with arguments from info
for sampling session.
Examples
Baytes.savechainsummary
— Functionsavechainsummary(trace, transform)
savechainsummary(trace, transform, printdefault)
savechainsummary(trace, transform, printdefault, name)
Save summary for trace parameter chains as html file.
Examples
Baytes.savechainsummary
— Functionsavechainsummary(model, trace, transform)
savechainsummary(model, trace, transform, printdefault)
savechainsummary(
model,
trace,
transform,
printdefault,
name
)
Add a ModelWrapper struct 'model' as a function argument to save model.val as "true" parameter in table.
Examples
Baytes.savetrace
— Functionsavetrace(trace, model, algorithm)
savetrace(trace, model, algorithm, name)
Save trace
, model
and algorithm
to current working directory with name 'name'.
Examples
Baytes.showparam
— Methodshowparam(model, datatune, constructor)
Return all unique targetted parameter, and parameter where diagnostics will be printed. Separate to get_sym.
Examples
Baytes.trace_to_2DArray
— Methodtrace_to_2DArray(trace, transform)
Change trace.val to 2d Array. First dimension is iterations*chains, second number of parameter.
Examples
Baytes.trace_to_2DArrayᵤ
— Methodtrace_to_2DArrayᵤ(trace, transform)
Change trace.val to 2d Array in unconstrained space. First dimension is iterations*chains, second number of parameter.
Examples
Baytes.trace_to_3DArray
— Methodtrace_to_3DArray(trace, transform)
Change trace.val to 3d Array that is consistent with MCMCCHains dimensons. First dimension is iterations, second number of parameter, third number of chains.
Examples
Baytes.trace_to_3DArrayᵤ
— Methodtrace_to_3DArrayᵤ(trace, transform)
Change trace.val to 3d Array in unconstrained space that is consistent with MCMCCHains dimensons. First dimension is iterations, second number of parameter, third number of chains.
Examples
Baytes.trace_to_crosschainmean
— Methodtrace_to_crosschainmean(trace, transform)
Change trace.val to 3d Array and return Posterior mean as NamedTuple and as Vector for each parameter for each MCMC iteration across MCMC kernels
Examples
Baytes.trace_to_posteriormean
— Methodtrace_to_posteriormean(mod_array, transform)
Change trace.val to 3d Array and return Posterior mean as NamedTuple and as Vector
Examples
Baytes.update
— Methodupdate(datatune, temperingadaption, smc)
Check if we can capture results from last proposal step. Typically only possible if a single MCMC or SMC step applied.
Examples
BaytesCore.infer
— Methodinfer(_rng, diagnostics, algorithmsᵛ, model, data)
Infer types of all Diagnostics container.
Examples
BaytesCore.propose!
— Methodpropose!(_rng, trace, algorithmᵛ, modelᵛ, data)
Propose new parameter for each model in modelᵛ
given data
with algorithms algorithmᵛ
. A separate model for each chain is provided to avoid pointer issues. If args
is a single SMC
algorithm, chains will not be separately allocated but instead used within the algorithm. Note that smc still works as intended if used alongside other mcmc sampler in args
.
Examples
BaytesCore.update!
— Methodupdate!(tempertune, trace, algorithm, iter)
Update tempering tune based on output diagnostics of last kernels in each chain.
Examples
StatsBase.sample!
— Methodsample!(iterations, _rng, model, data, trace, algorithmᵛ)
Continue sampling with all algorithms in algorithm
.
Examples
StatsBase.sample
— Methodsample(_rng, model, data, args; default)
Sample model
parameter given data
with args
algorithm. Default sampling arguments given in default
keyword.
Examples