Skip to content

Commit

Permalink
Allowing for adding approximate loglikelihood function
Browse files Browse the repository at this point in the history
  • Loading branch information
rsetienne committed Oct 23, 2024
1 parent 43e37e1 commit b5c2d9b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
8 changes: 7 additions & 1 deletion R/DAISIE_ML1.R
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ DAISIE_ML1 <- function(
island_ontogeny = NA,
jitter = 0,
num_cycles = 1,
function_to_optimize = DAISIE_loglik_all_choosepar) {
function_to_optimize = 'DAISIE_exact') {
# datalist = list of all data: branching times, status of clade, and numnber of missing species
# datalist[[,]][1] = list of branching times (positive, from present to past)
# - max(brts) = age of the island
Expand Down Expand Up @@ -157,6 +157,12 @@ DAISIE_ML1 <- function(
# . eqmodel = 4 : equilibrium is assumed on immigrants using deterministic equation for endemics and immigrants
# . eqmodel = 5 : equilibrium is assumed on endemics and immigrants using deterministic equation for endemics and immigrants

if(function_to_optimize == 'DAISIE_exact') {
function_to_optimize <- DAISIE_loglik_all_choosepar
} else
{
DAISIE_loglik_all_choosepar_approx
}

out2err <- data.frame(
lambda_c = NA,
Expand Down
6 changes: 4 additions & 2 deletions R/DAISIE_ML_CS.R
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,8 @@ DAISIE_ML_CS <- DAISIE_ML <- function(
verbose = 0,
tolint = c(1E-16, 1E-10),
jitter = 0,
num_cycles = 1) {
num_cycles = 1,
function_to_optimize = 'DAISIE_exact') {

if (datatype == "single") {
if (is.na(island_ontogeny)) {
Expand Down Expand Up @@ -229,7 +230,8 @@ DAISIE_ML_CS <- DAISIE_ML <- function(
verbose = verbose,
tolint = tolint,
jitter = jitter,
num_cycles = num_cycles)
num_cycles = num_cycles,
function_to_optimize = function_to_optimize)
}
} else {
stop(
Expand Down

0 comments on commit b5c2d9b

Please sign in to comment.