gwpca_df_mc {heterogen} | R Documentation |
Perform GWPCA from data.frame with spatial structure.
Description
gwpca_df is an R function that performs Generalized Weighted Principal Component Analysis (GWPCA) on a given dataset. This function allow to calculate the environmental heterogeneity from data.frame with spatial structure.
Usage
gwpca_df_mc(
datadf,
bandwidth = 0.2,
tolerance = 5,
nprocess = 10000,
parallel = FALSE,
ncores = 2,
normalized = FALSE,
method = "iter",
dirds = "rds"
)
Arguments
datadf |
The input data matrix for which GWPCA needs to be performed. It should contain numerical values only. Rows represent cells, and columns represent bioclimatic variables. |
bandwidth |
The bandwidth for the spatial weighting function. |
tolerance |
The tolerance for spatial weight computation. |
nprocess |
(Optional) The number of iterations for calculating the principal components. Default is set to 1000. |
parallel |
(Optional) A logical value indicating whether to run the computation in parallel. If |
ncores |
(Optional) The number of cores to be used for parallel computation. Only applicable if |
normalized |
(Optional) A logical value indicating whether the input data should be normalized before performing GWPCA. Default is |
method |
The method used for GWPCA computation. It can take one of the following values. |
dirds |
(Optional) The directory where the results will be saved in RDS format. Default is |
Value
A matrix of eigenvalues
Examples
path_csv <- system.file("extdata","south.csv", package="heterogen")
south_csv <- rio::import(path_csv)
# notice: south_csv object contains x,y (lot/lat coordinates)
# and environmental variables
north_het <- gwpca_df_mc(as.matrix(south_csv), parallel = TRUE,
ncores = 2, bandwidth = 0.1, tolerance = 10)