For Developers

On this page you can finde more detailed, developer oriented documentation on internal functions which are not necessarily exported to the main API.

MCPhylo.setinits!Function
setinits!(m::Model, inits::Dict{Symbol})

Set the initial values of stochastic model nodes.

Returns the model with stochastic nodes initialized and the iter field set equal to 0.

  • m : model with nodes to be initialized.

  • inits : initial values for stochastic model nodes. Dictionary keys and values should be given for each stochastic node.

source
setinits!(m::Model, inits::Vector{V} where V<:Dict{Symbol})
source
MCPhylo.setmonitor!Function
setmonitor!(d::AbstractDependent, monitor::Bool)

Specify node elements to be included in monitored MCMC sampler output.

Returns d with its monitor field updated to reflect the specified monitoring.

  • d : node whose elements contain sampled MCMC values.

  • monitor : boolean indicating whether all elements are monitored.

source
setmonitor!(d::AbstractDependent, monitor::Vector{Int})

Specify node elements to be included in monitored MCMC sampler output.

Returns d with its monitor field updated to reflect the specified monitoring.

  • d : node whose elements contain sampled MCMC values.

  • monitor : vector of element-wise indices of elements to monitor.

source
setmonitor!(d::TreeVariate, monitor::Bool)

Specify node elements to be included in monitored MCMC sampler output.

Returns d with its monitor field updated to reflect the specified monitoring.

  • d : node whose elements contain sampled MCMC values.

  • monitor : boolean indicating whether all elements are monitored.

source
setmonitor!(d::TreeVariate, monitor::Vector{Int})

Specify node elements to be included in monitored MCMC sampler output.

Returns d with its monitor field updated to reflect the specified monitoring.

  • d : node whose elements contain sampled MCMC values.

  • monitor : vector of element-wise indices of elements to monitor.

source
MCPhylo.update!Function
update!(l::AbstractLogical, m::Model)

Update the values of a logical node according to its relationship with others in a model.

Returns the node with its values updated.

  • l : logical node to update.

  • m : model containing the node.

source
update!(s::AbstractStochastic, m::Model)

Update the values of a stochastic node according to its relationship with others in a model.

Returns the node with its values updated.

  • s : stochastic node to update.

  • m : model containing the node.

source
update!(m::Model, block::Integer=0)
source
update!(m::Model, nodekeys::Vector{Symbol})

Update values of logical and stochastic model node according to their relationship with others in a model.

Returns the model with updated nodes.

  • m : mode with nodes to be updated.

  • block : sampling block of nodes to be updated (default: all blocks).

  • nodekeys : nodes to be updated in the given order.

source
Base.keysFunction
Base.keys(m::Model, ntype::Symbol, at...)

Extract the symbols (keys) for all existing nodes or for nodes of a specified type.

  • m : model containing the nodes of interest.

  • ntype : type of nodes to return. Options are

    • :all : all input, logical, and stochastic model nodes.

    • :assigned : nodes that have been assigned values.

    • :block : stochastic nodes being updated by the sampling block(s) at::Integer=0 (default: all blocks).

    • :dependent : logical and stochastic (dependent) nodes in topologically sorted order.

    • :independent or :input : input (independent) nodes.

    • :logical : logical nodes.

    • :monitor : stochastic nodes being monitored in MCMC sampler output.

    • :output : stochastic nodes upon which no other stochastic nodes depend.

    • :source : nodes upon which the node at::Symbol or vector of nodes at::Vector{Symbol} depends.

    • :stochastic : stochastic nodes.

    • :target : topologically sorted nodes that depend on the sampling block(s) at::Integer=0 (default: all blocks), node at::Symbol , or vector of nodes at::Vector{Symbol} .

  • at... : additional positional arguments to be passed to the ntype options, as described above.

source
Base.keys(c::AbstractChains)

Returns names of parameter elements.

  • c : Chain to return names of.
source
Base.showFunction
Base.show(io::IO, m::Model)

Write a text representation of the model, nodes, and attributes to the current output stream.

source
Base.show(io::IO, c::AbstractChains)

Prints header and values of Chain.

  • io : IO stream on which to print.

  • AbstractChains : Chain to print.

source
MCPhylo.showallFunction
showall(io::IO, m::Model)

Write a verbose text representation of the model, nodes, and attributes to the current output stream.

source

Simulation

MCPhylo.gettuneFunction
gettune(m::Model, block::Integer)
source
gettune(m::Model)

Get block-sampler tuning parameters.

Returns a Vector{Any} of all block-specific tuning parameters without block input, and turning parameters for the specified block otherwise.

source
MCPhylo.settune!Function
settune!(m::Model, tune, block::Integer)
source
settune!(m::Model, tune::Vector{Any})

Set tuning parameters for one or all blocks.

Assigns desired tune values to model.

  • m : model containing the nodes of interest.

  • tune : tune values to be assigned to models; if no block value is input, tune must be a Vector with length equal to m.samplers.

  • block : Integer denoting which block's tune value is to be reassigned.

