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