Skip to contents

This function computes the maximum likelihood estimates of the parameters of the DAMOCLES model for a given phylogeny and presence-absence data. It also outputs the corresponding loglikelihood that can be used in model comparisons.

Usage

DAMOCLES_ML(
  phy,
  pa,
  initparsopt,
  idparsopt = 1:length(initparsopt),
  parsfix = NULL,
  idparsfix = NULL,
  idparsequal = NULL,
  pars2 = c(0.001, 1e-04, 1e-05, 1000),
  optimmethod = "simplex",
  pchoice = 0,
  edgeTList = NULL,
  methode = "analytical",
  model = 0,
  num_cycles = 1,
  verbose = FALSE,
  cond = 0
)

Arguments

phy

phylogeny in phylo format

pa

presence-absence table.
The first column contains the labels of the species (corresponding to the tip labels in the phylogeny.
The second column contains the presence (1) or absence (0) of species in the local community.

initparsopt

The initial values of the parameters that must be optimized

idparsopt

The ids of the parameters that must be optimized, e.g. 1:2 for extinction rate, and offset of immigration rate The ids are defined as follows:
id == 1 corresponds to mu (extinction rate)
id == 2 corresponds to gamma_0 (offset of immigration rate)
id == 3 corresponds to gamma_1 (parameter controlling decline in immigration rate with time)

parsfix

The values of the parameters that should not be optimized. See idparsfix.

idparsfix

The ids of the parameters that should not be optimized, e.g. c(1,3) if mu and gamma_1 should not be optimized, but only gamma_0. In that case idparsopt must be c(2). The default is to fix all parameters not specified in idparsopt.

idparsequal

The ids of the parameters that should be set equal to the first parameter of the same type.

pars2

Vector of settings:
pars2[1] sets the relative tolerance in the parameters

pars2[2] sets the relative tolerance in the function

pars2[3] sets the absolute tolerance in the parameters

pars2[4] sets the maximum number of iterations

optimmethod

Method used in optimization of the likelihood. Current default is 'subplex'. Alternative is 'simplex' (default of previous version)

pchoice

sets the p-value to optimize:
pchoice == 0 corresponds to the sum of p_0f + p_1f
pchoice == 1 corresponds to p_0f
pchoice == 2 corresponds to p_1f

edgeTList

list of edge lengths that need to be succesively pruned; if not specified, it will computed using compute_edgeTList

methode

method used to solve the ODE. Either 'analytical' for the analytical solution, 'Matrix' for matrix exponentiation using package Matrix or 'expm' using package 'expm' or any of the numerical solvers, used in deSolve.

model

model used. Default is 0 (standard null model). Other options are 1 (binary traits) 2 (trinary environmental trait) or 3 (diversity-dependent colonization - beta version)

num_cycles

the number of cycles of opimization. If set at Inf, it will do as many cycles as needed to meet the tolerance set for the target function.

verbose

Whether intermediate output should be printed. Default is FALSE.

cond

Whether likelihood should be conditioned on non-empty community. Default is no conditioning.

Value

mu

gives the maximum likelihood estimate of mu

gamma_0

gives the maximum likelihood estimate of gamma_0

gamma_1

gives the maximum likelihood estimate of gamma_1

loglik

gives the maximum loglikelihood

df

gives the number of estimated parameters, i.e. degrees of feedom

conv

gives a message on convergence of optimization; conv = 0 means convergence

Details

The output is a dataframe containing estimated parameters and maximum loglikelihood.

References

Pigot, A.L. & R.S. Etienne (2015). A new dynamic null model for phylogenetic community structure. Ecology Letters 18: 153-163.

Author

Rampal S. Etienne