source
Distributions.gradlogpdfFunction
gradlogpdf(m::Model, block::Integer=0, transform::Bool=false;
                dtype::Symbol=:forward)
source
gradlogpdf(m::Model, targets::Array{Symbol, 1})::Tuple{Float64, Array{Float64}}

Compute the gradient of log-densities for stochastic nodes.

Returns the resulting gradient vector. Method gradlogpdf!() additionally updates model m with supplied values x.

  • m : model containing the stochastic nodes for which to compute the gradient.

  • block : sampling block of stochastic nodes for which to compute the gradient (default: all stochastic nodes).

  • x: value (possibly different than the current one) at which to compute the gradient.

  • transform: whether to compute the gradient of block parameters on the link–transformed scale.

  • dtype : type of differentiation for gradient calculations. Options are

    • :central : central differencing.

    • :forward : forward differencing.

source
MCPhylo.gradlogpdf!Function
gradlogpdf!(m::Model, x::AbstractVector{T}, block::Integer=0,
                  transform::Bool=false; dtype::Symbol=:forward) where {T<:Real}
source
gradlogpdf!(m::Model, x::AbstractArray{T}, block::Integer=0,transform::Bool=false)
 where T<:GeneralNode
source
gradlogpdf!(m::Model, x::N, block::Integer=0,transform::Bool=false)::Tuple{Float64, Vector{Float64}}
    where N<:GeneralNode

Returns the resulting gradient vector. Method gradlogpdf!() additionally updates model m with supplied values x.

source
Distributions.logpdfFunction
logpdf(m::Model, block::Integer=0, transform::Bool=false)
source
logpdf(m::Model, nodekeys::Vector{Symbol}, transform::Bool=false)

Compute the sum of log-densities for stochastic nodes.

Returns the resulting numeric value of summed log-densities.

  • m: model containing the stochastic nodes for which to evaluate log-densities.

  • block : sampling block of stochastic nodes over which to sum densities (default: all stochastic nodes).

  • nodekeys : nodes over which to sum densities.

  • x : value (possibly different than the current one) at which to evaluate densities.

  • transform : whether to evaluate evaluate log-densities of block parameters on the link–transformed scale.

source
logpdf(m::Model, x::AbstractArray{T}, block::Integer=0,
        transform::Bool=false) where {T<:Real}
source
logpdf(mc::ModelChains, f::Function, nodekeys::Vector{Symbol})

Compute the sum of log-densities at each iteration of MCMC output for stochastic nodes.

