Learn R Programming

douconca (version 1.2.3)

FS.dcca: Forward selection of traits or environmental variables using dc-CA.

Description

Forward selection of traits or environmental variables using dc-CA.

Usage

# S3 method for dcca
FS(
  mod,
  ...,
  select = c("traits", "env"),
  consider,
  permutations = 999,
  n_axes = "all",
  initial_model = "1",
  factor2categories = TRUE,
  test = TRUE,
  threshold_P = 0.1,
  PvalAdjustMethod = "holm",
  max_step = 10,
  verbose = FALSE
)

Value

list with three elements: final... with selected variables, model_final, and process with account of the selection process

Arguments

mod

dc-CA model.

...

unused.

select

Character, the default "traits" selects trait variables based on the environmental model of mod. Set select = "e" to select environmental variables based on the trait model of mod.

consider

character vector of names considered for addition, either trait names in mod$data$dataTraits or environmental variable names in in mod$data$dataEnv. The names may include transformations of predictor variables, such as log(.), if consider does not include factors or if factor2categories=FALSE. If consider includes factors, such transformations give in a error in the default setting (factor2categories=TRUE).

permutations

a list of control values for the permutations as returned by the function how, or the number of permutations required (default 999), or a permutation matrix where each row gives the permuted indices.

n_axes

number of eigenvalues to select upon. The sum of n_axes eigenvalues is taken as criterion. Default "full" for selection without dimension reduction to n_axes. If n_axes =1, selection is on the first eigenvalue for selection of variables that form an optimal one-dimensional model.

initial_model

character specifying what should be inside Condition(). Default: "1" (nothing, the intercept only). Examples: With selection of environmental varialbles, "region" for a within-region analysis or "A*B" for a within analysis specified by the interaction of factors A and B, with region, A, B in the data. Analogously, a trait or trait factor can be the initial model.

factor2categories

logical, default TRUE, to convert factors to their categories (set(s) of indicator values). If FALSE, the selection uses, the fit of a factor divided by its number of categories minus 1.

test

logical; default: TRUE.

threshold_P

significance level, after adjustment for testing multiplicity, for addition of a variable to the model.

PvalAdjustMethod

method for correction for multiple testing in p.adjust, default "holm", which is an improved version Bonferroni.

max_step

maximal number of variables selected.

verbose

show progress, default: TRUE.

Details

The selection is on the basis of the additional fit (inertia) of a variable given the variables already in the model.

The function FS does not implement the max test and may thus be liberal. It is recommended to test the final model (element model_ final of the returned object) by anova.

Examples

Run this code
data("dune_trait_env")

# rownames are carried forward in results
rownames(dune_trait_env$comm) <- dune_trait_env$comm$Sites
abun <- dune_trait_env$comm[, -1] # must delete "Sites"

mod <- dc_CA(formulaEnv = abun ~ Moist + Mag,
             formulaTraits = ~ F + R + N + L,
             dataEnv = dune_trait_env$envir,
             dataTraits = dune_trait_env$traits,
             verbose = FALSE)

# selection of traits with environmental model of mod (~ Moist+Mag)
out1 <- FS(mod, consider = c("F", "R", "N", "L"), 
           select = "traits", verbose = FALSE) 

names(out1)
out1$finalWithOneExtra
out1$model_final

# selection of environmental variables with trait model of mod (~ F + R + N + L)
out2 <- FS(mod, consider =  c("A1", "Moist", "Mag", "Use", "Manure"), 
           select= "env", verbose = FALSE) 

names(out2)
out2$finalWithOneExtra
out2$model_final

# selection of environmental variables without a trait model 
# i.e. with a single constraint
mod3 <- cca0(mod$data$Y ~ Moist, data = mod$data$dataEnv)
out3 <- FS(mod3, consider = c("A1", "Moist", "Mag", "Use", "Manure"), 
           threshold_P = 0.05)

out3$finalWithOneExtra
out3$model_final

# selection of traits without an environmental model 
#                         i.e. with a single constraint
tY <- t(mod$data$Y)

mod4 <- cca0(tY ~ L, data = mod$data$dataTraits)

names(mod$data$dataTraits)
out4 <- FS(mod4, 
           consider =  c("SLA", "Height", "LDMC", "Seedmass", "Lifespan", 
                         "F", "R", "N", "L"))

out4$finalWithOneExtra
out4$model_final

Run the code above in your browser using DataLab