rm_multicol: rm_multicol

View source: R/06_rm_multicol.R

rm_multicolR Documentation

rm_multicol

Description

rm_multicol calculates the average of each variable and removes those variables highly correlated

Usage

rm_multicol(
  dir2process = NULL,
  yrs2use = NULL,
  multicol_cutoff = 0.7,
  cores2use = 1,
  filename = "",
  ...
)

Arguments

dir2process

Character. Directory where the SpatRaster objects are stored. All the .tif files in the directory will be read in to be used

yrs2use

Numeric. A numeric vector with the years (layers positions) of the time series to be used (e.g. yrs2use = 2:21). Optional. Default (= NULL) uses all years

multicol_cutoff

Numeric. Cutoff value of (Pearson's) correlation. Optional. Default is 0.70

cores2use

Numeric. Number of cores to use for parallelization. Optional. Default is 1 (no parallelization)

filename

Character. Output filename. Optional

...

Optional. Arguments for removeCollinearity()

Details

Firstly, after reading in all .tif files in 'dir2process', if they are multiband (time series), averages are calculated. Secondly, it creates a SpatRaster object with those (averaged) variables which have a Pearson's correlation coefficient below 'multicol_cutoff'. See removeCollinearity for further arguments and functionalities

Value

SpatRaster object

Author(s)

Xavier Rotllan-Puig

References

Leroy B, Meynard CN, Bellard C, Courchamp F (2015). “virtualspecies, an R package to generate virtual species distributions”. Ecography. doi: 10.1111/ecog.01388

See Also

removeCollinearity

Examples


dirctry <- paste0(system.file(package='LPDynR'), "/extdata")  # directory with variables to process
rm_multicol(dir2process = dirctry,
            multicol_cutoff = 0.7,
            plot = TRUE)


LPDynR documentation built on Sept. 13, 2024, 1:10 a.m.