fast.adonis: Calculate R2 for analysis of variance using distance matrices

fast.adonisR Documentation

Calculate R2 for analysis of variance using distance matrices

Description

fast.adonis is a R function that is used for analysis of variance using distance matrices. It can be used for both weighted and unweighted data. For unweighted data, it performs similarly with R functions 'adonis' and 'adonis2' from package(vegan). Besides a permutation test, fast.adonis provides a standard error for R2. The standard error can by computed by within cluster bootstraps or bootstrapping samples by weights. For unweighted data, fast.adonis does not provide permutation tests.

Usage

fast.adonis(
  formula,
  data = NULL,
  permutations = 999,
  boot.times = 100,
  boot.se = "WCB",
  boot.sample.size = NULL,
  weights = NULL,
  order_list = NULL,
  by = "terms",
  parallel = getOption("mc.cores")
)

Arguments

formula

Model Formula. The LHS must be a matrix that is computed from a dissimilarity matrix. For example, given a Bray Curtis dissimilarity matrix D, LHS= -0.5*D^2. The RHS defines the independent variables. These can be continuous variables or factors.

data

the data frame for the independent variables.

permutations

number of permutations

boot.times

times for bootstrapping

boot.se

the name of any method for bootstraps. Bootstraps are used to calculate standard errors for R2. 'boot.se = WCB' is within cluster bootstrap. Clusters are first created by weights.'boot.se = AS' is booting samples directly by weights. By default, 'boot.se = WCB'.

boot.sample.size

sample size for bootstrap

weights

If weights is NULL or a vector of 1s, fast.adonis conducts both permutations and bootstraps. Otherwise, fast.adonis' does not conduct permutations.

order_list

a list of different orders of input variables. For example, an input formula is RHS ~ A+B+C. The order_list can be list(c(3,2,1),c(2,3,1)). The output will be three tabs. The first is the analysis table for formula, RHS ~ A+B+C. The second is the table for formula, RHS ~ C+B+A. The last is the table for formula, RHS ~ B+C+A.

by

'by=terms' will assess significance for each term (sequentially from first to last). 'by=margin' will assess the marginal effects of the terms (each marginal term analysis in a model without all other variables). If 'by=margin' is set, "order_list" will be set to NULL.

parallel

number of parallel processes. With parallel = 1 uses ordinary, non-parallel processing. The parallel processing is done with the parallel package.

Value

An anova table


jennylsl/fast.adonis documentation built on May 6, 2022, 12:27 a.m.