pic.ortho: Phylogenetically Independent Orthonormal Contrasts

Description Usage Arguments Details Value Author(s) References See Also Examples

View source: R/pic.R

Description

This function computes the orthonormal contrasts using the method described by Felsenstein (2008). Only a single trait can be analyzed; there can be several observations per species.

Usage

1
pic.ortho(x, phy, var.contrasts = FALSE, intra = FALSE)

Arguments

x

a numeric vector or a list of numeric vectors.

phy

an object of class "phylo".

var.contrasts

logical, indicates whether the expected variances of the contrasts should be returned (default to FALSE).

intra

logical, whether to return the intraspecific contrasts.

Details

The data x can be in two forms: a vector if there is a single observation for each species, or a list whose elements are vectors containing the individual observations for each species. These vectors may be of different lengths.

If x has names, its values are matched to the tip labels of phy, otherwise its values are taken to be in the same order than the tip labels of phy.

Value

either a vector of contrasts, or a two-column matrix with the contrasts in the first column and their expected variances in the second column (if var.contrasts = TRUE). If the tree has node labels, these are used as labels of the returned object.

If intra = TRUE, the attribute "intra", a list of vectors with the intraspecific contrasts or NULL for the species with a one observation, is attached to the returned object.

Author(s)

Emmanuel Paradis

References

Felsenstein, J. (2008) Comparative methods with sampling error and within-species variation: Contrasts revisited and revised. American Naturalist, 171, 713–725.

See Also

pic, varCompPhylip

Examples

1
2
3
4
5
6
7
8
tr <- rcoal(30)
### a single observation per species:
x <- rTraitCont(tr)
pic.ortho(x, tr)
pic.ortho(x, tr, TRUE)
### different number of observations per species:
x <- lapply(sample(1:5, 30, TRUE), rnorm)
pic.ortho(x, tr, intra = TRUE)

Example output

           31            32            33            34            35 
-1.878489e-01  2.231555e-01 -1.457898e-01  7.468094e-02  1.010386e-01 
           36            37            38            39            40 
 8.930429e-02 -1.879065e-02 -8.964799e-03 -9.002681e-02 -2.325797e-05 
           41            42            43            44            45 
 8.602010e-03 -3.323148e-02  1.876600e-02  6.783034e-02  5.549726e-03 
           46            47            48            49            50 
-4.619032e-02  7.589203e-03  1.700657e-02  8.290729e-03  3.754268e-02 
           51            52            53            54            55 
 2.658836e-02 -4.849340e-03  2.542465e-02 -1.114919e-02  1.083879e-02 
           56            57            58            59 
-6.849387e-03  3.222744e-04  9.567091e-03 -3.516445e-04 
       contrasts     variance
31 -1.878489e-01 8.1336951038
32  2.231555e-01 5.0205660145
33 -1.457898e-01 1.8368389197
34  7.468094e-02 1.3192122678
35  1.010386e-01 0.4217915162
36  8.930429e-02 0.2127709395
37 -1.879065e-02 0.5050031392
38 -8.964799e-03 0.2262199723
39 -9.002681e-02 0.1992805174
40 -2.325797e-05 0.2120806198
41  8.602010e-03 0.1563055277
42 -3.323148e-02 0.1155692257
43  1.876600e-02 0.1051256488
44  6.783034e-02 0.1397091232
45  5.549726e-03 0.0906089304
46 -4.619032e-02 0.0950018617
47  7.589203e-03 0.0764420711
48  1.700657e-02 0.0421480595
49  8.290729e-03 0.0389826008
50  3.754268e-02 0.0347135494
51  2.658836e-02 0.0422549757
52 -4.849340e-03 0.0284666198
53  2.542465e-02 0.0252907973
54 -1.114919e-02 0.0191524827
55  1.083879e-02 0.0186906674
56 -6.849387e-03 0.0099844676
57  3.222744e-04 0.0060347604
58  9.567091e-03 0.0021220980
59 -3.516445e-04 0.0004496835
         31          32          33          34          35          36 
 0.89616576  0.86435660 -0.71562292 -0.07757967  0.68188094  0.22425791 
         37          38          39          40          41          42 
 0.71081131 -0.34428173 -0.26166588 -0.32522798  0.17251498 -0.85961479 
         43          44          45          46          47          48 
-0.75076444 -0.09594546 -1.80186749 -1.44047501  2.02649373 -0.40640927 
         49          50          51          52          53          54 
-0.61841228  0.37525180 -1.87789816 -0.12708358  0.65791356  1.94621226 
         55          56          57          58          59 
-0.77543722 -2.00427304  0.37232120 -0.52443567 -0.11997514 
attr(,"intra")
attr(,"intra")$t17
[1] -0.98291398  0.51376351 -0.05917482

attr(,"intra")$t8
[1] -0.1890188

attr(,"intra")$t10
[1] -0.1379050  0.5120594 -0.1845081

attr(,"intra")$t5
[1]  0.4465634 -0.4774436  0.4901192

attr(,"intra")$t3
[1]  0.1546809 -0.2120560 -1.4120125

attr(,"intra")$t22
[1] 0.7560508 1.1258017 0.6361948 1.0935225

attr(,"intra")$t20
[1]  0.2240103  0.4495512 -1.9328085

attr(,"intra")$t19
[1]  0.8140827 -0.4863960

attr(,"intra")$t1
NULL

attr(,"intra")$t18
[1] -1.2464638  0.5396705 -1.5046453 -0.6300711

attr(,"intra")$t27
NULL

attr(,"intra")$t24
[1] -0.90093125  0.08971458

attr(,"intra")$t25
[1] 0.3291918 0.1995028

attr(,"intra")$t4
NULL

attr(,"intra")$t23
NULL

attr(,"intra")$t28
[1]  1.5916156  0.7958098 -0.6502815

attr(,"intra")$t11
NULL

attr(,"intra")$t30
[1]  0.51508851 -0.32088854 -1.47000917 -0.08172254

attr(,"intra")$t13
[1]  1.4066654 -0.1576881 -1.4996184

attr(,"intra")$t14
[1] -1.74619

attr(,"intra")$t26
[1] -1.255612 -1.460457

attr(,"intra")$t29
[1] -0.703168643 -1.272431034  1.115468534  0.007865326

attr(,"intra")$t2
[1] -0.5219172  1.2997340 -1.3950046 -0.2165376

attr(,"intra")$t16
[1] -0.3734063 -1.9710318 -1.5904461

attr(,"intra")$t15
[1] -1.1213753 -0.4924286  0.3949122 -0.5397798

attr(,"intra")$t21
NULL

attr(,"intra")$t6
NULL

attr(,"intra")$t9
[1]  1.5197897 -1.2047581 -0.9943149

attr(,"intra")$t7
NULL

attr(,"intra")$t12
[1] -0.2327652  1.9187909

ape documentation built on Sept. 24, 2018, 9:03 a.m.