# NOT RUN {
# Input a phylogeny
tree <- ape::read.tree(text = "(((t4:0.7293960718,(t1:0.450904974,t3:0.09259337652)
:0.04068535892):0.4769176776,t8:0.1541864066):0.7282000314,((t7:0.07264320855,
(((t5:0.8231869878,t6:0.3492440532):0.2380232813,t10:0.2367582193):0.5329497182,
t9:0.1016243151):0.5929288475):0.3003101915,t2:0.8320755605):0.2918686506);")
# Calculate the log likelihood under a constant birth-death model (i.e, no shifts)
# with full extant & extinct sampling
likelihood_MSBD(tree, shifts = c(), gamma = 0, lambdas = 10, mus = 1, sigma = 1)
# Calculate the log likelihood under a multi-states model with 2 states
# and full extant & extinct sampling
likelihood_MSBD(tree, shifts = matrix(c(2,1.8,2), nrow = 1),
gamma = 0.05, lambdas = c(10, 6), mus = c(1, 0.5), sigma = 1)
# Calculate the log likelihood under a multi-states model with 2 states and exponential decay
# with full extant & extinct sampling
likelihood_MSBD(tree, shifts = matrix(c(2,1.8,2), nrow = 1),
gamma = 0.05, lambdas = c(10, 6), mus = c(1, 0.5),
sigma = 1, stepsize = 0.01, lambda_rates = c(0.1, 0.1))
# }
Run the code above in your browser using DataLab