GLcenfa: Climate-niche factor analysis for reference study area

GLcenfaR Documentation

Climate-niche factor analysis for reference study area

Description

This function is used to facilitate comparisons between species in the same study area. It speeds up the computation of multiple CNFAs or ENFAs by calculating the global covariance matrix as a first step, which can then be fed into the cnfa or enfa functions as their first argument. This saves the user from having to calculate the global covariance matrix for each species, which can take quite a bit of time.

Usage

GLcenfa(
  x,
  center = TRUE,
  scale = TRUE,
  filename = "",
  progress = FALSE,
  parallel = FALSE,
  n = 1,
  cl = NULL,
  keep.open = FALSE,
  ...
)

## S4 method for signature 'Raster'
GLcenfa(
  x,
  center = TRUE,
  scale = TRUE,
  filename = "",
  progress = FALSE,
  parallel = FALSE,
  n = 1,
  cl = NULL,
  keep.open = FALSE,
  ...
)

Arguments

x

Raster* object, typically a brick or stack of p environmental raster layers

center

logical or numeric. If TRUE, centering is done by subtracting the layer means (omitting NAs), and if FALSE, no centering is done. If center is a numeric vector with length equal to the nlayers(x), then each layer of x has the corresponding value from center subtracted from it

scale

logical or numeric. If TRUE, scaling is done by dividing the (centered) layers of x by their standard deviations if center is TRUE, and the root mean square otherwise. If scale is FALSE, no scaling is done. If scale is a numeric vector with length equal to nlayers(x), each layer of x is divided by the corresponding value. Scaling is done after centering

filename

character. Optional filename to save the RasterBrick output to file. If this is not provided, a temporary file will be created for large x

progress

logical. If TRUE, messages and progress bar will be printed

parallel

logical. If TRUE then multiple cores are utilized

n

numeric. Number of CPU cores to utilize for parallel processing

cl

optional cluster object

keep.open

logical. If TRUE and parallel = TRUE, the cluster object will not be closed after the function has finished

...

Additional arguments for writeRaster

Details

If there is too much correlation between the layers of x, the covariance matrix will be singular, which will lead to later problems in computing the overall marginalities, sensitivities, or specializations of species. In this case, a warning will be issued, suggesting the removal of correlated variables or a transformation of the data.

Value

Returns an S4 object of class GLcenfa with the following components:

global_ras

Raster* x of p layers, possibly centered and scaled

cov

Global p x p covariance matrix

See Also

cnfa, enfa

Examples

glc <- GLcenfa(x = climdat.hist)


rinnan/CENFA documentation built on July 19, 2023, 12:58 p.m.