## Indices K, Kstar and Kw of Phylogenetic Signal

### Description

The functions `K`, `Kstar` and `Kw` calculate Blomberg et al. (2003) statistics K, and K* and Pavoine and Ricotta (2013) statistic Kw, respectively. Then they perform a permutation test where species identities are maintained in the phylogeny while the trait values of species are randomly shuffled (permuted) (Pavoine and Ricotta 2013).

### Usage

```K(phyl, trait, nrep = 999, alter = c("greater", "less", "two-sided"))

Kstar(phyl, trait, nrep = 999, alter = c("greater", "less", "two-sided"))

Kw(phyl, trait, nrep = 999, alter = c("greater", "less", "two-sided"))
```

### Arguments

 `phyl` an object inheriting the class `phylo` (see package ape), `phylo4` (see package phylobase) or `hclust`. `trait` a vector with the trait value for each species (tip) in the phylogenetic tree. Trait values for species must be in the same order as species in the phylogenetic tree. `nrep` a numeric: the number of randomizations. `alter` a string specifying the alternative hypothesis; it must be one of `"greater"` (phylogenetic signal; the default), `"less"` or `"two-sided"`. If several values are given, only the first one is retained.

### Details

Blomberg et al. (2003) introduced two statistics of phylogenetic signal:

K = MSE0 / MSE

K* = MSE* / MSE

where MSE is the mean squared error of the trait values calculated using the variance-covariance matrix derived from the phylogenetic tree, MSE0 is the mean squared error of the tip trait values, measured from a phylogenetically correct mean of tip trait values and MSE* is the mean squared error of the tip trait values, measured from the estimate of the mean of the raw tip trait values. In both statistics K and K*, the value of MSE will be relatively small if the phylogenetic tree accurately describes the variance-covariance pattern observed in the data, leading to high values for K and K* (meaning high phylogenetic signal). In functions `K` and `Kstar`, K and K*, respectively, are divided (normalized) by their expected value if the trait evolved under a Brownian motion along the branches of the phylogenetic tree (this expected value is invariant under permutation of trait values among the tips of the phylogeny).

To test for phylogenetic signal, Blomberg et al. (2003) actually considered neither K nor K* but MSE as the core statistic associated with random permutations of trait values among tips of the phylogenetic tree. Although the literature on phylogenetic signal has currently mostly ignored K* focusing on statistic K, K* could thus actually have been considered as the core statistic of Blomberg et al. (2003) test for phylogenetic signal. Indeed, as MSE* is independent of permutations of trait values among the tips of the phylogeny while MSE0 is, Blomberg et al. (2003) approach corresponds to considering K* and not K as the statistic of the test of phylogenetic signal in traits. This test is also equivalent to an alternative implemented via phylogenetically independent contrasts also proposed by Blomberg et al. (2003).

Function `KW` implements index Kw, a modified version of K* that grants a higher importance in the calculation of phylogenetic signal to the tips that have many closely related tips (Pavoine and Ricotta 2013).

In functions, `K`, `Kstar` and `Kw`, I considered the same permutation scheme as in Blomberg et al. (2003) but used K, K* and Kw, as the core statistic, respectively. The test developed by Blomberg et al. (2003) thus corresponds to function `Kstar`.

### Value

Each function returns an object of class `randtest` with the results of the permutation tests. (see function `randtest` in package ade4)

### Author(s)

Sandrine Pavoine sandrine.pavoine@mnhn.fr

### References

Blomberg, S.P., Garland, T., Ives, A.R. (2003) Testing for phylogenetic signal in comparative data: behavioral traits are more labile. Evolution, 57, 717–745.

Pavoine, S., Ricotta, C. (2013) Testing for phylogenetic signal in biological traits: the ubiquity of cross-product statistics. Evolution, 67, 828–840.

`Kstar`, `Kw`

### Examples

```## Not run:

data(rockfish)

theK <- K(phy, rockfish\$traits[phy\$tip.label, 1])
theK
plot(theK)

theKstar <- Kstar(phy, rockfish\$traits[phy\$tip.label, 1])
theKstar
plot(theKstar)

theKw <- Kw(phy, rockfish\$traits[phy\$tip.label, 1])
theKw
plot(theKw)

}

## End(Not run)
```