| DriftTest | R Documentation |
Given a set of covariance matrices and means for terminals, test the hypothesis that observed divergence is larger/smaller than expected by drift alone using a regression of the between-group variances on the within-group eigenvalues.
DriftTest(
means,
cov.matrix,
show.plot = TRUE,
sample.sizes = NULL,
tol = NULL,
plot = TRUE
)
means |
list or array of species means being compared. array must have means in the rows. |
cov.matrix |
ancestral covariance matrix for all populations |
show.plot |
Logical. If TRUE, plot of eigenvalues of ancestral matrix by between group variance is showed. |
sample.sizes |
Optional vector with the number of individuals used to estimate each mean, in the same
order as |
tol |
Optional numeric. If supplied, axes whose ancestral matrix eigenvalue is below |
plot |
Logical. If FALSE the ggplot is not built and the |
Non-positive eigenvalues of cov.matrix (matrices that are not positive definite) have no
logarithm; the corresponding axes are excluded from the regression and a warning is issued. Use tol to
also exclude near-zero eigenvalues.
Means estimated from samples carry sampling variance proportional to the within-group matrix
(W/n), so when divergence among groups is small relative to W/n the between group variances are dominated
by sampling error and the slope tends to one regardless of the process that produced the divergence. If
sample.sizes is supplied, this expected sampling variance is subtracted. Axes whose corrected
variance is not positive (no detectable divergence beyond sampling error) are set to NA, excluded from the
regression, and reported with a warning. The corrected slope is a less attenuated estimate of the
scaling between divergence and within-group variation, but it is also noisier, so the test based on it is
not more powerful than the uncorrected test; it is most useful for estimating the slope and for checking
whether divergence along each axis exceeds sampling error. When sample.sizes is NULL (default) the
results are identical to previous versions.
list of results containing:
regression: the linear regression between the log of the eigenvalues of the ancestral matrix and the log of the between group variance (projected on the eigenvectors of the ancestral matrix)
coefficient_CI_95: confidence intervals for the regression coefficients
log.between_group_variance: log of the between group variance (projected on the ancestral matrix eigenvectors), corrected for sampling variance if sample.sizes is supplied (NA for axes with non-positive corrected variance)
log.W_eVals: log of the ancestral matrix eigenvalues
plot: plot of the regression using ggplot2
If the regression coefficient is significantly different to one, the null hypothesis of drift is rejected.
Ana Paula Assis, Diogo Melo
Marroig, G., and Cheverud, J. M. (2004). Did natural selection or genetic drift produce the cranial diversification of neotropical monkeys? The American Naturalist, 163(3), 417-428. doi:10.1086/381693
Proa, M., O'Higgins, P. and Monteiro, L. R. (2013), Type I error rates for testing genetic drift with phenotypic covariance matrices: A simulation study. Evolution, 67: 185-195. doi: 10.1111/j.1558-5646.2012.01746.x
#Input can be an array with means in each row or a list of mean vectors
means = array(rnorm(40*10), c(10, 40))
cov.matrix = RandomMatrix(40, 1, 1, 10)
DriftTest(means, cov.matrix)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.