FS.wrda {douconca}R Documentation

Forward selection of predictor variables using wrda or cca0

Description

Forward selection of predictor variables using wrda or cca0

Usage

## S3 method for class 'wrda'
FS(
  mod,
  ...,
  consider = NULL,
  permutations = 999,
  n_axes = "all",
  initial_model = "1",
  factor2categories = TRUE,
  test = TRUE,
  threshold_P = 0.1,
  PvalAdjustMethod = "holm",
  max_step = 10,
  verbose = FALSE
)

Arguments

mod

initial wrda or cca0 model with at least on predictor variable,

...

unused.

consider

character vector of names in mod$data to consider for addition.

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: "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.

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 names in consider may include transformations of predictor variables, such as log(.), if consider does not include factors or if factor2categories=FALSE. If consider does include factors, such transformations give in a error in the default setting (factor2categories=TRUE).

Value

list with three elements: final... with selected variables and model_final and process with account of the selection process If is.numeric(n_axes), then the variance in the returned table is the sum of the n_axes eigenvalues of the current model (all variables so far included).

Examples

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

[Package douconca version 1.2.3 Index]