| Title: | Phylogeny-based Komogorov-Smirnov Importance Statistic |
|---|---|
| Description: | Package underlying Cornwell et al. 2014 J. Ecology. |
| Authors: | Tempo and Mode in Plant Trait Evolution Working Group |
| Maintainer: | Will Cornwell <[email protected]> |
| License: | GPL (>=2) |
| Version: | 0.1-3 |
| Built: | 2026-05-17 05:50:57 UTC |
| Source: | https://github.com/traitecoevo/ksi |
Converts a data.frame with named rows and a number of data columns
into a list of vectors, each of which is named with the rownames of
the data.frame, and omitting any missing values. This is the format
expected by ksi.
data.frame.to.vectors(dat)data.frame.to.vectors(dat)
dat |
A data.frame with named rows. |
Richard G. FitzJohn
This is the fitting function. The test works by sequentially fitting a series of (possibly nested) nodes and asking “Is the trait distribution for the clade descending from this node different to that of the nodes neighbourhood?”. The neighbourhood is defined as all the species that are in the 'partition' of the parent of the focal node that are
Not descended from that node
Not descended from a node that was identified in a previous
iteration (so, when fitting node , we exclude all species
descended from nodes )
This is basically the same algorithm as MEDUSA uses for fitting diversification rates that vary across a phylogeny.
ksi(tree, dat, depth=10, test=NULL, verbose=TRUE, multicore=FALSE, multicore.args=list())ksi(tree, dat, depth=10, test=NULL, verbose=TRUE, multicore=FALSE, multicore.args=list())
tree |
An phylogeny, of class |
dat |
A named vector of tip states. This can be numeric, a
factor (categorical) or logical ( |
depth |
The number of nested nodes to identify (integer from 1 to the number of nodes in the tree once all taxa that lack state information are removed). |
test |
Force a particular test to be used. Valid values are
If |
verbose |
Print a (fairly small) amount of progress information as the fits proceed. |
multicore |
Logical: if |
multicore.args |
Arguments to control the behaviour of
|
The ksi function returns an object of class ksi. This
is a list with one element per node, named with the names of the nodes
that were fit. Each list element contains the elements:
statisticValue of the statistic against which nodes are ranked (for the Kolmogorov-Smirnov test, this is D scaled by the relative sample sizes – see ?ks.test).
p.valueThe p-value from the test (often meaninglessly small on large trees or uneven partitions).
nA vector of length 2 with the number of species in the 'target' and 'neighbourhood' of the node, respectively.
In addition, the ksi object (obj, say) has a number of
attributes:
attr(obj, "tree")The phylogeny, after adding node labels and dropping species that have no trait data.
attr(obj, "dat")The data, altered to have the same contents and order as attr(obj, "tree")$tip.label.
attr(obj, "contents")A list with one element per
node. Each element is a list with elements neighbourhood,
target and other, containing the indices of the
species that were in each test. These are indices against
attr(obj, "dat") for now.
attr(obj, "statistics")A list with one element poer
node. Each element is a vector along the nodes (in ape index) with
the statistic for each node for that round. Nodes that were used
in previous rounds have a value of NA.
attr(obj, "test")Indicates which test (ks, chisq, gtest) was done.
...to write...
ksi.nodeset(obj, idx, alpha=1/20, node=NULL) ksi.group(obj, idx, alpha=1/20, include=1/5)ksi.nodeset(obj, idx, alpha=1/20, node=NULL) ksi.group(obj, idx, alpha=1/20, include=1/5)
obj |
Fitted |
idx |
Index of the node to search around (1, 2, etc). |
alpha |
The quantile to include when defining plausible sets;
|
include |
Rank up to this fraction of the nodes in the tree. |
node |
If non-NULL, centres the nodeset at a different node. |
...to write...
Vector of node names.
Richard G. FitzJohn