Model

The Model type is designed to store the set of all model nodes, including parameter set \Theta. In particular, it stores Dependent type objects in its nodes dictionary field. Valid models are ones whose nodes form directed acyclic graphs (DAGs). Sampling functions $\{f_j\}_{j=1}^{B}$ are saved as Sampler objects in the vector of field samplers. Vector elements j=1,\ldots,B correspond to sampling blocks $\{\Theta_j\}_{j=1}^{B}$.

Dependent

MCPhylo.LogicalType
Logical(f::Function, monitor::Union{Bool, Vector{Int}}=true)

Constructor for a Logical model node. This function assumes the output of the logical operation to be a scalar.

  • f: Function specifying the deterministic operation performed on its arguments. These arguments are other nodes of the model.

  • monitor : Indicates whether the results should be monitored, i.e.saved.

source
Logical(d::Integer, f::Function, monitor::Union{Bool, Vector{Int}}=true)

Constructor for a Logical model node.

  • d : Specifies the dimension of the output.

  • f : Specifies the deterministic operation performed on its arguments. These arguments are other nodes of the model.

  • monitor : Indicates whether the results should be monitored, i.e.saved.

source
Logical(d::T, f::Function, monitor::Union{Bool, Vector{Int}}=true) where T<:GeneralNode

Constructor for a Logical model node, which can hold a Node structure, i.e. a tree.

  • f is a function specifying the deterministic operation performed on its arguments. These arguments are other nodes of the model.

  • monitor indicates whether the results should be monitored, i.e. saved.

source
MCPhylo.StochasticType
Stochastic(f::Function, monitor::Union{Bool, Vector{Int}}=true)

Constructor for a Stochastic model node. This function assumes the output of the logical operation to be scalar.

  • f : Specifies the distributional relationship between the arguments and the node. These arguments are other nodes of the model.

  • monitor : Indicates whether the results should be monitored, i.e. saved.

source
Stochastic(d::N, f::Function, monitor::Union{Bool, Vector{Int}}=true) where N<:GeneralNode

Constructor for a Stochastic model node, which can hold a Node structure, i.e. a tree.

  • f : Specifies the distributional reslationship between the arguments and the node.

These arguments are other nodes of the model.

  • monitor : Indicates whether the results should be monitored, i.e. saved.
source

Graph

MCPhylo.drawFunction
draw(m::Model; filename::AbstractString="")

Draw a GraphViz DOT-formatted graph representation of model nodes and their relationships.

The model drawn to an external file or standard output. Stochastic, logical, and input nodes will be represented by ellipses, diamonds, and rectangles, respectively. Nodes that are unmonitored in MCMC simulations will be gray-colored.

  • m : model for which to construct a graph.

  • filename : external file to which to save the resulting graph, or an empty string to draw to standard output (default). If a supplied external file name does not include a dot (.), the file extension .dot will be appended automatically.

source
MCPhylo.graph2dotFunction
graph2dot(m::Model)

Draw a GraphViz DOT-formatted graph representation of model nodes and their relationships.

A character string representation of the graph suitable for in-line processing. Stochastic, logical, and input nodes will be represented by ellipses, diamonds, and rectangles, respectively. Nodes that are unmonitored in MCMC simulations will be gray-colored.

  • m : model for which to construct a graph.
source

Initialization

MCPhylo.SimulationParametersMethod
SimulationParameters(; burnin::Int64=0, thin::Int64=1, chains::Int64=1,
                     verbose::Bool=true, trees::Bool=false,
                     asdsf::Bool=false, freq::Int64=50,
                     min_splits::Float64=0.1)::SimulationParameters

Construct a SimulationParameters object that defines the simulation parameters for a MCMC simulation.

Returns a SimulationParameters type object.

  • burnin: controls how many trees are discarded before saving

  • thin: controls thinning of saved trees

  • chains: controls how many chains there are

  • verbose: controls if sampler output is printed to the console

  • trees: controls if trees should be created during simulation

  • asdsf: controls if ASDSF should be calculated

  • freq: controls at which interval trees are used for ASDSF

  • min_splits: controls the default minimal splits threshold

source
MCPhylo.setinits!Method
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
MCPhylo.setinputs!Method
setinputs!(m::Model, inputs::Dict{Symbol})

Set the values of input model nodes.

  • m : model with input nodes to be assigned.

  • inputs : values for input model nodes. Dictionary keys and values should be given for each input node.

Returns the model with values assigned to input nodes.

source
MCPhylo.setsamplers!Method
function setsamplers!(m::Model, samplers::Vector{V} where V<:Sampler)

Set the samplers for the Stocastic nodes of a given Model.

Returns the Model with updated samplers.

  • m : Model to update.

  • samplers : block-specific sampelrs.

source

MCMC

MCPhylo.mcmcFunction
mcmc(mc::ModelChains, iters::Integer; verbose::Bool=true, trees::Bool=false)

This function simulates additional draws from a model.

  • mc is the results of a previous call to the mcmc function.

  • iters indicates the number of draws to simulate.

  • verbose controls whether to print progress statements to the console.

  • trees indicates if the states of the model nodes describing tree structures should be stored as well.

source
mcmc(m::Model, inputs::Dict{Symbol},
          inits::Vector{V} where V<:Dict{Symbol},
          iters::Integer; burnin::Integer=0, thin::Integer=1,
          chains::Integer=1, verbose::Bool=true, trees::Bool=false,
          params::SimulationParameters=SimulationParameters())

Simulate MCMC draws from the model m.

  • inputs is a dictionary storing the values for input model nodes. Dictionary keys and values should be given for each input node.

  • inits contains dictionaries with initial values for stochastic model nodes. Dictionary keys and values should be given for each stochastic node. Consecutive runs of the simulator will iterate through the vector’s dictionary elements.

  • iter Specifies the number of draws to generate for each simulation run

  • burnin specifies the number of initial draws to discard as a burn-in sequence to allow for convergence.

  • thin is the step-size between draws to store in the output.

  • chains specifies the number of simulation runs to perform.

  • verbose indicates whether the sampler progress should be printed at the console.

  • trees indicates if the states of the model nodes describing tree structures should be stored as well.

  • params pass one Struct to set all simulation parameters, instead of setting each individually

source

Model Building

MCPhylo.ModelType
Model(; iter::Integer=0, burnin::Integer=0,
  samplers::Vector{Sampler}=Sampler[], nodes...)

Construct a Model object that defines a model for MCMC simulation.

Returns a Model type object.

  • iter: current iteration of the MCMC simulation.

  • burnin: number of initial draws to be discarded as a burn-in sequence to allow for convergence.

  • samplers: block-specific sampling functions.

  • nodes...: arbitrary number of user-specified arguments defining logical and stochastic nodes in the model. Argument values must be Logical or Stochastic type objects. Their names in the model will be taken from the argument names.

source