Type: Package
Title: Hierarchical and Variation Partitioning for Canonical Analysis
Version: 1.1-1
Date: 2024-8-24
Depends: R (≥ 3.4.0),vegan,ggplot2
Maintainer: Jiangshan Lai <lai@njfu.edu.cn>
Description: This function conducts variation partitioning and hierarchical partitioning to calculate the unique, shared (referred as to "common") and individual contributions of each predictor (or matrix) towards explained variation (R-square and adjusted R-square) on canonical analysis (RDA,CCA and db-RDA), applying the algorithm of Lai J.,Zou Y., Zhang J.,Peres-Neto P.(2022) Generalizing hierarchical and variation partitioning in multiple regression and canonical analyses using the rdacca.hp R package.Methods in Ecology and Evolution,13: 782-788 <doi:10.1111/2041-210X.13800>.
License: GPL-2 | GPL-3 [expanded from: GPL]
URL: https://github.com/laijiangshan/rdacca.hp
Encoding: UTF-8
RoxygenNote: 7.1.1
NeedsCompilation: no
Packaged: 2024-08-24 14:42:52 UTC; lai
Author: Jiangshan Lai ORCID iD [aut, cre], Kim Nimon [aut], Yao Liu [aut], Pedro Peres-Neto [aut]
Repository: CRAN
Date/Publication: 2024-08-24 15:20:02 UTC

Internal function for rdacca.hp() to create diagonal matrix

Description

Internal function for rdacca.hp() to create diagonal matrix

Usage

creatbin(col, binmatrix)

Arguments

col

Imput number.

binmatrix

Imput empty matrix.


Internal function for rdacca.hp()

Description

Internal function for rdacca.hp()

Usage

genList(ivlist, value)

Arguments

ivlist

The names of explanatory variable.

value

The sequence ID.


Internal function for rdacca.hp() to determine whether the odd number

Description

Internal function for rdacca.hp() to determine whether the odd number

Usage

odd(val)

Arguments

val

Imput number.


Permutation Test of Hierarchical Partitioning for Canonical Analysis

Description

Permutation Test of Hierarchical Partitioning for Canonical Analysis

Usage

permu.hp(
  dv,
  iv,
  method = c("RDA", "dbRDA", "CCA"),
  type = c("adjR2", "R2"),
  scale = FALSE,
  add = FALSE,
  sqrt.dist = FALSE,
  n.perm = 1000,
  permutations = 1000
)

Arguments

dv

Response variable, either a numeric vector or a matrix. If method="dbRDA", dv should be a "dist" matrix.

iv

Predictors (explanatory variable), either a data frame or a list of data frames. If it is a data frame, the relative importance of each column of the data frame will be evaluated; if it is a list, the relative importance of each element (matrix) will be evaluated.

method

Type of canonical analysis used for variation partitioning, should be a character string, either "RDA", "dbRDA" or "CCA", the default is "RDA". If the response variable (dv) is a numerical vector and method="RDA", the hierarchical and variation partitioning for the classical multiple regression is implemented.

type

The type of total explained variation, either "R2" or "adjR2", in which "R2" is unadjusted R-square and "adjR2" is adjusted R-square, the default is "adjR2". The adjusted R-square is calculated using Ezekiel's formula (Ezekiel 1930) for RDA and dbRDA, while permutation procedure is used for CCA (Peres-Neto et al. 2006).

scale

Logical; If the columns of dv should be standardized to unit variance when method="RDA" is applied.

add

Logical; If a constant should be added to the non-diagonal values to euclidify dissimilarities (see dbrda function in vegan for details). Choice "lingoes" (or TRUE) uses the recommended method of Legendre & Anderson (1999: "method 1") and "cailliez" uses their "method 2". The argument has an effect only when method="dbRDA".

sqrt.dist

Logical, If the square root of dissimilarities should be taken. This often euclidifies dissimilarities. The argument has an effect only when method="dbRDA"(see dbrda function in vegan for details).

n.perm

An integer; Number of permutations for computing the adjusted R-square for CCA. The argument has an effect only when method="CCA".

permutations

An integer; Number of permutations for computing p value of individual contribution for the randomized dataset.

Details

This function is a permutation test of hierarchical partitioning for canonical analysis. It returns a matrix of I values (the individual contribution towards total explained variation) for all values from permutations randomizations. For each permutation, the values in each variable (i.e each column of iv) are randomized independently, and rdacca.hp is run on the randomized iv. As well as the randomized I matrix, the function returns a summary table listing the observed I values, the p value of I for the randomized dataset.

Value

a data.frame containing a summary table listing the observed individual contribution, the p value of individual contribution for the randomized dataset

Author(s)

Jiangshan Lai lai@ibcas.ac.cn

Examples

library(vegan)
data(mite)
data(mite.env)
#Hellinger-transform the species dataset for RDA
mite.hel <- decostand(mite, "hellinger")
permu.hp(mite.hel,mite.env,method="RDA",type="adjR2",permutations=10)

Plot for a rdacca.hp object

Description

Plot for a rdacca.hp object

Usage

## S3 method for class 'rdaccahp'
plot(x, plot.perc = FALSE, color = NULL, ...)

