View source: R/secsse_loglik.R
secsse_loglik | R Documentation |
Likelihood for SecSSE model Loglikelihood calculation for the SecSSE model given a set of parameters and data
secsse_loglik(
parameter,
phy,
traits,
num_concealed_states,
cond = "proper_cond",
root_state_weight = "proper_weights",
sampling_fraction,
setting_calculation = NULL,
see_ancestral_states = FALSE,
loglik_penalty = 0,
is_complete_tree = FALSE,
num_threads = 1,
atol = 1e-08,
rtol = 1e-07,
method = "odeint::bulirsch_stoer"
)
parameter |
list where first vector represents lambdas, the second mus and the third transition rates. |
phy |
phylogenetic tree of class |
traits |
vector with trait states for each tip in the phylogeny. The
order of the states must be the same as the tree tips. For help, see
|
num_concealed_states |
number of concealed states, generally equivalent to the number of examined states in the dataset. |
cond |
condition on the existence of a node root: |
root_state_weight |
the method to weigh the states:
|
sampling_fraction |
vector that states the sampling proportion per trait state. It must have as many elements as there are trait states. |
setting_calculation |
argument used internally to speed up calculation.
It should be left blank (default : |
see_ancestral_states |
Boolean for whether the ancestral states should
be shown? Defaults to |
loglik_penalty |
the size of the penalty for all parameters; default is 0 (no penalty). |
is_complete_tree |
logical specifying whether or not a tree with all its
extinct species is provided. If set to |
num_threads |
number of threads to be used. Default is one thread. |
atol |
A numeric specifying the absolute tolerance of integration. |
rtol |
A numeric specifying the relative tolerance of integration. |
method |
integration method used, available are:
|
The loglikelihood of the data given the parameter.
rm(list = ls(all = TRUE))
library(secsse)
set.seed(13)
phylotree <- ape::rcoal(31, tip.label = 1:31)
traits <- sample(c(0,1,2),ape::Ntip(phylotree),replace = TRUE)
num_concealed_states <- 2
cond <- "proper_cond"
root_state_weight <- "proper_weights"
sampling_fraction <- c(1,1,1)
drill <- id_paramPos(traits,num_concealed_states)
drill[[1]][] <- c(0.12,0.01,0.2,0.21,0.31,0.23)
drill[[2]][] <- 0
drill[[3]][,] <- 0.1
diag(drill[[3]]) <- NA
secsse_loglik(parameter = drill,
phylotree,
traits,
num_concealed_states,
cond,
root_state_weight,
sampling_fraction,
see_ancestral_states = FALSE)
#[1] -113.1018
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.