Index
ExtensibleMCMC.AdaptationExtensibleMCMC.AdaptationUnifRWExtensibleMCMC.AdaptationUnifRWExtensibleMCMC.AdaptationUnifRWExtensibleMCMC.CallbackExtensibleMCMC.GaussianRandomWalkExtensibleMCMC.GaussianRandomWalkMixExtensibleMCMC.GenericChainStatsExtensibleMCMC.GenericGlobalWorkspaceExtensibleMCMC.GenericLocalWorkspaceExtensibleMCMC.GenericMCMCBackendExtensibleMCMC.GlobalWorkspaceExtensibleMCMC.HaarioTypeAdaptationExtensibleMCMC.ImproperPosPriorExtensibleMCMC.ImproperPriorExtensibleMCMC.LocalWorkspaceExtensibleMCMC.MCMCExtensibleMCMC.MCMCBackendExtensibleMCMC.MCMCConjugateParamUpdateExtensibleMCMC.MCMCConjugateUpdateExtensibleMCMC.MCMCGradientBasedUpdateExtensibleMCMC.MCMCImputationExtensibleMCMC.MCMCParamUpdateExtensibleMCMC.MCMCScheduleExtensibleMCMC.MCMCUpdateExtensibleMCMC.MCMCUpdateDecoratorExtensibleMCMC.NoAdaptationExtensibleMCMC.PriorExtensibleMCMC.ProductPriorExtensibleMCMC.REPLCallbackExtensibleMCMC.RandomWalkExtensibleMCMC.RandomWalkUpdateExtensibleMCMC.SavingCallbackExtensibleMCMC.StandardGlobalSubworkspaceExtensibleMCMC.StandardLocalSubworkspaceExtensibleMCMC.StandardPriorExtensibleMCMC.TransitionKernelExtensibleMCMC.UniformRandomWalkExtensibleMCMC.WorkspaceBase.:==Base.iterateBase.randDataStructures.reset!Distributions.logpdfDistributions.logpdfDistributions.logpdfExtensibleMCMC._AdaptationUnifRWExtensibleMCMC._AdaptationUnifRWExtensibleMCMC._AdaptationUnifRWExtensibleMCMC.__run!ExtensibleMCMC._adpt_rw_fill_defaultsExtensibleMCMC._adpt_rw_fill_defaultsExtensibleMCMC._adpt_rw_fill_defaultsExtensibleMCMC._adpt_rw_fill_defaultsExtensibleMCMC._assure_scalarExtensibleMCMC._upgrade_to_svecExtensibleMCMC._upgrade_to_vecExtensibleMCMC.accept_reject!ExtensibleMCMC.acceptance_rateExtensibleMCMC.acceptance_rate!ExtensibleMCMC.acceptedExtensibleMCMC.check_if_executeExtensibleMCMC.check_if_executeExtensibleMCMC.cleanup!ExtensibleMCMC.cleanup!ExtensibleMCMC.compute_gradients_and_momenta!ExtensibleMCMC.compute_ll!ExtensibleMCMC.compute_δExtensibleMCMC.compute_ϵExtensibleMCMC.coordsExtensibleMCMC.create_workspaceExtensibleMCMC.create_workspacesExtensibleMCMC.custom_zeroExtensibleMCMC.data_to_csvExtensibleMCMC.estim_covExtensibleMCMC.estim_meanExtensibleMCMC.execute!ExtensibleMCMC.execute!ExtensibleMCMC.find_available_nameExtensibleMCMC.find_starting_idxExtensibleMCMC.get_decoratorsExtensibleMCMC.init!ExtensibleMCMC.init!ExtensibleMCMC.init!ExtensibleMCMC.init_global_workspaceExtensibleMCMC.init_global_workspaceExtensibleMCMC.isdecoratorExtensibleMCMC.isequal_exceptExtensibleMCMC.llExtensibleMCMC.llExtensibleMCMC.llrExtensibleMCMC.ll°ExtensibleMCMC.ll°ExtensibleMCMC.log_priorExtensibleMCMC.log_priorExtensibleMCMC.log_priorExtensibleMCMC.log_transition_densityExtensibleMCMC.log_transition_densityExtensibleMCMC.log_transition_densityExtensibleMCMC.logitExtensibleMCMC.name_of_updateExtensibleMCMC.num_mcmc_stepsExtensibleMCMC.num_updtExtensibleMCMC.proposal!ExtensibleMCMC.readjust!ExtensibleMCMC.register!ExtensibleMCMC.register_accept_reject_results!ExtensibleMCMC.register_accept_reject_results!ExtensibleMCMC.remove_curlyExtensibleMCMC.reschedule!ExtensibleMCMC.run!ExtensibleMCMC.run!ExtensibleMCMC.set_accepted!ExtensibleMCMC.set_parameters!ExtensibleMCMC.set_parameters!ExtensibleMCMC.set_proposal!ExtensibleMCMC.sigmoidExtensibleMCMC.stateExtensibleMCMC.stateExtensibleMCMC.stateExtensibleMCMC.stateExtensibleMCMC.state°ExtensibleMCMC.state°ExtensibleMCMC.strip_decoratorsExtensibleMCMC.subidxExtensibleMCMC.time_to_updateExtensibleMCMC.transitionExtensibleMCMC.update!ExtensibleMCMC.update_workspaces!StatsBase.loglikelihoodStatsBase.loglikelihood
ExtensibleMCMC.AdaptationUnifRW — MethodAdaptationUnifRW(θ::K; kwargs...) where KDefine an adaptation scheme for a random walker that does updates on the parameter of shape and type θ. The following named parameters can be specified
Arguments
adapt_every_k_steps=100: number of steps based on which adaptation happenstarget_accpt_rate=0.234: acceptance rate of MH step that is to be targettedscale=1.0: scaling of the adaptationmin=1e-12: minimum allowable (half)-range of the uniform samplermax=1e7: maximum allowable (half)-range of the unifor sampleroffset=1e2: number of adaptation steps after which the shrinking of adaptive steps is supposed to start.
ExtensibleMCMC.GenericChainStats — Typemutable struct GenericChainStats{T} <: ChainStats
rolling_ar::Vector{Vector{Float64}}
roll_window::Int64
mean::Vector{T}
cov::Matrix{T}
N::Int64
endSimple online statistics for the Markov chain.
ExtensibleMCMC.GenericMCMCBackend — TypeGenericMCMCBackend <: MCMCBackendA flag that no specific backend is passed.
ExtensibleMCMC.NoAdaptation — TypeNoAdaptationA struct-flag for indicating that no adaptation is to be done.
ExtensibleMCMC.get_decorators — Methodget_decorators(updt_and_decor)Retrieve all decorators from a list
ExtensibleMCMC.isdecorator — Methodisdecorator(u)Returns true if u is a subtype of decorators.
ExtensibleMCMC.run! — Functionrun!(
mcmc::MCMC, num_mcmc_steps, data, θinit, callbacks=Callback[];
kwargs...
)The main calling function of this package that initializes, runs and outputs the results of an MCMC sampler for discretely observed stochastic processes.
Arguments
mcmc::MCMC: specifies a sequence of updates that constitute a single MCMC step and provides additional info about the MCMC backend algorithm to be usednum_mcmc_steps: the total number of MCMC stepsdata: completely characterizes everything that is known about the observations (including everything known about the underlying dynamics and the way it was collected),θinit: an initial guess for the unknown parameterscallbacks: a collection of extra utility functions that do extra work around MCMC sampling.exclude_updates: a standard named argument which lists the update indices and corresponding ranges of MCMC iterations at which given updates are supposed to be omitted.kwargs...: additional named arguments, passed onto initializers of global workspace; they depend on the chosenMCMCBackend
ExtensibleMCMC.Adaptation — TypeSupertype for all adaptation schemes.
ExtensibleMCMC.MCMCConjugateParamUpdate — TypeMCMCConjugateParamUpdate <: MCMCParamUpdateSupertype of all conjugate updates that update parameters and for which sampling can be done directly, without resorting to a Metropolis-Hastings algorithm
ExtensibleMCMC.MCMCConjugateUpdate — TypeMCMCConjugateUpdate <: MCMCUpdateSupertype of all conjugate updates, for which sampling can be done directly, without resorting to a Metropolis-Hastings algorithm
ExtensibleMCMC.MCMCGradientBasedUpdate — TypeMCMCGradientBasedUpdate <: MCMCParamUpdateSupertype of all updates that require local gradient information to perform update of state.
ExtensibleMCMC.MCMCImputation — TypeMCMCImputation <: MCMCUpdateSupertype of all updates that do not make any changes to the main parameter state in GlobalWorkspace, but instead, perform sampling on any auxiliary variables that are not of direct interest to the MCMC chain.
ExtensibleMCMC.MCMCParamUpdate — TypeMCMCParamUpdate <: MCMCUpdateSupertype of all updates that make changes to the main MCMC parameter called state in the GlobalWorkspace.
ExtensibleMCMC.MCMCUpdate — TypeSupertype of all MCMC updates
ExtensibleMCMC.MCMCUpdateDecorator — TypeSupertype of all decorators to update schemes. In this context, we use the word decorator to refer to any additional information that needs to be conveyed to the MCMC sampler that is not directly extractable from the update-objects themselves (for instance, a change in the delimitation of blocks that is made in-between updates).
ExtensibleMCMC.RandomWalk — TypeRandomWalk <: TransitionKernelSupertype for all random walkers.
ExtensibleMCMC.TransitionKernel — TypeSupertype of all transition kernels that perform updates on the main state of the global workspace. Conceptually, these are used by subtypes of MCMCParamUpdate to perform actual sampling and instances of types inheriting from TransitionKernel are usually member objects of the instances inheriting from MCMCParamUpdate.
Base.:== — MethodBase.:(==)(a::AdaptationUnifRW{T}, b::AdaptationUnifRW{S}) where{T,S}Convenience comparison of AdaptationUnifRW instances. Used only for tests.
Base.iterate — FunctionBase.iterate(iter::MCMCSchedule, state=iter.start)Iterate through the MCMCSchedule, outputting the named tuples (mcmciter=..., pidx=...) along the way, indicating the current index of the mcmc sampler (mcmciter), as well as the index of update that is to be performed.
Base.rand — MethodBase.rand(rw::UniformRandomWalk, θ)Sample a new state for a random walker rw that is currently in a state θ.
DataStructures.reset! — Methodreset!(adpt::AdaptationUnifRW)Reset the number of proposals and accepted samples to zero.
Distributions.logpdf — MethodDistributions.logpdf(rw::UniformRandomWalk, θ, θ°)Evaluate the log-probability density function for a move of a random walker from θ to θ°.
Distributions.logpdf — Methodlogpdf(::Prior, θ)Evaluate the log-probability density function at θ for a given prior.
ExtensibleMCMC._AdaptationUnifRW — Method_AdaptationUnifRW(
::Any, ::Val{:scalar}, ::Val{N}, trgt_ar, steps; kwargs...
) where NInternal constructor of AdaptationUnifRW, populating entries with scalars.
ExtensibleMCMC._AdaptationUnifRW — Method_AdaptationUnifRW(
::Val{false}, ::Val{:nonscalar}, v::Val{N}, trgt_ar, steps; kwargs...
) where NInternal constructor of AdaptationUnifRW, populating entries with SVectors.
ExtensibleMCMC._AdaptationUnifRW — Method_AdaptationUnifRW(
::Val{true}, ::Val{:nonscalar}, ::Val{N}, trgt_ar, steps; kwargs...
) where NInternal constructor of AdaptationUnifRW, populating entries with vectors.
ExtensibleMCMC.__run! — Method__run!(global_ws, local_wss, updates, schedule, callbacks)Internal loops that run the (already initialized) MCMC sampler. global_ws and local_wss are the already initialized global workspace and local workspaces (one for each update) respectively. schedule is the iterator over MCMC steps and callbacks is a list of callbacks.
ExtensibleMCMC._adpt_rw_fill_defaults — Method_adpt_rw_fill_defaults(N; kwargs...)Return a vector with set vector parameters, falling back on default values if necessary.
ExtensibleMCMC._adpt_rw_fill_defaults — Method_adpt_rw_fill_defaults(f::Function)Return a vector with set parameters, setting them according to the "recipe" f, falling back on default values if necessary.
ExtensibleMCMC._adpt_rw_fill_defaults — Method_adpt_rw_fill_defaults(; kwargs...)Return a vector with set scalar parameters, falling back on default values if necessary.
ExtensibleMCMC._adpt_rw_fill_defaults — Method_adpt_rw_fill_defaults(N; kwargs...)Return a vector with set SVector parameters, falling back on default values if necessary.
ExtensibleMCMC._assure_scalar — Method_assure_scalar(v)Accept a scalar or a vector of length one and return it as a scalar. Raise assertion error if other objects are passed.
ExtensibleMCMC._upgrade_to_svec — Method_upgrade_to_svec(v, ::Val{N}) where NReceive a scalar or a vector of length 1 and return a length N static vector of repeats of entry v.
ExtensibleMCMC._upgrade_to_vec — Method_upgrade_to_vec(v, N)Receive a scalar or a vector of length 1 and return a length N vector of repeats of entry v.
ExtensibleMCMC.accept_reject! — Functionaccept_reject!(updt, global_ws, ws, step, i=1)Finish computations of the log-likelihood ratio between the target and proposal in MH acceptance probability and accept/reject respectively.
ExtensibleMCMC.acceptance_rate! — Methodacceptance_rate!(adpt::AdaptationUnifRW)Destructive computation of a current acceptance rate that also resets the number of proposals and accepted samples to zeros.
ExtensibleMCMC.acceptance_rate — Methodacceptance_rate(adpt::AdaptationUnifRW)Compute current acceptance rate of the Metropolis-Hastings update step
ExtensibleMCMC.check_if_execute — Methodcheck_if_execute(callback::SavingCallback, iter)Return true if the mcmc iteration iter is one at which an intermediate save is to be made.
ExtensibleMCMC.cleanup! — Methodcleanup!(callback::SavingCallback, ws::GlobalWorkspace, iter)Save the entire MCMC chain, history of proposals, acceptance history etc.
ExtensibleMCMC.compute_ll! — Methodcompute_ll!(
global_ws::GlobalWorkspace,
ws::LocalWorkspace,
step,
)Evaluate the proposal log-likelihood at the observations.
ExtensibleMCMC.compute_δ — Methodcompute_δ(p, mcmc_iter)δ decreases roughly proportional to scale/sqrt(iteration)
ExtensibleMCMC.compute_ϵ — Functioncompute_ϵ(ϵ_old, p, a_r, δ, flip=1.0, f=identity, finv=identity)ϵ is moved by δ to adapt to target acceptance rate
ExtensibleMCMC.custom_zero — Methodcustom_zero(x::T, ::Type{elT}) where {T,elT}Create a zero with eltype elT, that is of the same structure as the collection x.
Examples
julia> custom_zero(3.0, Bool)
false
julia> custom_zero([3.0, 4.0], Bool)
2-element Array{Bool,1}:
0
0
julia> custom_zero(SVector{2}(1, 2), ComplexF64)
2-element SArray{Tuple{2},Complex{Float64},1,2} with indices SOneTo(2):
0.0 + 0.0im
0.0 + 0.0imExtensibleMCMC.data_to_csv — Methoddata_to_csv(f, ws::GlobalWorkspace, i)Write data entries to a CSV file.
ExtensibleMCMC.execute! — Methodexecute!(sc::SavingCallback, ws::GlobalWorkspace, iter)Save the chain of accepted states, proposed states and acceptance history to the disk.
ExtensibleMCMC.find_available_name — Functionfind_available_name(path, filename, disambig_num, extension=".csv")Check if a chosen filename already exists, if so, then tries appending consecutive numbers to the end of the file until the first one that is not used yet is found.
ExtensibleMCMC.find_starting_idx — Methodfind_starting_idx(callback::SavingCallback, iter)Find the last index for which saving was done.
ExtensibleMCMC.init! — Functioninit!(
mcmc::MCMC,
num_mcmc_steps,
data,
θinit,
exclude_updates=[];
kwargs...
)Initialize the schedule and the global workspace of the MCMC sampler for a given set of updates (already saved in mcmc.updates), a total number of MCMC iterations given by num_mcmc_steps, observed dataset data. θinit is the initial value of the main parameter that the MCMC sampling is done for, exclude_updates lists the update indices and the repspective ranges of mcmc iterations from which these updates are supposed to be omitted from and kwargs lists all additional named arguments passed for creating a global workspace.
ExtensibleMCMC.init! — Methodinit!(callback::SavingCallback)Create a CSV file for writing into.
ExtensibleMCMC.init_global_workspace — Methodinit_global_workspace(
::MCMCBackend,
num_mcmc_steps,
updates::Vector{<:MCMCUpdate},
data,
θinit::Vector{T};
kwargs...
) where TInitialize the <custom>GlobalWorkspace. <custom>MCMCBackend points to which GlobalWorkspace constructors to use, updates is a list of MCMC updates, θinit is the initial guess for the parameter and kwargs are the named arguments passed to run!.
ExtensibleMCMC.isequal_except — Methodisequal_except(
::AdaptationUnifRW{T}, b::AdaptationUnifRW{S}, args...
) where{T,S}Convenience comparison of AdaptationUnifRW instances. Used only for tests. The fields specified by args are excluded from comparison.
ExtensibleMCMC.log_prior — Methodlog_prior(::Previous, updt::MCMCParamUpdate, ws::LocalWorkspace, i)Evaluate the log-prior at θ.
ExtensibleMCMC.log_prior — Methodlog_prior(::Proposal, updt::MCMCParamUpdate, ws::LocalWorkspace, i)Evaluate the log-prior at θ°.
ExtensibleMCMC.log_transition_density — Methodlog_transition_density(
::Previous, updt::MCMCParamUpdate, ws::LocalWorkspace, i
)Evaluate the log-density for a transition θ → θ°.
ExtensibleMCMC.log_transition_density — Methodlog_transition_density(
::Proposal, updt::MCMCParamUpdate, ws::LocalWorkspace, i
)Evaluate the log-density for a transition θ° → θ.
ExtensibleMCMC.logit — Functionlogit(x, a=1.0)Logit function. (Inverse of sigmoid).
ExtensibleMCMC.readjust! — Methodreadjust!(rw::UniformRandomWalk, adpt::AdaptationUnifRW, mcmc_iter)Adaptive readjustment of the range for sampling uniforms by the random walker.
ExtensibleMCMC.register! — Methodregister!(adpt::AdaptationUnifRW, accepted::Bool, ::Any)Register the result of the acceptance decision in the Metropolis-Hastings step.
ExtensibleMCMC.register_accept_reject_results! — Functionregister_accept_reject_results!(
accepted::Bool, updt, ws::LocalWorkspace, step, i=1
)Register the results of accept/reject step relevant to a local workspace.
ExtensibleMCMC.register_accept_reject_results! — Functionregister_accept_reject_results!(
accepted::Bool,
updt,
global_ws::GlobalWorkspace,
local_ws::LocalWorkspace,
step,
i=1
)Register the result of accept/reject step.
ExtensibleMCMC.remove_curly — Methodremove_curly(::Type{K}) where KUtility function that removes all type-specifiers listed in the curly brackets.
Examples
julia> remove_curly(Array{Float64,1})
ArrayExtensibleMCMC.reschedule! — Functionreschedule!(
schedule::MCMCSchedule,
num_new_updates=0,
idxes_to_remove=[],
idxes_to_add=[]
)Make changes to the schedule (possibly in the midst of iterating through it). Add num_new_updtes-many allowable updates that can be performed at each MCMC step, idxes_to_remove lists all parameter udpates that are to be completely removed from the MCMC sampler, idxes_to_add lists entries that are to be added to schedule.exclude_updates.
ExtensibleMCMC.set_proposal! — Methodset_proposal!(
updt::MCMCParamUpdate,
global_ws::GlobalWorkspace,
ws::LocalWorkspace,
step
)The proposal parameter θ° has been sampled by this point. This function propagates it through workspaces and sets the new parameter in proposal law P°
ExtensibleMCMC.sigmoid — Functionsigmoid(x, a=1.0)Sigmoid function. (Inverse of logit).
ExtensibleMCMC.state — Methodstate(ws::GlobalWorkspace, updt::MCMCParamUpdate)Return a substate of a gloabl state consisting of coordinates that the updt is concerned with.
ExtensibleMCMC.strip_decorators — Methodstrip_decorators(updt_and_decor)Remove all decorators from a list
ExtensibleMCMC.time_to_update — Methodtime_to_update(adpt::AdaptationUnifRW)Return true if it's the time to update the ϵ parameter of Uniform random walks
ExtensibleMCMC.transition — Methodtransition(schedule::MCMCSchedule, state)Determine the next state of the MCMCSchedule iterator, by skipping through all updates that are to be excluded, as per schedule.exclude_updates.
ExtensibleMCMC.update! — Methodupdate!(
updt::MCMCParamUpdate,
global_ws::GlobalWorkspace,
ws::LocalWorkspace,
step,
)General recipe for performing parameter update (doing an update of the main state of the MCMC sampler).
ExtensibleMCMC.update_workspaces! — Methodupdate_workspaces!(
local_updt::MCMCParamUpdate,
global_ws::GlobalWorkspace,
local_ws::LocalWorkspace,
step,
prev_ws,
)Transfer all the information that is needed at the time of starting the MCMC update step from the global (or a previously used local) to the currently used local workspace.