EM_phylo: A montecarlo EM algorithm implementation to diversification...

Usage Arguments Examples

Usage

1
EM_phylo(wt, init_par, n_trees = 100, n_it = 30, printpar = TRUE, mu = NULL, impsam = FALSE, dummy = 0)

Arguments

wt

waiting times of the (extant only) phylogenetic tree

init_par

Initial parameters for the EM algorithm

n_trees

Number of trees to be samplead for the montecarlo algorithm at each EM iteration

n_it

Number of iterations for the EM algorithm (this should be replaced by a tolerance value and a stoping criteria)

printpar

if printpar=TRUE then the EM estimations will be printed at each iteration

mu

You can use this in case you do not want to estimate mu

impsam

if impsam=TRUE then an importance sampling approach will be used on the montecarlo sampling

dummy

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
##---- Should be DIRECTLY executable !! ----
##-- ==>  Define data, use random,
##--	or do  help(data=index)  for the standard data sets.

## The function is currently defined as
function (wt, init_par, n_trees = 100, n_it = 30, printpar = TRUE,
    mu = NULL, impsam = FALSE, dummy = 0)
{
    pars = init_par
    for (j in 1:n_it) {
        if (printpar)
            print(pars)
        trees <- sim_srt(wt = wt, pars = pars, parallel = F,
            n_trees = n_trees)
        if (length(init_par) == 3) {
            pars = subplex(par = c(8, 0.175, 0.9), fn = llik_st,
                setoftrees = trees, impsam = impsam)$par
        }
        else {
            pars = subplex(par = c(8, 0.175), mu2par = mu, fn = llik_st,
                setoftrees = trees, impsam = impsam)$par
        }
        pars[3] = pars[3] + dummy
    }
    return(pars)
  }

franciscorichter/dmea documentation built on May 16, 2019, 1:54 p.m.