orthogram {ade4}R Documentation

Orthonormal decomposition of variance

Description

This function performs the orthonormal decomposition of variance of a quantitative variable on an orthonormal basis. It also returns the results of five non parametric tests associated to the variance decomposition. It thus provides tools (graphical displays and test) for analysing phylogenetic, spatial and temporal pattern of one quantitative variable.

Usage

orthogram(x, orthobas = NULL, neig = NULL, phylog = NULL,
     nrepet = 999, posinega = 0, tol = 1e-07, na.action = c("fail",
     "mean"), cdot = 1.5, cfont.main = 1.5, lwd = 2, nclass,
     high.scores = 0,alter=c("greater", "less", "two-sided"))

Arguments

x a numeric vector corresponding to the quantitative variable
orthobas an object of class 'orthobasis'
neig an object of class 'neig'
phylog an object of class 'phylog'
nrepet an integer giving the number of permutations
posinega a parameter for the ratio test. If posinega > 0, the function computes the ratio test.
tol a tolerance threshold for orthonormality condition
na.action if 'fail' stops the execution of the current expression when z contains any missing value. If 'mean' replaces any missing values by mean(z)
cdot a character size for points on the cumulative decomposition display
cfont.main a character size for titles
lwd a character size for dash lines
nclass a single number giving the number of cells for the histogram
high.scores a single number giving the number of vectors to return. If > 0, the function returns labels of vectors that explains the larger part of variance.
alter a character string specifying the alternative hypothesis, must be one of "greater" (default), "less" or "two-sided"

Details

The function computes the variance decomposition of a quantitative vector x on an orthonormal basis B. The variable is normalized given the uniform weight to eliminate problem of scales. It plots the squared correlations R^2 between x and vectors of B (variance decomposition) and the cumulated squared correlations SR^2 (cumulative decomposition). The function also provides five non parametric tests to test the existence of autocorrelation. The tests derive from the five following statistics :

R2Max
=max(R^2). It takes high value when a high part of the variability is explained by one score.
SkR2k
=sum_i^(n-1) i*(R^2)_i. It compares the part of variance explained by internal nodes to the one explained by end nodes.
Dmax
=max_(m=1,...,n-1)(sum_(j=1)^m(R^2_j) - (m/n-1)). It examines the accumulation of variance for a sequence of scores.
SCE
=sum_(m=1)^(n-1)(sum_(j=1)^m(R^2_j) - (m/n-1))^2. It examines also the accumulation of variance for a sequence of scores.
ratio
depends of the parameter posinega. If posinega > 0, the statistic ratio exists and equals sum_i (R^2)_i with i < posinega + 1. It compares the part of variance explained by internal nodes to the one explained by end nodes when we can define how many vectors correspond to internal nodes.

Value

If (high.scores = 0), returns an object of class 'krandtest' (randomization tests) corresponding to the five non parametric tests.

If (high.scores > 0), returns a list containg :
w : an object of class 'krandtest' (randomization tests)
scores.order : a vector which terms give labels of vectors that explain the larger part of variance

Author(s)

S├ębastien Ollier ollier@biomserv.univ-lyon1.fr
Daniel Chessel

References

Ollier, S., Chessel, D. and Couteron, P. (2005) Orthonormal Transform to Decompose the Variance of a Life-History Trait across a Phylogenetic Tree. Biometrics, 62, 471–477.

See Also

gridrowcol, orthobasis, mld

Examples

# a phylogenetic example
data(ungulates)
ung.phy <- newick2phylog(ungulates$tre)
FemBodyMass <- log(ungulates$tab[,1])
NeonatBodyMass <- log((ungulates$tab[,2]+ungulates$tab[,3])/2)
plot(FemBodyMass,NeonatBodyMass, pch = 20, cex = 2)
abline(lm(NeonatBodyMass~FemBodyMass))
z <- residuals(lm(NeonatBodyMass~FemBodyMass))
dotchart.phylog(ung.phy,val = z, clabel.n = 1,
     labels.n = ung.phy$Blabels, cle = 1.5, cdot = 2)
table.phylog(ung.phy$Bscores, ung.phy,clabel.n = 1,
     labels.n = ung.phy$Blabels)
orthogram(z, ung.phy$Bscores)
orthogram(z, phyl=ung.phy) # the same thing

# a spatial example
data(irishdata)
neig1 <- neig(mat01 = 1*(irishdata$link > 0))
sco1 <- scores.neig(neig1)
z <- scalewt(irishdata$tab$cow)
orthogram(z, sco1)

# a temporal example
data(arrival)
w <- orthobasis.circ(24)
orthogram(arrival$hours, w)
par(mfrow = c(1,2))
dotcircle(arrival$hours)
dotcircle(w[,2])
par(mfrow = c(1,1))

