Performs analyses of sensitivity to species sampling by randomly removing species and detecting the effects on parameter estimates in a phylogenetic linear regression.

samp_phylm(
  formula,
  data,
  phy,
  n.sim = 30,
  breaks = seq(0.1, 0.5, 0.1),
  model = "lambda",
  track = TRUE,
  ...
)

Arguments

formula

The model formula

data

Data frame containing species traits with row names matching tips in phy.

phy

A phylogeny (class 'phylo') matching data.

n.sim

The number of times species are randomly deleted for each break.

breaks

A vector containing the percentages of species to remove.

model

The phylogenetic model to use (see Details). Default is lambda.

track

Print a report tracking function progress (default = TRUE)

...

Further arguments to be passed to phylolm

Value

The function samp_phylm returns a list with the following components:

formula: The formula

full.model.estimates: Coefficients, aic and the optimised value of the phylogenetic parameter (e.g. lambda or kappa) for the full model without deleted species.

sensi.estimates: A data frame with all simulation estimates. Each row represents a model rerun with a given number of species n.remov removed, representing n.percent of the full dataset. Columns report the calculated regression intercept (intercept), difference between simulation intercept and full model intercept (DIFintercept), the percentage of change in intercept compared to the full model (intercept.perc) and intercept p-value (pval.intercept). All these parameters are also reported for the regression slope (DIFestimate etc.). Additionally, model aic value (AIC) and the optimised value (optpar) of the phylogenetic parameter (e.g. kappa or lambda, depending on the phylogenetic model used) are reported. Lastly we reported the standardised difference in intercept (sDIFintercept) and slope (sDIFestimate).

sign.analysis For each break (i.e. each percentage of species removed) this reports the percentage of statistically significant (at p<0.05) intercepts (perc.sign.intercept) over all repetitions as well as the percentage of statisticaly significant (at p<0.05) slopes (perc.sign.estimate).

data: Original full dataset. #' @note Please be aware that dropping species may reduce power to detect significant slopes/intercepts and may partially be responsible for a potential effect of species removal on p-values. Please also consult standardised differences in the (summary) output.

Details

This function randomly removes a given percentage of species (controlled by breaks) from the full phylogenetic linear regression, fits a phylogenetic linear regression model without these species using phylolm, repeats this many times (controlled by n.sim), stores the results and calculates the effects on model parameters.

All phylogenetic models from phylolm can be used, i.e. BM, OUfixedRoot, OUrandomRoot, lambda, kappa, delta, EB and trend. See ?phylolm for details.

Currently, this function can only implement simple linear models (i.e. \(trait~ predictor\)). In the future we will implement more complex models.

Output can be visualised using sensi_plot.

References

Paterno, G. B., Penone, C. Werner, G. D. A. sensiPhy: An r-package for sensitivity analysis in phylogenetic comparative methods. Methods in Ecology and Evolution 2018, 9(6):1461-1467.

Werner, G.D.A., Cornwell, W.K., Sprent, J.I., Kattge, J. & Kiers, E.T. (2014). A single evolutionary innovation drives the deep evolution of symbiotic N2-fixation in angiosperms. Nature Communications, 5, 4087.

Ho, L. S. T. and Ane, C. 2014. "A linear-time algorithm for Gaussian and non-Gaussian trait evolution models". Systematic Biology 63(3):397-408.

See also

Examples

# Load data: data(alien) # Run analysis: samp <- samp_phylm(log(gestaLen) ~ log(adultMass), phy = alien$phy[[1]], data = alien$data, n.sim = 10)
#> Warning: NA's in response or predictor, rows with NA's were removed
#> Warning: Some phylo tips do not match species in data (this can be due to NA removal) species were dropped from phylogeny or data
#> Used dataset has 84 species that match data and phylogeny
#> | | | 0% | |= | 2% | |=== | 4% | |==== | 6% | |====== | 8% | |======= | 10% | |======== | 12% | |========== | 14% | |=========== | 16% | |============= | 18% | |============== | 20% | |=============== | 22% | |================= | 24% | |================== | 26% | |==================== | 28% | |===================== | 30% | |====================== | 32% | |======================== | 34% | |========================= | 36% | |=========================== | 38% | |============================ | 40% | |============================= | 42% | |=============================== | 44% | |================================ | 46% | |================================== | 48% | |=================================== | 50% | |==================================== | 52% | |====================================== | 54% | |======================================= | 56% | |========================================= | 58% | |========================================== | 60% | |=========================================== | 62% | |============================================= | 64% | |============================================== | 66% | |================================================ | 68% | |================================================= | 70% | |================================================== | 72% | |==================================================== | 74% | |===================================================== | 76% | |======================================================= | 78% | |======================================================== | 80% | |========================================================= | 82% | |=========================================================== | 84% | |============================================================ | 86% | |============================================================== | 88% | |=============================================================== | 90% | |================================================================ | 92% | |================================================================== | 94% | |=================================================================== | 96% | |===================================================================== | 98% | |======================================================================| 100%
summary(samp)
#> 50 simulations saved, see output$sensi.estimates to acess all simulations
#> % Species Removed % Significant Intercepts Mean Intercept Change (%) #> 1 10 100 1.81 #> 2 20 100 5.01 #> 3 30 100 5.36 #> 4 40 100 7.63 #> 5 50 100 8.57 #> Mean sDIFintercept % Significant Estimates Mean Estimate Change (%) #> 1 -0.02571011 100 2.26 #> 2 0.40459768 100 6.35 #> 3 -0.71321138 100 12.64 #> 4 -0.83524452 100 18.99 #> 5 -0.95153795 100 22.60 #> Mean sDIFestimate #> 1 0.081904449 #> 2 -0.002248192 #> 3 0.863252886 #> 4 1.221987717 #> 5 1.537153137
head(samp$sensi.estimates)
#> n.remov n.percent intercept DIFintercept intercept.perc pval.intercept #> 1 8 10 2.368728 0.006503047 0.3 1.246049e-10 #> 2 8 10 2.371091 0.008865261 0.4 1.820402e-09 #> 3 8 10 2.364645 0.002419851 0.1 1.483657e-09 #> 4 8 10 2.374281 0.012055730 0.5 3.507355e-09 #> 5 8 10 2.268748 -0.093477636 4.0 2.935996e-09 #> 6 8 10 2.382500 0.020274238 0.9 1.821140e-10 #> estimate DIFestimate estimate.perc pval.estimate AIC optpar #> 1 0.1488133 1.313016e-03 0.9 4.907265e-10 -0.6344393 1 #> 2 0.1475543 5.403549e-05 0.0 2.247742e-09 6.3778524 1 #> 3 0.1458786 -1.621691e-03 1.1 9.051909e-09 9.0806434 1 #> 4 0.1481210 6.206649e-04 0.4 1.087773e-08 16.8854815 1 #> 5 0.1509530 3.452662e-03 2.3 3.133312e-10 2.4746960 1 #> 6 0.1419103 -5.590028e-03 3.8 1.448714e-09 5.9198516 1 #> sDIFintercept sDIFestimate #> 1 0.03739404 0.061360513 #> 2 0.05097732 0.002525213 #> 3 0.01391471 -0.075785651 #> 4 0.06932326 0.029005219 #> 5 -0.53751824 0.161351530 #> 6 0.11658161 -0.261235959
# Visual diagnostics if (FALSE) { sensi_plot(samp) # You can specify which graph and parameter ("estimate" or "intercept") to print: sensi_plot(samp, graphs = 1, param = "estimate") sensi_plot(samp, graphs = 2, param = "intercept") }