Performs Phylogenetic linear regression evaluating intraspecific variability in response and/or predictor variables.
intra_phylm( formula, data, phy, Vy = NULL, Vx = NULL, y.transf = NULL, x.transf = NULL, n.intra = 30, distrib = "normal", model = "lambda", track = TRUE, ... )
formula | The model formula: |
---|---|
data | Data frame containing species traits and species names as row names. |
phy | A phylogeny (class 'phylo', see ? |
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 |
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 |
y.transf | Transformation for the response variable (e.g. |
x.transf | Transformation for the predictor variable (e.g. |
n.intra | Number of times to repeat the analysis generating a random value for response and/or predictor variables.
If NULL, |
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 |
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 intra_phylm
returns a list with the following
components:
formula
: The formula
data
: Original full dataset
sensi.estimates
: Coefficients, aic and the optimised
value of the phylogenetic parameter (e.g. lambda
) for each regression.
N.obs
: Size of the dataset after matching it with tree tips and removing NA's.
stats
: Main statistics for model parameters.CI_low
and CI_high
are the lower
and upper limits of the 95
all.stats
: Complete statistics for model parameters. sd_intra
is the standard deviation
due to intraspecific variation. CI_low
and CI_high
are the lower and upper limits
of the 95
sp.pb
: Species that caused problems with data transformation (see details above).
This function fits a phylogenetic linear regression model using phylolm
.
The regression is repeated n.intra
times. At each iteration the function generates a random value
for each row in the dataset using the standard deviation or errors supplied and assuming a normal or uniform distribution.
To calculate means and se for your raw data, you can use the summarySE
function from the
package Rmisc
.
#' 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
.
When Vy or Vx exceed Y or X, respectively, negative (or null) values can be generated, this might cause problems
for data transformation (e.g. log-transformation). In these cases, the function will skip the simulation. This problem can
be solved by increasing n.intra
, changing the transformation type and/or checking the target species in output$sp.pb.
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
Martinez, P. a., Zurano, J.P., Amado, T.F., Penone, C., Betancur-R, R., Bidau, C.J. & Jacobina, U.P. (2015). Chromosomal diversity in tropical reef fishes is related to body size and depth range. Molecular Phylogenetics and Evolution, 93, 1-4
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.
# Load data: data(alien) # run PGLS accounting for intraspecific variation: intra <- intra_phylm(gestaLen ~ adultMass, y.transf = log, x.transf = log, phy = alien$phy[[1]], data = alien$data, Vy = "SD_gesta", n.intra = 30)#> 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#>#> | | | 0% | |== | 3% | |===== | 7% | |======= | 10% | |========= | 13% | |============ | 17% | |============== | 20% | |================ | 23% | |=================== | 27% | |===================== | 30% | |======================= | 33% | |========================== | 37% | |============================ | 40% | |============================== | 43% | |================================= | 47% | |=================================== | 50% | |===================================== | 53% | |======================================== | 57% | |========================================== | 60% | |============================================ | 63% | |=============================================== | 67% | |================================================= | 70% | |=================================================== | 73% | |====================================================== | 77% | |======================================================== | 80% | |========================================================== | 83% | |============================================================= | 87% | |=============================================================== | 90% | |================================================================= | 93% | |==================================================================== | 97% | |======================================================================| 100%#> mean CI_low CI_high #> intercept 2.242 2.199 2.285 #> se.intercept 0.367 0.358 0.375 #> pval.intercept 0.000 0.000 0.000 #> estimate 0.163 0.157 0.168 #> se.estimate 0.024 0.023 0.024 #> pval.estimate 0.000 0.000 0.000