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.Logical
— TypeLogical(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.
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.
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.
MCPhylo.Stochastic
— TypeStochastic(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.
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.
Graph
MCPhylo.draw
— Functiondraw(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.
MCPhylo.graph2dot
— Functiongraph2dot(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.
Initialization
MCPhylo.SimulationParameters
— MethodSimulationParameters(; 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 savingthin
: controls thinning of saved treeschains
: controls how many chains there areverbose
: controls if sampler output is printed to the consoletrees
: controls if trees should be created during simulationasdsf
: controls if ASDSF should be calculatedfreq
: controls at which interval trees are used for ASDSFmin_splits
: controls the default minimal splits threshold
MCPhylo.setinits!
— Methodsetinits!(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.
MCPhylo.setinits!
— Methodsetinits!(m::Model, inits::Vector{V} where V<:Dict{Symbol})
MCPhylo.setinputs!
— Methodsetinputs!(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.
MCPhylo.setsamplers!
— Methodfunction 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.
MCMC
MCPhylo.mcmc
— Functionmcmc(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.
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 runburnin
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
Model Building
MCPhylo.Model
— TypeModel(; 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 beLogical
orStochastic
type objects. Their names in the model will be taken from the argument names.