R/tree_influ_phylm.R
tree_influ_phylm.Rd
Performs leave-one-out deletion analysis for phylogenetic linear regression, and detects influential species while evaluating uncertainty in trees topology.
tree_influ_phylm( formula, data, phy, n.tree = 2, cutoff = 2, model = "lambda", track = TRUE, ... )
formula | The model formula |
---|---|
data | Data frame containing species traits with row names matching tips
in |
phy | A phylogeny (class 'phylo') matching |
n.tree | Number of times to repeat the analysis with n different trees picked randomly in the multiPhylo file. |
cutoff | The cutoff value used to identify for influential species (see Details) |
model | The phylogenetic model to use (see Details). Default is |
track | Print a report tracking function progress (default = TRUE) |
... | Further arguments to be passed to |
The function influ_phylm
returns a list with the following
components:
cutoff
: The value selected for cutoff
formula
: The formula
full.model.estimates
: Coefficients, aic and the optimised
value of the phylogenetic parameter (e.g. lambda
) for the full model
without deleted species.
influential_species
: List of influential species, both
based on standardised difference in intercept and in the slope of the
regression. Species are ordered from most influential to less influential and
only include species with a standardised difference > cutoff
.
sensi.estimates
: A data frame with all simulation
estimates. Each row represents a deleted clade for a given random tree. Columns report the calculated
regression intercept (intercept
), difference between simulation
intercept and full model intercept (DIFintercept
), the standardised
difference (sDIFintercept
), 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.
data
: Original full dataset.
errors
: Species where deletion resulted in errors.
This function sequentially removes one species at a time, fits a phylogenetic
linear regression model using phylolm
, stores the
results and detects influential species. It repeats this operation using n trees,
randomly picked in a multiPhylo file.
All phylogenetic models from phylolm
can be used, i.e. BM
,
OUfixedRoot
, OUrandomRoot
, lambda
, kappa
,
delta
, EB
and trend
. See ?phylolm
for details.
influ_phylm
detects influential species based on the standardised
difference in intercept and/or slope when removing a given species compared
to the full model including all species. Species with a standardised difference
above the value of cutoff
are identified as influential. The default
value for the cutoff is 2 standardised differences change.
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
.
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
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.
if (FALSE) { # Load data: data(alien) # run analysis: tree_influ <- tree_influ_phylm(log(gestaLen) ~ log(adultMass), phy = alien$phy, data = alien$data, n.tree = 5) # To check summary results: summary(tree_influ) # Visual diagnostics sensi_plot(tree_influ) sensi_plot(tree_influ, graphs = 1) sensi_plot(tree_influ, graphs = 2) data(alien) tree_influ <- tree_influ_phylm(log(gestaLen) ~ log(adultMass), phy = alien$phy, data = alien$data[1:25, ], n.tree = 2) summary(tree_influ) }