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.
DAMOCLES_ML(
phy = rcoal(10),
pa = matrix(c(phy$tip.label,sample(c(0,1),Ntip(phy),replace = T)),
nrow = Ntip(phy),ncol = 2),
initparsopt = c(0.1,0.1),
idparsopt = 1:length(initparsopt),
parsfix = 0,
idparsfix = (1:3)[-idparsopt],
pars2 = c(1E-3,1E-4,1E-5,1000),
pchoice = 0
)phylogeny in phylo format
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.
The initial values of the parameters that must be optimized
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)
The values of the parameters that should not be optimized. See 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.
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
sets which p-value to optimize (default 0) pchoice == 0 correspond to the sum of p_0f + p_1f pchoice == 1 correspond to p_0f pchoice == 2 correspond to p_1f
gives the maximum likelihood estimate of mu
gives the maximum likelihood estimate of gamma_0
gives the maximum likelihood estimate of gamma_1
gives the maximum loglikelihood
gives the number of estimated parameters, i.e. degrees of feedom
gives a message on convergence of optimization; conv = 0 means convergence
The output is a dataframe containing estimated parameters and maximum loglikelihood.
Pigot, A.L. & R.S. Etienne (2015). A new dynamic null model for phylogenetic community structure. Ecology Letters 18: 153-163.
# NOT RUN {
data(NWPrimates_data)
out = DAMOCLES_ML(
phy = NWPrimates_data[[1]],
pa = NWPrimates_data[[2]],
initparsopt = c(0.01,1.8),
idparsopt = c(1,2),
parsfix = c(0),
idparsfix = c(3),
pars2 = c(1E-3,1E-4,1E-5,1000),
pchoice = 0)
# }
Run the code above in your browser using DataLab