Phylogenetic community structure hypothesis test
DAMOCLES_bootstrap.RdThis function computes the maximum likelihood estimates of colonisation and local extinction rate for a given phylogeny and presence-absence data under the DAMOCLES model. These rate estimates are used to simulate null communities under the DAMOCLES model. Standardized effect size of mean nearest taxon distance (mntd), mean phylogentic distance (mpd) and loglikelihood are calculated For comparison, standardised effect sizes are also calculated relative to a "Random-Draw" null model i.e. presence absence randomised across tips
Usage
DAMOCLES_bootstrap(
phy = ape::rcoal(10),
pa = matrix(c(phy$tip.label, sample(c(0, 1), ape::Ntip(phy), replace = T)), nrow =
ape::Ntip(phy), ncol = 2),
initparsopt = c(0.1, 0.1),
idparsopt = 1:length(initparsopt),
parsfix = NULL,
idparsfix = NULL,
pars2 = c(0.001, 1e-04, 1e-05, 1000),
pchoice = 0,
runs = 999,
estimate_pars = FALSE,
conf.int = 0.95
)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)- 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) if mu should not be optimized, but only gamma_0. In that case idparsopt must be c(2). The default is to fix the parameters not specified in idparsopt.
- pars2
Vector of settings:
pars2[1]sets the relative tolerance in the parameterspars2[2]sets the relative tolerance in the functionpars2[3]sets the absolute tolerance in the parameterspars2[4]sets the maximum number of iterations- pchoice
sets which p-value to optimize and with which root state to simulate (default pchoice = 0)
pchoice == 0 correspond to optimizing sum of p_0f + p_1f, and simulating with an equal number of root states being 0 or 1
pchoice == 1 correspond to optimizing p_0f, and simulating with root state being 0
pchoice == 2 correspond to optimizing p_1f, and simulating with root state being 1- runs
the number null communities to generate.
- estimate_pars
Whether to estimate parameters on the simulated datasets (default = FALSE).
- conf.int
The width of the conifdence intervals calculated on bootstrapped parameter estimates
Value
- summary_table
mugives the maximum likelihood estimate of mu and confidence intervals in brackets if estimate_pars = TRUEgamma_0gives the maximum likelihood estimate of gamma_0 and confidence intervals in brackets if bootstrap=TRUEloglikgives the maximum loglikelihooddfgives the number of estimated parameters, i.e. degrees of feedomconvgives a message on convergence of optimization; conv = 0 means convergencen.obsgives the number of species locally present in the observed communitymntd.obsgives the MNTD of the observed communitympd.obsgives the MPD of the observed communityrunsgives the number of null communities simulatedmntd.mean.RDmean of MNTD from null communities generated by a "Random Draw" modelmntd.sd.RDstandard deviation of MNTD from null communities generated by a "Random Draw" modelmntd.obs.z.RDstandardized effect size of MNTD compared to null communities generated by a "Random Draw" model (= -1*(mntd.obs - mntd.mean.RD)/ mntd.sd.RD)mntd.obs.rank.RDrank of observed MNTD compared to null communities generated by a "Random Draw" modelmntd.obs.q.RDquantile of observed MNTD vs. null communities (= mntd.obs.rank.RD /runs + 1)mpd.mean.RDmean of MPD from null communities generated by a "Random Draw" modelmpd.sd.RDstandard deviation of MPD from null communities generated by a "Random Draw" modelmpd.obs.z.RDstandardized effect size of MPD compared to null communities generated by a "Random Draw" model (= -1*(mpd.obs - mpd.mean.RD)/ mpd.sd.RD)mpd.obs.rank.RDrank of observed MPD compared to null communities generated by a "Random Draw" modelmpd.obs.q.RDquantile of observed MPD vs. null communities (= mpd.obs.rank.RD /runs + 1)n.mean.DAMOCLESmean number of species locally present in the null communities generated by DAMOCLESmntd.mean.DAMOCLESmean of MNTD from null communities generated by DAMOCLESmntd.sd.DAMOCLESstandard deviation of MNTD from null communities generated by DAMOCLESmntd.obs.z.DAMOCLESstandardized effect size of MNTD compared to null communities generated by DAMOCLES (= -1*(mntd.obs - mntd.mean.DAMOCLES)/ mntd.sd.DAMOCLES)mntd.obs.rank.DAMOCLESrank of observed MNTD compared to null communities generated by DAMOCLESmntd.obs.q.DAMOCLESquantile of observed MNTD vs. null communities (= mntd.obs.rank.DAMOCLES /runs + 1)mpd.mean.DAMOCLESmean of MPD from null communities generated by DAMOCLESmpd.sd.DAMOCLESstandard deviation of MPD from null communities generated by DAMOCLESmpd.obs.z.DAMOCLESstandardized effect size of MPD compared to null communities generated by DAMOCLES (= -1*(mpd.obs - mpd.mean.DAMOCLES)/ mpd.sd.DAMOCLES)mpd.obs.rank.DAMOCLESrank of observed MPD compared to null communities generated by DAMOCLESmpd.obs.q.DAMOCLESquantile of observed MPD vs. null communities (= mpd.obs.rank.DAMOCLES /runs + 1)loglik.mean.DAMOCLESmean of loglikelihoods from null communities generated by DAMOCLESloglik.sd.DAMOCLESstandard deviation of loglikelihoods from null communities generated by DAMOCLESloglik.obs.z.DAMOCLESstandardized effect size of loglikelihood compared to null communities generated by DAMOCLES (= -1*(loglik.obs - loglik.mean.DAMOCLES)/ loglik.sd.DAMOCLES)loglik.obs.rank.DAMOCLESrank of observed loglikelihood compared to null communities generated by DAMOCLESloglik.obs.q.DAMOCLESquantile of observed loglikelihoods vs. null communities (= loglik.obs.rank.DAMOCLES /runs + 1)- null_community_data
rungives the simulation runroot.state.printgives the state of the ancestral species in the local community assumed in the simulation, i.e. present (1) or absent (0)ngives the number of species locally present in the observed communityn.RDgives the number of species locally present in the null community generated by a "Random Draw" modelmntd.RDgives the MNTD of the null community generated by a "Random Draw" modelmpd.RDgives the MPD of the null community generated by a "Random Draw" modeln.DAMOCLESgives the number of species locally present in the null community generated by DAMOCLESmntd.DAMOCLESgives the MNTD of the null community generated by DAMOCLESmpd.DAMOCLESgives the MPD of the null community generated by DAMOCLESloglik.DAMOCLESgives the maximum loglikelihood for the null community generated by DAMOCLESmu.DAMOCLESgives the maximum likelihood estimate of mu for the null community generated by DAMOCLESgamma_0.DAMOCLESgives the maximum likelihood estimate of gamma_0 for the null community generated by DAMOCLES
Details
The output is a list of two dataframes. The first dataframe, summary_table, contains the summary results. The second dataframe, null_community_data, contains decsriptive statistics for each null community.
References
Pigot, A.L. & R.S. Etienne (2015). A new dynamic null model for phylogenetic community structure. Ecology Letters 18: 153-163.