Estimate the impact on model estimates of phylogenetic linear regression after removing clades from the analysis, while taking into account potential interactions with intraspecific variability.

intra_clade_phylm(
  formula,
  data,
  phy,
  clade.col,
  n.species = 5,
  n.sim = 100,
  n.intra = 2,
  Vy = NULL,
  Vx = NULL,
  distrib = "normal",
  y.transf = NULL,
  x.transf = NULL,
  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.

clade.col

The column in the provided data frame which specifies the clades (a character vector with clade names).

n.species

Minimum number of species in a clade for the clade to be included in the leave-one-out deletion analysis. Default is 5.

n.sim

Number of simulations for the randomization test.

n.intra

Number of datasets resimulated taking into account intraspecific variation (see: "intra_phylm")

Vy

Name of the column containing the standard deviation or the standard error of the response variable. When information is not available for one taxon, the value can be 0 or NA.

Vx

Name of the column containing the standard deviation or the standard error of the predictor variable. When information is not available for one taxon, the value can be 0 or NA

distrib

A character string indicating which distribution to use to generate a random value for the response and/or predictor variables. Default is normal distribution: "normal" (function rnorm). Uniform distribution: "uniform" (runif) Warning: we recommend to use normal distribution with Vx or Vy = standard deviation of the mean.

y.transf

Transformation for the response variable (e.g. "log" or "sqrt"). Please use this argument instead of transforming data in the formula directly (see also details below).

x.transf

Transformation for the predictor variable (e.g. "log" or "sqrt"). Please use this argument instead of transforming data in the formula directly (see also details below).

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 intra_clade_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) for the full model without deleted species.

sensi.estimates: A data frame with all simulation estimates. Each row represents a deleted clade. 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.

null.dist: A data frame with estimates for the null distributions for all clades analysed.

data: Original full dataset.

errors: Clades and/or iterations where deletion resulted in errors.

Details

This function sequentially removes one clade at a time, fits a phylogenetic linear regression model using phylolm and stores the results. The impact of of a specific clade on model estimates is calculated by the comparison between the full model (with all species) and the model without the species belonging to a clade. This operation is repeated n.intra times for simulated values of the dataset, taking into account intraspecific variation. At each iteration, the function generates a random value for each row in the dataset using the standard deviation or errors supplied, and detect the influential species within that iteration.

Additionally, to account for the influence of the number of species on each clade (clade sample size), this function also estimates a null distribution expected for the number of species in a given clade. This is done by fitting models without the same number of species in the given clade. The number of simulations to be performed is set by 'n.sim'. To test if the clade influence differs from the null expectation for a clade of that size, a randomization test can be performed using 'summary(x)'.

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

clade_phylm detects influential clades based on difference in intercept and/or slope when removing a given clade compared to the full model including all species.

Currently, this function can only implement simple linear models (i.e. \(y = a + bx\)). 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.

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

if (FALSE) { #load data data(alien) intra_clade <- intra_clade_phylm(gestaLen ~ adultMass, phy = alien$phy[[1]], data = alien$data, clade.col = "family", n.sim = 30, n.intra = 5, y.transf = log, x.transf = log, Vy="SD_gesta") summary(intra_clade) sensi_plot(intra_clade) sensi_plot(intra_clade, clade = "Bovidae", graphs = 2) sensi_plot(intra_clade, clade = "Mustelidae", graphs = 2) } # \dontshow{ data(alien) intra_clade <- intra_clade_phylm(gestaLen ~ adultMass, phy = alien$phy[[1]], data = alien$data, clade.col = "family", n.sim = 1, n.intra = 1, y.transf = log, x.transf = log, Vy="SD_gesta")
#> Warning: distrib=normal: make sure that standard deviation is provided for Vx and/or Vy
#> 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% | |======================================================================| 100%
summary(intra_clade)
#> $Estimate #> clade.removed N.species estimate DIFestimate Change (%) Pval #> 1 Bovidae 15 0.1633700 -0.019586436 10.7 5.759268e-07 #> 4 Mustelidae 6 0.1999498 0.016993281 9.3 2.021307e-13 #> 3 Macropodidae 7 0.1934033 0.010446826 5.7 7.868967e-10 #> 2 Cervidae 12 0.1898529 0.006896379 3.8 3.667733e-09 #> m.null.estimate Pval.randomization Significant (%) #> 1 0.1802304 0 100 #> 4 0.1811273 0 100 #> 3 0.1806454 0 100 #> 2 0.1845538 0 100 #> #> $Intercept #> clade.removed N.species intercept DIFintercept Change (%) Pval #> 1 Bovidae 15 2.214727 0.15369957 7.5 5.759268e-07 #> 4 Mustelidae 6 1.926107 -0.13492086 6.5 2.021307e-13 #> 3 Macropodidae 7 1.981059 -0.07996840 3.9 7.868967e-10 #> 2 Cervidae 12 2.006580 -0.05444805 2.6 3.667733e-09 #> m.null.intercept Pval.randomization Significant (%) #> 1 2.110956 0 100 #> 4 2.089195 0 100 #> 3 2.049315 0 100 #> 2 2.079245 0 100 #>
# }