Functions to compute the fourth-corner statistic
fourthcorner.Rd
These functions allow to compute the fourth-corner statistic for abundance or presence-absence data. The fourth-corner statistic has been developed by Legendre et al (1997) and extended in Dray and Legendre (2008). The statistic measures the link between three tables: a table L (n x p) containing the abundances of p species at n sites, a second table R (n x m) containing the measurements of m environmental variables for the n sites, and a third table Q (p x s) describing s species traits for the p species.
Usage
fourthcorner(tabR, tabL, tabQ, modeltype = 6, nrepet = 999, tr01 = FALSE,
p.adjust.method.G = p.adjust.methods, p.adjust.method.D = p.adjust.methods,
p.adjust.D = c("global", "levels"), ...)
fourthcorner2(tabR, tabL, tabQ, modeltype = 6, nrepet = 999, tr01 = FALSE,
p.adjust.method.G = p.adjust.methods, ...)
# S3 method for class '4thcorner'
print(x, varQ = 1:length(x$varnames.Q),
varR = 1:length(x$varnames.R), stat = c("D", "D2"), ...)
# S3 method for class '4thcorner'
summary(object,...)
# S3 method for class '4thcorner'
plot(x, stat = c("D", "D2", "G"), type = c("table", "biplot"),
xax = 1, yax = 2, x.rlq = NULL, alpha = 0.05,
col = c("lightgrey", "red", "deepskyblue", "purple"), ...)
fourthcorner.rlq(xtest, nrepet = 999, modeltype = 6,
typetest = c("axes", "Q.axes", "R.axes"), p.adjust.method.G = p.adjust.methods,
p.adjust.method.D = p.adjust.methods, p.adjust.D = c("global", "levels"), ...)
Arguments
- tabR
a dataframe containing the measurements (numeric values or factors) of m environmental variables (columns) for the n sites (rows).
- tabL
a dataframe containing the abundances of p species (columns) at n sites (rows).
- tabQ
a dataframe containing numeric values or factors describing s species traits (columns) for the p species (rows).
- modeltype
an integer (1-6) indicating the permutation model used in the testing procedure (see details).
- nrepet
the number of permutations
- tr01
a logical indicating if data in
tabL
must be transformed to presence-absence data (FALSE by default)- object
an object of the class 4thcorner
- x
an object of the class 4thcorner
- varR
a vector containing indices for variables in
tabR
- varQ
a vector containing indices for variables in
tabQ
- type
results are represented by a table or on a biplot (see x.rlq)
- alpha
a value of significance level
- p.adjust.method.G
a string indicating a method for multiple adjustment used for output tabG, see
p.adjust.methods
for possible choices- p.adjust.method.D
a string indicating a method for multiple adjustment used for output tabD/tabD2, see
p.adjust.methods
for possible choices- p.adjust.D
a string indicating if multiple adjustment for tabD/tabD2 should be done globally or only between levels of a factor ("levels", as in the original paper of Legendre et al. 1997)
- stat
a character to specify if results should be plotted for cells (D and D2) or variables (G)
- xax
an integer indicating which rlq axis should be plotted on the x-axis
- yax
an integer indicating which rlq axis should be plotted on the y-axis
- x.rlq
an object created by the
rlq
function. Used to represent results on a biplot (type should be "biplot" and object created by thefourthcorner
functions)- col
a vector of length 4 containing four colors used for the graphical representations. The first is used to represent non-significant associations, the second positive significant, the third negative significant. For the 'biplot' method and objects created by the
fourthcorner.rlq
function, the second corresponds to variables significantly linked to the x-axis, the third for the y-axis and the fourth for both axes- xtest
an object created by the
rlq
function- typetest
a string indicating which tests should be performed
- ...
further arguments passed to or from other methods
Details
For the fourthcorner
function, the link is measured by a Pearson correlation coefficient for two quantitative variables (trait and environmental variable), by a Pearson Chi2 and G statistic for two qualitative variables and by a Pseudo-F and Pearson r for one quantitative variable and one qualitative variable. The fourthcorner2 function offers a multivariate statistic (equal to the sum of eigenvalues of RLQ analysis) and measures the link between two variables by a square correlation coefficient (quant/quant), a Chi2/sum(L) (qual/qual) and a correlation ratio (quant/qual). The significance is tested by a permutation procedure. Different models are available:
model 1 (
modeltype
=1): Permute values for each species independently (i.e., permute within each column of table L)model 2 (
modeltype
=2): Permute values of sites (i.e., permute entire rows of table L)model 3 (
modeltype
=3): Permute values for each site independently (i.e., permute within each row of table L)model 4 (
modeltype
=4): Permute values of species (i.e., permute entire columns of table L)model 5 (
modeltype
=5): Permute values of species and after (or before) permute values of sites (i.e., permute entire columns and after (or before) entire rows of table L)model 6 (
modeltype
=6): combination of the outputs of models 2 and 4. Dray and Legendre (2008) and ter Braak et al. (20012) showed that all models (except model 6) have inflated type I error.
Note that the model 5 is strictly equivalent to permuting simultaneously the rows of tables R and Q, as proposed by Doledec et al. (1996).
The function summary
returns results for variables (G). The
function print
returns results for cells (D and D2). In the case
of qualitative variables, Holm's corrected pvalues are also provided.
The function plot
produces a graphical representation of the
results (white for non significant, light grey for negative significant
and dark grey for positive significant relationships). Results can be
plotted for variables (G) or for cells (D and D2). In the case of
qualitative / quantitative association, homogeneity (D) or correlation
(D2) are plotted.
Value
The fourthcorner
function returns a a list where:
tabD
is akrandtest
object giving the results of tests for cells of the fourth-corner (homogeneity for quant./qual.).tabD2
is akrandtest
object giving the results of tests for cells of the fourth-corner (Pearson r for quant./qual.).tabG
is akrandtest
object giving the results of tests for variables (Pearson's Chi2 for qual./qual.).
The fourthcorner2
function returns a list where:
tabG
is akrandtest
object giving the results of tests for variables.trRLQ
is akrandtest
object giving the results of tests for the multivariate statistic (i.e. equivalent torandtest.rlq
function).
References
Doledec, S., Chessel, D., ter Braak, C.J.F. and Champely, S. (1996) Matching species traits to environmental variables: a new three-table ordination method. Environmental and Ecological Statistics, 3, 143–166.
Legendre, P., R. Galzin, and M. L. Harmelin-Vivien. (1997) Relating behavior to habitat: solutions to the fourth-corner problem. Ecology, 78, 547–562.
Dray, S. and Legendre, P. (2008) Testing the species traits-environment relationships: the fourth-corner problem revisited. Ecology, 89, 3400–3412.
ter Braak, C., Cormont, A., and Dray, S. (2012) Improved testing of species traits-environment relationships in the fourth corner problem. Ecology, 93, 1525–1526.
Dray, S., Choler, P., Doledec, S., Peres-Neto, P.R., Thuiller, W., Pavoine, S. and ter Braak, C.J.F (2014) Combining the fourth-corner and the RLQ methods for assessing trait responses to environmental variation. Ecology, 95, 14–21. doi:10.1890/13-0196.1
Author
Stéphane Dray stephane.dray@univ-lyon1.fr
Examples
data(aviurba)
## Version using the sequential test (ter Braak et al 2012)
## as recommended in Dray et al (2013),
## using Holm correction of P-values (only 99 permutations here)
four.comb.default <- fourthcorner(aviurba$mil,aviurba$fau,aviurba$traits,nrepet=99)
summary(four.comb.default)
#> Fourth-corner Statistics
#> ------------------------
#> Permutation method Comb. 2 and 4 ( 99 permutations)
#>
#> Adjustment method for multiple comparisons: holm
#> Test Stat Obs Std.Obs Alter Pvalue
#> 1 farms / feed.hab Chi2 4.36429268 2.295495479 greater 0.04
#> 2 small.bui / feed.hab Chi2 5.57481613 1.746971583 greater 0.07
#> 3 high.bui / feed.hab Chi2 3.11706174 0.606108009 greater 0.24
#> 4 industry / feed.hab Chi2 2.05615534 0.031344316 greater 0.35
#> 5 fields / feed.hab Chi2 14.01139382 0.055150988 greater 0.37
#> 6 grassland / feed.hab Chi2 1.27966991 -0.260547947 greater 0.48
#> 7 scrubby / feed.hab Chi2 2.87647118 0.954971438 greater 0.11
#> 8 deciduous / feed.hab Chi2 2.56301663 0.256398831 greater 0.28
#> 9 conifer / feed.hab Chi2 0.67773900 -0.594378464 greater 0.70
#> 10 noisy / feed.hab Chi2 8.04038367 -0.180385659 greater 0.49
#> 11 veg.cover / feed.hab Chi2 29.48926101 -0.379268816 greater 0.53
#> 12 farms / feed.strat Chi2 4.29284964 0.547390514 greater 0.23
#> 13 small.bui / feed.strat Chi2 13.59643807 2.992764157 greater 0.04
#> 14 high.bui / feed.strat Chi2 8.13102044 0.948972082 greater 0.11
#> 15 industry / feed.strat Chi2 1.60089833 -0.447712340 greater 0.60
#> 16 fields / feed.strat Chi2 7.89491358 1.737128280 greater 0.07
#> 17 grassland / feed.strat Chi2 2.11779967 -0.345019095 greater 0.47
#> 18 scrubby / feed.strat Chi2 5.17033389 0.793727078 greater 0.18
#> 19 deciduous / feed.strat Chi2 4.27795300 0.243337888 greater 0.28
#> 20 conifer / feed.strat Chi2 3.27694136 0.159985917 greater 0.25
#> 21 noisy / feed.strat Chi2 6.75501319 0.964699944 greater 0.16
#> 22 veg.cover / feed.strat Chi2 78.31693213 2.369616829 greater 0.05
#> 23 farms / breeding Chi2 3.23430156 -0.457763113 greater 0.63
#> 24 small.bui / breeding Chi2 27.79316236 1.907196271 greater 0.07
#> 25 high.bui / breeding Chi2 12.43543038 0.984548680 greater 0.10
#> 26 industry / breeding Chi2 22.28586480 3.170069002 greater 0.02
#> 27 fields / breeding Chi2 38.33899311 1.545015853 greater 0.08
#> 28 grassland / breeding Chi2 16.69969331 1.761632967 greater 0.09
#> 29 scrubby / breeding Chi2 7.93877813 0.597165875 greater 0.24
#> 30 deciduous / breeding Chi2 36.37422465 6.269643246 greater 0.01
#> 31 conifer / breeding Chi2 8.13155633 0.468364010 greater 0.21
#> 32 noisy / breeding Chi2 22.81746753 1.332861904 greater 0.13
#> 33 veg.cover / breeding Chi2 118.24035270 3.222986594 greater 0.03
#> 34 farms / migratory Chi2 3.19878341 1.978222496 greater 0.07
#> 35 small.bui / migratory Chi2 0.98799705 0.009362366 greater 0.32
#> 36 high.bui / migratory Chi2 0.62908910 -0.275143822 greater 0.37
#> 37 industry / migratory Chi2 0.98753393 0.001061572 greater 0.31
#> 38 fields / migratory Chi2 5.39284445 3.845909669 greater 0.04
#> 39 grassland / migratory Chi2 0.09775421 -0.666352785 greater 0.82
#> 40 scrubby / migratory Chi2 3.40196612 1.678334708 greater 0.05
#> 41 deciduous / migratory Chi2 0.00146756 -0.758876021 greater 0.98
#> 42 conifer / migratory Chi2 0.18177435 -0.484990722 greater 0.69
#> 43 noisy / migratory Chi2 0.99220442 0.039952946 greater 0.32
#> 44 veg.cover / migratory Chi2 9.14414536 0.736910869 greater 0.23
#> Pvalue.adj
#> 1 1.00
#> 2 1.00
#> 3 1.00
#> 4 1.00
#> 5 1.00
#> 6 1.00
#> 7 1.00
#> 8 1.00
#> 9 1.00
#> 10 1.00
#> 11 1.00
#> 12 1.00
#> 13 1.00
#> 14 1.00
#> 15 1.00
#> 16 1.00
#> 17 1.00
#> 18 1.00
#> 19 1.00
#> 20 1.00
#> 21 1.00
#> 22 1.00
#> 23 1.00
#> 24 1.00
#> 25 1.00
#> 26 0.72
#> 27 1.00
#> 28 1.00
#> 29 1.00
#> 30 0.44
#> 31 1.00
#> 32 1.00
#> 33 1.00
#> 34 1.00
#> 35 1.00
#> 36 1.00
#> 37 1.00
#> 38 1.00
#> 39 1.00
#> 40 1.00
#> 41 1.00
#> 42 1.00
#> 43 1.00
#> 44 1.00
#>
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
plot(four.comb.default, stat = "G")
## using fdr correction of P-values
four.comb.fdr <- fourthcorner(aviurba$mil, aviurba$fau, aviurba$traits,
nrepet = 99, p.adjust.method.G = 'fdr', p.adjust.method.D = 'fdr')
summary(four.comb.fdr)
#> Fourth-corner Statistics
#> ------------------------
#> Permutation method Comb. 2 and 4 ( 99 permutations)
#>
#> Adjustment method for multiple comparisons: fdr
#> Test Stat Obs Std.Obs Alter Pvalue
#> 1 farms / feed.hab Chi2 4.36429268 0.20884546 greater 0.30
#> 2 small.bui / feed.hab Chi2 5.57481613 -0.45378050 greater 0.55
#> 3 high.bui / feed.hab Chi2 3.11706174 -0.64046206 greater 0.69
#> 4 industry / feed.hab Chi2 2.05615534 -0.22182628 greater 0.50
#> 5 fields / feed.hab Chi2 14.01139382 0.08482524 greater 0.39
#> 6 grassland / feed.hab Chi2 1.27966991 -0.77624006 greater 0.76
#> 7 scrubby / feed.hab Chi2 2.87647118 0.09449946 greater 0.35
#> 8 deciduous / feed.hab Chi2 2.56301663 -0.55599611 greater 0.63
#> 9 conifer / feed.hab Chi2 0.67773900 -0.70837631 greater 0.70
#> 10 noisy / feed.hab Chi2 8.04038367 -0.14213104 greater 0.49
#> 11 veg.cover / feed.hab Chi2 29.48926101 -0.29530078 greater 0.53
#> 12 farms / feed.strat Chi2 4.29284964 0.14631809 greater 0.35
#> 13 small.bui / feed.strat Chi2 13.59643807 1.06912700 greater 0.13
#> 14 high.bui / feed.strat Chi2 8.13102044 0.85332276 greater 0.15
#> 15 industry / feed.strat Chi2 1.60089833 -0.28651498 greater 0.47
#> 16 fields / feed.strat Chi2 7.89491358 -0.32761859 greater 0.52
#> 17 grassland / feed.strat Chi2 2.11779967 -0.50057766 greater 0.60
#> 18 scrubby / feed.strat Chi2 5.17033389 0.90760330 greater 0.12
#> 19 deciduous / feed.strat Chi2 4.27795300 -0.02117242 greater 0.33
#> 20 conifer / feed.strat Chi2 3.27694136 1.13583842 greater 0.10
#> 21 noisy / feed.strat Chi2 6.75501319 -0.16417636 greater 0.47
#> 22 veg.cover / feed.strat Chi2 78.31693213 3.41649387 greater 0.01
#> 23 farms / breeding Chi2 3.23430156 -0.48084845 greater 0.62
#> 24 small.bui / breeding Chi2 27.79316236 2.00937411 greater 0.05
#> 25 high.bui / breeding Chi2 12.43543038 0.87293687 greater 0.21
#> 26 industry / breeding Chi2 22.28586480 6.47496250 greater 0.01
#> 27 fields / breeding Chi2 38.33899311 1.86673736 greater 0.06
#> 28 grassland / breeding Chi2 16.69969331 2.78094314 greater 0.02
#> 29 scrubby / breeding Chi2 7.93877813 1.58125758 greater 0.11
#> 30 deciduous / breeding Chi2 36.37422465 6.21199498 greater 0.01
#> 31 conifer / breeding Chi2 8.13155633 0.66354544 greater 0.20
#> 32 noisy / breeding Chi2 22.81746753 1.36377678 greater 0.12
#> 33 veg.cover / breeding Chi2 118.24035270 4.11235291 greater 0.01
#> 34 farms / migratory Chi2 3.19878341 0.91590648 greater 0.18
#> 35 small.bui / migratory Chi2 0.98799705 -0.54523901 greater 0.58
#> 36 high.bui / migratory Chi2 0.62908910 -0.56193514 greater 0.60
#> 37 industry / migratory Chi2 0.98753393 -0.23006150 greater 0.51
#> 38 fields / migratory Chi2 5.39284445 -0.09971868 greater 0.37
#> 39 grassland / migratory Chi2 0.09775421 -0.76174494 greater 0.86
#> 40 scrubby / migratory Chi2 3.40196612 1.63046470 greater 0.10
#> 41 deciduous / migratory Chi2 0.00146756 -0.76060238 greater 0.98
#> 42 conifer / migratory Chi2 0.18177435 -0.64315022 greater 0.67
#> 43 noisy / migratory Chi2 0.99220442 -0.58276984 greater 0.63
#> 44 veg.cover / migratory Chi2 9.14414536 -0.45599292 greater 0.61
#> Pvalue.adj
#> 1 0.72947
#> 2 0.72947
#> 3 0.75122
#> 4 0.72947
#> 5 0.72947
#> 6 0.79619
#> 7 0.72947
#> 8 0.72947
#> 9 0.75122
#> 10 0.72947
#> 11 0.72947
#> 12 0.72947
#> 13 0.40857
#> 14 0.44000
#> 15 0.72947
#> 16 0.72947
#> 17 0.72947
#> 18 0.40615
#> 19 0.72947
#> 20 0.40615
#> 21 0.72947
#> 22 0.11000
#> 23 0.72947
#> 24 0.31429
#> 25 0.54353
#> 26 0.11000
#> 27 0.33000
#> 28 0.14667
#> 29 0.40615
#> 30 0.11000
#> 31 0.35200
#> 32 0.40615
#> 33 0.11000
#> 34 0.49500
#> 35 0.72947
#> 36 0.72947
#> 37 0.72947
#> 38 0.72947
#> 39 0.88000
#> 40 0.40615
#> 41 0.98000
#> 42 0.75122
#> 43 0.72947
#> 44 0.72947
#>
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
plot(four.comb.fdr, stat = "G")
## Explicit procedure to combine the results of two models
## proposed in Dray and Legendre (2008);the above does this implicitly
four2 <- fourthcorner(aviurba$mil,aviurba$fau,aviurba$traits,nrepet=99,modeltype=2)
four4 <- fourthcorner(aviurba$mil,aviurba$fau,aviurba$traits,nrepet=99,modeltype=4)
four.comb <- combine.4thcorner(four2, four4)
summary(four.comb)
#> Fourth-corner Statistics
#> ------------------------
#> Permutation method Comb. 2 and 4 ( 99 permutations)
#>
#> Adjustment method for multiple comparisons: holm
#> Test Stat Obs Std.Obs Alter Pvalue
#> 1 farms / feed.hab Chi2 4.36429268 1.573370407 greater 0.08
#> 2 small.bui / feed.hab Chi2 5.57481613 -0.584969060 greater 0.68
#> 3 high.bui / feed.hab Chi2 3.11706174 0.723118087 greater 0.21
#> 4 industry / feed.hab Chi2 2.05615534 0.169655878 greater 0.32
#> 5 fields / feed.hab Chi2 14.01139382 -0.102383638 greater 0.39
#> 6 grassland / feed.hab Chi2 1.27966991 -0.201732648 greater 0.48
#> 7 scrubby / feed.hab Chi2 2.87647118 0.701623729 greater 0.16
#> 8 deciduous / feed.hab Chi2 2.56301663 0.839001881 greater 0.16
#> 9 conifer / feed.hab Chi2 0.67773900 -0.698431577 greater 0.72
#> 10 noisy / feed.hab Chi2 8.04038367 -0.154885611 greater 0.53
#> 11 veg.cover / feed.hab Chi2 29.48926101 -0.336940270 greater 0.62
#> 12 farms / feed.strat Chi2 4.29284964 0.387864417 greater 0.26
#> 13 small.bui / feed.strat Chi2 13.59643807 3.017805579 greater 0.05
#> 14 high.bui / feed.strat Chi2 8.13102044 2.058597383 greater 0.08
#> 15 industry / feed.strat Chi2 1.60089833 -0.546515026 greater 0.60
#> 16 fields / feed.strat Chi2 7.89491358 1.750868023 greater 0.08
#> 17 grassland / feed.strat Chi2 2.11779967 -0.412519227 greater 0.57
#> 18 scrubby / feed.strat Chi2 5.17033389 0.645171209 greater 0.16
#> 19 deciduous / feed.strat Chi2 4.27795300 0.308157180 greater 0.26
#> 20 conifer / feed.strat Chi2 3.27694136 0.008772359 greater 0.34
#> 21 noisy / feed.strat Chi2 6.75501319 0.754034839 greater 0.18
#> 22 veg.cover / feed.strat Chi2 78.31693213 2.602882878 greater 0.03
#> 23 farms / breeding Chi2 3.23430156 -0.475953294 greater 0.60
#> 24 small.bui / breeding Chi2 27.79316236 1.477045078 greater 0.13
#> 25 high.bui / breeding Chi2 12.43543038 1.807951809 greater 0.07
#> 26 industry / breeding Chi2 22.28586480 3.743381678 greater 0.01
#> 27 fields / breeding Chi2 38.33899311 1.377205855 greater 0.12
#> 28 grassland / breeding Chi2 16.69969331 1.371706411 greater 0.11
#> 29 scrubby / breeding Chi2 7.93877813 0.335032612 greater 0.25
#> 30 deciduous / breeding Chi2 36.37422465 6.231598494 greater 0.01
#> 31 conifer / breeding Chi2 8.13155633 0.487891277 greater 0.22
#> 32 noisy / breeding Chi2 22.81746753 1.243494591 greater 0.14
#> 33 veg.cover / breeding Chi2 118.24035270 5.490753181 greater 0.01
#> 34 farms / migratory Chi2 3.19878341 1.920648796 greater 0.08
#> 35 small.bui / migratory Chi2 0.98799705 0.439110053 greater 0.26
#> 36 high.bui / migratory Chi2 0.62908910 -0.125140612 greater 0.36
#> 37 industry / migratory Chi2 0.98753393 -0.112058212 greater 0.34
#> 38 fields / migratory Chi2 5.39284445 -0.188130386 greater 0.41
#> 39 grassland / migratory Chi2 0.09775421 -0.648887703 greater 0.76
#> 40 scrubby / migratory Chi2 3.40196612 1.685917190 greater 0.06
#> 41 deciduous / migratory Chi2 0.00146756 -0.807066176 greater 0.97
#> 42 conifer / migratory Chi2 0.18177435 -0.522920219 greater 0.62
#> 43 noisy / migratory Chi2 0.99220442 -0.036133767 greater 0.32
#> 44 veg.cover / migratory Chi2 9.14414536 0.904430322 greater 0.19
#> Pvalue.adj
#> 1 1.00
#> 2 1.00
#> 3 1.00
#> 4 1.00
#> 5 1.00
#> 6 1.00
#> 7 1.00
#> 8 1.00
#> 9 1.00
#> 10 1.00
#> 11 1.00
#> 12 1.00
#> 13 1.00
#> 14 1.00
#> 15 1.00
#> 16 1.00
#> 17 1.00
#> 18 1.00
#> 19 1.00
#> 20 1.00
#> 21 1.00
#> 22 1.00
#> 23 1.00
#> 24 1.00
#> 25 1.00
#> 26 0.44
#> 27 1.00
#> 28 1.00
#> 29 1.00
#> 30 0.44
#> 31 1.00
#> 32 1.00
#> 33 0.44
#> 34 1.00
#> 35 1.00
#> 36 1.00
#> 37 1.00
#> 38 1.00
#> 39 1.00
#> 40 1.00
#> 41 1.00
#> 42 1.00
#> 43 1.00
#> 44 1.00
#>
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
plot(four.comb, stat = "G")