R/samp_phyglm.R
samp_phyglm.Rd
Performs analyses of sensitivity to species sampling by randomly removing species and detecting the effects on parameter estimates in phylogenetic logistic regression.
samp_phyglm( formula, data, phy, n.sim = 30, breaks = seq(0.1, 0.5, 0.1), btol = 50, 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.sim | The number of times species are randomly deleted for each
|
breaks | A vector containing the percentages of species to remove. |
btol | Bound on searching space. For details see |
track | Print a report tracking function progress (default = TRUE) |
... | Further arguments to be passed to |
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.
This function randomly removes a given percentage of species (controlled by
breaks
) from the full phylogenetic logistic regression, fits a phylogenetic
logistic regression model without these species using phyloglm
,
repeats this many times (controlled by n.sim
), stores the results and
calculates the effects on model parameters.
Only logistic regression using the "logistic_MPLE"-method from
phyloglm
is implemented.
Currently, this function can only implement simple logistic models (i.e. \(trait~ predictor\)). In the future we will implement more complex models.
Output can be visualised using sensi_plot
.
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.
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.
# Simulate Data: set.seed(6987) phy = rtree(100) x = rTrait(n=1,phy=phy) X = cbind(rep(1,100),x) y = rbinTrait(n=1,phy=phy, beta=c(-1,0.5), alpha=.7 ,X=X) dat = data.frame(y, x) # Run sensitivity analysis: samp <- samp_phyglm(y ~ x, data = dat, phy = phy, n.sim = 10)#>#> | | | 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%#>#> % Species Removed % Significant Intercepts Mean Intercept Change (%) #> 1 10 100 6.44 #> 2 20 100 8.07 #> 3 30 100 13.79 #> 4 40 100 20.58 #> 5 50 100 15.75 #> Mean sDIFintercept % Significant Estimates Mean Estimate Change (%) #> 1 -0.04537909 100 7.04 #> 2 0.07351624 100 9.04 #> 3 0.19030487 100 8.54 #> 4 -0.14821057 100 13.02 #> 5 -0.01570813 100 14.33 #> Mean sDIFestimate #> 1 0.02544364 #> 2 -0.19178080 #> 3 -0.19537254 #> 4 -0.29841826 #> 5 -0.54390569