Learn R Programming

usdm (version 2.1-7)

exclude: Excluding variables specified in a VIF object

Description

Phisically exclude the collinear variables which are identified using vifcor or vifstep from a set of variables.

Usage

exclude(x, vif, ...)

Value

an object of class same as x (i.e. RasterStack or RasterBrick or data.frame or matrix)

Arguments

x

explanatory variables (predictors), defined as a raster object (RasterStack or RasterBrick), or as a matrix, or as a data.frame.

vif

an object of class VIF, resulted from vifcor or vifstep functions.

...

additional argument as in vifstep

Details

Before using this function, you should execute one of vifstep or vifcor which detect collinearity based on calculating variance inflation factor (VIF) statistics. If vif is missing, then vifstep is called.

References

IF you used this method, please cite the following article for which this package is developed:

Naimi, B., Hamm, N.A.S., Groen, T.A., Skidmore, A.K., and Toxopeus, A.G. 2014. Where is positional uncertainty a problem for species distribution modelling?, Ecography 37 (2): 191-203.

See Also

vif

Examples

Run this code
if (FALSE) {
file <- system.file("external/spain.tif", package="usdm")

r <- rast(file) # reading a RasterBrick object including 10 raster layers in Spain

r 

vif(r) # calculates vif for the variables in r

v1 <- vifcor(r, th=0.9) # identify collinear variables that should be excluded

v1

re1 <- exclude(r,v1) # exclude the collinear variables that were identified in 
# the previous step

re1

v2 <- vifstep(r, th=10) # identify collinear variables that should be excluded

v2

re2 <- exclude(r, v2) # exclude the collinear variables that were identified in 
# the previous step

re2

re3 <- exclude(r) # first, vifstep is called 


re3
}

Run the code above in your browser using DataLab