data(lynx)
ortho <- orthobasis.line(114)
orthogram(lynx,ortho)
attributes(lynx)$tsp
par(mfrow = c(2,1))
par(mar = c(4,4,2,2))
plot.ts(lynx)
plot(ts(ortho[,23], start = 1821, end = 1934, freq = 1), ylab = "score 23")
par(mfrow = c(1,1))

Worked out examples


> library(ade4)
> ### Name: orthogram
> ### Title: Orthonormal decomposition of variance
> ### Aliases: orthogram
> ### Keywords: spatial ts
> 
> ### ** Examples
> 
> # a phylogenetic example
> data(ungulates)
> ung.phy <- newick2phylog(ungulates$tre)
> FemBodyMass <- log(ungulates$tab[,1])
> NeonatBodyMass <- log((ungulates$tab[,2]+ungulates$tab[,3])/2)
> plot(FemBodyMass,NeonatBodyMass, pch = 20, cex = 2)
> abline(lm(NeonatBodyMass~FemBodyMass))
> z <- residuals(lm(NeonatBodyMass~FemBodyMass))
> dotchart.phylog(ung.phy,val = z, clabel.n = 1,
+      labels.n = ung.phy$Blabels, cle = 1.5, cdot = 2)
> table.phylog(ung.phy$Bscores, ung.phy,clabel.n = 1,
+      labels.n = ung.phy$Blabels)
> orthogram(z, ung.phy$Bscores)
class: krandtest 
Monte-Carlo tests
Call: orthogram(x = z, orthobas = ung.phy$Bscores)

Test number:   4 
Permutation number:   999 
   Test       Obs    Std.Obs     Alter Pvalue
1 R2Max 0.3566524  0.7156088   greater  0.245
2 SkR2k 5.3204632 -2.1292061      less  0.011
3  Dmax 0.4273104  2.3679582 two-sided  0.019
4   SCE 1.0474954  2.6290910   greater  0.032

other elements: NULL
> orthogram(z, phyl=ung.phy) # the same thing
class: krandtest 
Monte-Carlo tests
Call: orthogram(x = z, phylog = ung.phy)

Test number:   4 
Permutation number:   999 
   Test       Obs    Std.Obs     Alter Pvalue
1 R2Max 0.3566524  0.7286543   greater  0.257
2 SkR2k 5.3204632 -2.2550421      less  0.010
3  Dmax 0.4273104  2.4943814 two-sided  0.015
4   SCE 1.0474954  2.8249528   greater  0.024

other elements: NULL
> 
> # a spatial example
> data(irishdata)
> neig1 <- neig(mat01 = 1*(irishdata$link > 0))
> sco1 <- scores.neig(neig1)
> z <- scalewt(irishdata$tab$cow)
> orthogram(z, sco1)
class: krandtest 
Monte-Carlo tests
Call: orthogram(x = z, orthobas = sco1)

Test number:   4 
Permutation number:   999 
   Test       Obs   Std.Obs     Alter Pvalue
1 R2Max 0.3219990  1.370423   greater  0.100
2 SkR2k 4.0552287 -3.896431      less  0.001
3  Dmax 0.6286936  4.828481 two-sided  0.001
4   SCE 3.8344874 10.309496   greater  0.001

other elements: NULL
> 
> # a temporal example
> data(arrival)
> w <- orthobasis.circ(24)
> orthogram(arrival$hours, w)
class: krandtest 
Monte-Carlo tests
Call: orthogram(x = arrival$hours, orthobas = w)

Test number:   4 
Permutation number:   999 
   Test       Obs   Std.Obs     Alter Pvalue
1 R2Max 0.7375324  7.085597   greater  0.001
2 SkR2k 4.4263014 -4.065394      less  0.001
3  Dmax 0.6505764  5.391656 two-sided  0.001
4   SCE 3.5301360 11.944731   greater  0.001

other elements: NULL
> par(mfrow = c(1,2))
> dotcircle(arrival$hours)
> dotcircle(w[,2])
> par(mfrow = c(1,1))
> 
> data(lynx)
> ortho <- orthobasis.line(114)
> orthogram(lynx,ortho)
class: krandtest 
Monte-Carlo tests
Call: orthogram(x = lynx, orthobas = ortho)

Test number:   4 
Permutation number:   999 
   Test        Obs   Std.Obs     Alter Pvalue
1 R2Max  0.3277626 15.671518   greater  0.001
2 SkR2k 25.5239344 -7.172787      less  0.001
3  Dmax  0.5797304 11.073390 two-sided  0.001
4   SCE 13.2741429 42.460455   greater  0.001

other elements: NULL
> attributes(lynx)$tsp
[1] 1821 1934    1
> par(mfrow = c(2,1))
> par(mar = c(4,4,2,2))
> plot.ts(lynx)
> plot(ts(ortho[,23], start = 1821, end = 1934, freq = 1), ylab = "score 23")
> par(mfrow = c(1,1))
> 
> 
> 
> 

[Package ade4 Index]