Returns a ModelChains object of resulting summed log-densities at each MCMC iteration of the supplied chain.

  • mc : sampler output from a model fit with the mcmc()` function.

  • nodekey/nodekeys : stochastic model node(s) over which to sum densities (default: all).

  • f : ??

source
logpdf(mc::ModelChains,
       nodekeys::Vector{Symbol}=keys(mc.model, :stochastic))
source
Missing docstring.

Missing docstring for MCPhylo.sample!(::Main.MCPhylo.Model, ::Integer). Check Documenter's build log for details.

MCPhylo.unlistFunction
unlist(m::Model, block::Integer=0, transform::Bool=false)
source
unlist(m::Model, monitoronly::Bool)
source
unlist(m::Model, nodekeys::Vector{Symbol}, transform::Bool=false)

Convert (unlist) sets of logical and/or stochastic node values to vectors.

Returns vectors of concatenated node values.

  • m : model containing nodes to be unlisted or relisted.

  • block : sampling block of nodes to be listed (default: all blocks).

  • nodekeys : node(s) to be listed.

  • transform : whether to apply a link transformation in the conversion.

source
MCPhylo.relistFunction
relist(m::Model, x::AbstractArray{T}, block::Integer=0,
        transform::Bool=false) where {T<:Real}
source
relist(m::Model, x::AbstractArray{T}, block::Integer=0,
        transform::Bool=false) where {T<:GeneralNode}
source
relist(m::Model, x::AbstractArray{T},
        nodekeys::Vector{Symbol}, transform::Bool=false) where {T<:Any}
source
relist(m::Model, x::N, nodekeys::Vector{Symbol}, transform::Bool=false) where N<:GeneralNode

Reverse of unlist; ie. Converts vectors to sets of logical and/or stochastic node values. Same inputs and return values as unlist.

source
MCPhylo.relist!Function
relist!(m::Model, x::AbstractArray{T}, block::Integer=0,
          transform::Bool=false) where {T<:Any}
source
relist!(m::Model, x::AbstractArray{T}, nodekey::Symbol,
              transform::Bool=false) where {T<:Real}

Reverse of unlist; ie. Converts vectors to sets of logical and/or stochastic node values. Same inputs as unlist.

Returns m, with values copied to the nodes.

source
Missing docstring.

Missing docstring for MCPhylo.update!. Check Documenter's build log for details.

StatsBase.sample!Function
sample!(m::Model, block::Integer=0)

Generate one MCMC sample of values for a specified model.

Returns the model updated with the MCMC sample and, in the case of block=0, the iter field incremented by 1.

  • m : model specification.

  • block : block for which to sample values (default: all blocks).

source
sample!(v::HMCVariate, logfgrad::Function)

Draw one sample from a target distribution using the HMC sampler. Parameters are assumed to be continuous and unconstrained.

Returns v updated with simulated values and associated tuning parameters.

source
sample!(v::NUTSVariate, logfgrad::Function; adapt::Bool=false)

Draw one sample from a target distribution using the NUTS sampler. Parameters are assumed to be continuous and unconstrained.

Returns v updated with simulated values and associated tuning parameters.

source
sample!(v::RWMVariate, logf::Function, moves::Array{Symbol})

Propose a new tree by randomly performing a move from the ones specified in moves.

Returns v updated with simulated values and associated tuning parameters.

source
sample!(v::RWMVariate, logf::Function)

Draw one sample from a target distribution using the RWM sampler. Parameters are assumed to be continuous and unconstrained.

Returns v updated with simulated values and associated tuning parameters.

source
sample!(v::SliceSimplexVariate, logf::Function)

Draw one sample from a target distribution using the SliceSimplex sampler. Parameters are assumed to be continuous and constrained to a simplex.

Returns v updated with simulated values and associated tuning parameters.

source
MCPhylo.SamplerType
Sampler(params::Vector{Symbol}, f::Function, tune::Any=Dict())

Construct a Sampler object that defines a sampling function for a block of stochastic nodes.

Returns a Sampler{typeof(tune)} type object.

  • params: node(s) being block-updated by the sampler.

  • f: function for the eval field of the constructed sampler and whose arguments are the other model nodes upon which the sampler depends, typed argument model::Model that contains all model nodes, and/or typed argument block::Integer that is an index identifying the corresponding sampling function in a vector of all samplers for the associated model. Through the arguments, all model nodes and fields can be accessed in the body of the function. The function may return an updated sample for the nodes identified in its params field. Such a return value can be a structure of the same type as the node if the block consists of only one node, or a dictionary of node structures with keys equal to the block node symbols if one or more. Alternatively, a value of nothing may be returned. Return values that are not nothing will be used to automatically update the node values and propagate them to dependent nodes. No automatic updating will be done if nothing is returned.

  • tune: tuning parameters needed by the sampling function.

source
Base.getindexFunction
Base.getindex(c::Chains, window, names, chains)

Subset MCMC sampler output. The syntax c[i, j, k] is converted to getindex(c, i, j, k).

Subsetted sampler output stored in the same type of object as that supplied in the call.

  • c : sampler output to subset.

  • window : indices of the form start:stop or start:thin:stop can be used to subset iterations, where start and stop define a range for the subset and thin will apply additional thinning to existing sampler output.

  • names : indices for subsetting of parameters that can be specified as strings, integers, or booleans identifying parameters to be kept. ModelChains may additionally be indexed by model node symbols.

  • chains : indices for chains can be integers or booleans.

A value of : can be specified for any of the dimensions to indicate no subsetting.

source
Base.setindex!Function
Base.setindex!(c::AbstractChains, value, iters, names, chains)

Store MCMC sampler output at a given index. The syntax c[i, j, k] = value is converted to setindex!(c, value, i, j, k).

Returns an object of the same type as c with the sampler output stored in the specified indices.

  • c : object within which to store sampler output.

  • value : sampler output.

  • iters : iterations can be indexed as a start:stop or start:thin:stop range, a single numeric index, or a vector of indices; and are taken to be relative to the index range store in the c.range field.

  • names : indices for subsetting of parameters can be specified as strings, integers, or booleans.

  • chains : indices for chains can be integers or booleans.

A value of : can be specified for any of the dimensions to indicate no subsetting.

source
Base.catFunction
Base.cat(c1::AbstractChains, args::AbstractChains...; dims::Integer)

Concatenate input MCMC chains along a specified dimension. For dimensions other than the specified one, all input chains must have the same sizes, which will also be the sizes of the output chain. The size of the output chain along the specified dimension will be the sum of the sizes of the input chains in that dimension. vcat concatenates vertically along dimension 1, and has the alternative syntax [chain1; chain2; ...]. hcat concatenates horizontally along dimension 2, and has the alternative syntax [chain1 chain2 ...].

Returns a Chains object containing the concatenated input.

  • dim : dimension (1, 2, or 3) along which to concatenate the input chains.

  • c1, args... : Chains to concatenate.

source
Base.keysMethod
Base.keys(c::AbstractChains)

Returns names of parameter elements.

  • c : Chain to return names of.
source
Base.showMethod
Base.show(io::IO, c::AbstractChains)

Prints header and values of Chain.

  • io : IO stream on which to print.

  • AbstractChains : Chain to print.

source
Base.sizeFunction
Base.size(c::AbstractChains)

Returns Tuple containing last iteration of MCMC sampler output and dimensions of Chain dimensions of c.value.

  • c : Chain object of interest.
source
Base.size(c::AbstractChains, ind)

Returns last iteration of MCMC sampler output, or dimension derived from C, according to value of ind.

  • c : Chain object of interest.

  • ind : index of tuple to return; 1 returns last iteration of MCMC sampler output, 2 and 3 return dimensions of c.value.

source