R/dim_reduce.R
dim_reduce.Rd
Select environmental variables that have pairwise Pearson correlation lower than a user-defined threshold. NOTE that it only works on numeric variables, does not work on categorical variables.
dim_reduce(
img_stack = NULL,
threshold = 0.5,
preferred_vars = NULL,
samples = NULL
)
(stars
or RasterStack
)
The image stack to work on.
(numeric
) The threshold number of Pearson
correlation that indicates two variables are strongly correlated.
The default is 0.5.
(vector
of character
) The preferred
variables in order in dimension reduction. The preferred variables
will move to the beginning before the reduction. So make sure they are
placed in order. Furthermore, setting preferred_vars does not guarantee
they can survive. For example, one preferred variable that is placed later
has strong correlation with former preferred variable.
(sf
or sp
) The samples to reduce
dimension.
If not NULL
, it can take sf
, sfc
,
SpatialPointsDataFrame
, SpatialPoints
, etc.
If NULL
, the whole raster stack would be used.
The default is NULL
.
(ReducedImageStack
) A list of
threshold (numeric
) The threshold set in function inputs
img_reduced (stars
) The image stack after dimension reduction
cors_original (data.frame
) A table of Pearson
correlations between all variables.
cors_reduced (data.frame
) A table of Pearson
correlations between variables after dimension reduction.