Arguments

x

A rdacca.hp object.

plot.perc

Logical;if TRUE, the bar plot (based on ggplot2 package) of the percentage to individual effects of variables or groups towards total explained variation, the default is FALSE to show plot with original individual effects.

color

Color of variables.

...

unused

Value

a ggplot object

Author(s)

Jiangshan Lai lai@njfu.edu.cn

Examples

library(vegan)
data(mite)
data(mite.env)
mite.hel <- decostand(mite, "hellinger")
avc<-rdacca.hp(mite.hel,mite.env,method="RDA",type="adjR2")
plot(avc)
plot(avc, plot.perc=TRUE)
avc<-rdacca.hp(mite.hel,mite.env[,1:3],method="RDA",type="adjR2",var.part=TRUE)
plot(avc,color = c("#8DD3C7", "#FFFFB3", "#BEBADA"))

Hierarchical and Variation Partitioning for Canonical Analysis Without Limiting the Number of Predictors (Matrices)

Description

Hierarchical and Variation Partitioning for Canonical Analysis Without Limiting the Number of Predictors (Matrices)

Usage

rdacca.hp(
  dv,
  iv,
  method = c("RDA", "dbRDA", "CCA"),
  type = c("adjR2", "R2"),
  scale = FALSE,
  add = FALSE,
  sqrt.dist = FALSE,
  n.perm = 1000,
  var.part = FALSE
)

Arguments

dv

Response variable, either a numeric vector, matrix or data frame. If method="dbRDA", dv should be of class "dist".

iv

Predictorsrepresented in either a data frame or a list of data frames. If it is a data frame, the relative importance of each column of the data frame will be evaluated; if it is a list, the relative importance of each element (matrix) will be evaluated.

method

Type of canonical analysis to be performed, should be a character string, either "RDA", "dbRDA" or "CCA", the default is "RDA". If the response variable (dv) is a numerical vector and method="RDA", the hierarchical and variation partitioning for the classical multiple regression is implemented.If response variable (dv) is of class "dist", "dbRDA" will be chosen automatically.

type

The type of total explained variation, either "R2" or "adjR2", in which "R2" is unadjusted R-square and "adjR2" is adjusted R-square, the default is "adjR2". The adjusted R-square is calculated using Ezekiel's formula (Ezekiel 1930) for RDA and dbRDA, while permutation procedure is used for CCA (Peres-Neto et al. 2006).

scale

Logical; If the columns of dv should be standardized to unit variance when method="RDA" is applied.

add

Logical; Specifies whether a constant should be added to the non-diagonal values to euclidify dissimilarities (see dbrda function in vegan for details). Choice "lingoes" (or TRUE) uses the recommended method of Legendre & Anderson (1999: "method 1") and "cailliez" uses their "method 2". The argument has an effect only when method="dbRDA".

sqrt.dist

Logical, Specifies whether the square root of dissimilarities should be taken. This often euclidifies dissimilarities. The argument has an effect only when method="dbRDA"(see dbrda function in vegan for details).

n.perm

Integer; Number of permutations for computing the adjusted R-square for CCA. The argument has an effect only when method="CCA".

var.part

Logical; If TRUE, the result of variation partitioning (2^N-1 fractions for N predictors or matrices) is shown, the default is FALSE.

Details

This function conducts variation partitioning and hierarchical partitioning to calculate the unique, average shared (referred as to "common") and individual contributions of each predictor (or matrix) towards explained variation (R-square) on canonical analysis (RDA,CCA and dbRDA). Variation partitioning should be conducted before hierarchical partitioning. The former emphasizes unique and common variation among predictors, the latter emphasizes the overall importance of each predictor (or group of predictors). This function simultaneously implements variation and hierarchical partitioning for single- and multiple-response models without limiting in the number of predictors / matrices of predictors.

Value

a list containing

Method_Type

The type of canonical analysis and whether the raw or adjusted R2 waswere used in the analysis.

Total_explained_variation

The explained variation for the full model (raw or adjusted R2).

Var.part

If var.part=TRUE, a matrix containing the value and percentage of all commonality (2^N-1 for N predictors or matrices).

Hier.part

A matrix containing unique, average shared, individual effects and percentage of individual effects towards total explained variation for each predictor or matrix.

Author(s)

Jiangshan Lai lai@njfu.edu.cn

References

Examples

library(vegan)
data(mite)
data(mite.env)
data(mite.xy)
data(mite.pcnm)
#Hellinger-transform the species dataset for RDA
mite.hel <- decostand(mite, "hellinger")
rdacca.hp(mite.hel,mite.env,method="RDA",type="adjR2")
rdacca.hp(vegdist(mite),mite.env,method="dbRDA",type="adjR2")
rdacca.hp(mite,mite.env,method="CCA",type="adjR2")
iv <- list(env=mite.env,xy=mite.xy,pcnm=mite.pcnm)
rdacca.hp(mite.hel,iv,method="RDA",var.part = TRUE)
rdacca.hp(vegdist(mite),iv,method="dbRDA",var.part = TRUE)
rdacca.hp(mite,iv,method="CCA",var.part = TRUE)