#' Reduce potentially problematic multicollinearity by removing variables until
#' the variance inflation factors (VIFs) of all predictor variables are below
#' a user-defined value.
#'
#' @description Removes the variable that contributed the least to a default
#' Maxent model and had a VIF greater than a user-defined value until all
#' variables used in the species distribution model have VIFs less than the
#' user-defined value.
#'
#' @param predictor_vars raster stack of variables to be used as potential
#' predictor variables
#'
#' @param maxVIF numeric value that denotes the maximum allowed VIF value among
#' predictor variables.
#'
#' @return A raster stack of predictor variables that has been reduced
#' to limit potential problems with multicollinearity.
#'
#' @importFrom usdm vif
#'
#'
#' @keywords VIF multicollinearity SDM
#' Function to automatically select SDM variables
select_sdmVariables <- function(predictor_vars, maxVIF){
vv <- predictor_vars
while(max(usdm::vif(vv)$VIF) >= maxVIF){
vv <- remove_singleVariables(pred_vars = vv, th = maxVIF)
}
return(vv)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.