Description Usage Arguments Details Value Note Author(s) References See Also Examples
View source: R/intra_samp_phyglm.R
Performs analyses of sensitivity to species sampling by randomly removing species and detecting the effects on parameter estimates in a phylogenetic logistic regression, while taking into account potential interactions with intraspecific variability.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
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
|
n.intra |
Number of datasets resimulated taking into account intraspecific variation (see: |
breaks |
A vector containing the percentages of species to remove. |
btol |
Bound on searching space. For details see |
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 |
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 |
x.transf |
Transformation for the predictor variable (e.g. |
track |
Print a report tracking function progress (default = TRUE) |
... |
Further arguments to be passed to |
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 phylolm
,
repeats this many times (controlled by n.sim
), stores the results and
calculates the effects on model parameters.
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
evaluates the effects of sampling within that iteration.
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 logistic models (i.e. trait~ predictor). In the future we will implement more complex models.
Output can be visualised using sensi_plot
.
The function samp_phyglm
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.
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.
Gustavo Paterno, Gijsbert D.A. Werner & Caterina Penone
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.
phylolm
, samp_phyglm
,
intra_phyglm
,intra_samp_phylm
,
sensi_plot
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | ## Not run:
set.seed(6987)
phy = rtree(100)
x = rTrait(n=1,phy=phy,parameters=list(ancestral.state=2,optimal.value=2,sigma2=1,alpha=1))
X = cbind(rep(1,100),x)
y = rbinTrait(n=1,phy=phy, beta=c(-1,0.5), alpha=.7 ,X=X)
z = rnorm(n = length(x),mean = mean(x),sd = 0.1*mean(x))
dat = data.frame(y, x, z)
#Run sensitivity analysis:
intra_samp <- intra_samp_phyglm(formula = y ~ x, data = dat, phy = phy,
n.sim=10, n.intra = 3,
breaks=seq(.1,.5,.1),
Vx = "z", distrib="normal", x.transf=NULL)
summary(intra_samp)
sensi_plot(intra_samp)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.