library(knitr)
library(dismo)
library(gbm)
library(randomForest)
library(ranger) # for the Random Forest
library(terra)
terraOptions(tempdir='big_data/temp')
library(sf)
library(tidyverse)
Nasua nasua Variable Selection
Variable Selection for Nasua nasua, using the data generated in the previous step.
- R Libraries
28 Predictors
bio1
: Annual Mean Temperature, from Bioclimatic variables (WorldClim V2.1)bio2
: Mean Diurnal Range (Mean of monthly (max temp - min temp)), from Bioclimatic variables (WorldClim V2.1)bio3
: Isothermality (BIO2/BIO7) (×100), from Bioclimatic variables (WorldClim V2.1)bio4
: Temperature Seasonality (standard deviation ×100), from Bioclimatic variables (WorldClim V2.1)bio5
: Max Temperature of Warmest Month, from Bioclimatic variables (WorldClim V2.1)bio6
: Min Temperature of Coldest Month, from Bioclimatic variables (WorldClim V2.1)bio7
: Temperature Annual Range (BIO5-BIO6), from Bioclimatic variables (WorldClim V2.1)bio8
: Mean Temperature of Wettest Quarter, from Bioclimatic variables (WorldClim V2.1)bio9
: Mean Temperature of Driest Quarter, from Bioclimatic variables (WorldClim V2.1)bio10
: Mean Temperature of Warmest Quarter, from Bioclimatic variables (WorldClim V2.1)bio11
: Mean Temperature of Coldest Quarter, from Bioclimatic variables (WorldClim V2.1)bio12
: Annual Precipitation, from Bioclimatic variables (WorldClim V2.1)bio13
: Precipitation of Wettest Month, from Bioclimatic variables (WorldClim V2.1)bio14
: Precipitation of Driest Month, from Bioclimatic variables (WorldClim V2.1)bio15
: Precipitation Seasonality (Coefficient of Variation), from Bioclimatic variables (WorldClim V2.1)bio16
: Precipitation of Wettest Quarter, from Bioclimatic variables (WorldClim V2.1)bio17
: Precipitation of Driest Quarter, from Bioclimatic variables (WorldClim V2.1)bio18
: Precipitation of Warmest Quarter, from Bioclimatic variables (WorldClim V2.1)bio19
: Precipitation of Coldest Quarter, from Bioclimatic variables (WorldClim V2.1)elev
: Elevation (WorldClim V2.1 SRTM elevation data), from Bioclimatic variables (WorldClim V2.1)urban
: Urban and Built-up Lands, from Land cover LC1 (MODIS TERRA LandCover_Type_Yearly_500m (MCD12Q1))barren
: Barren, from Land cover LC1 (MODIS TERRA LandCover_Type_Yearly_500m (MCD12Q1))water
: Water Bodies, from Land cover LC1 (MODIS TERRA LandCover_Type_Yearly_500m (MCD12Q1))savanna
: Savannas, from Land cover LC1 (MODIS TERRA LandCover_Type_Yearly_500m (MCD12Q1))woodysavanna
: Woody savannas, from Land cover LC1 (MODIS TERRA LandCover_Type_Yearly_500m (MCD12Q1))wetland
: Permanent Wetlands, from Land cover LC1 (MODIS TERRA LandCover_Type_Yearly_500m (MCD12Q1))grass
: Grasslands, from Land cover LC1 (MODIS TERRA LandCover_Type_Yearly_500m (MCD12Q1))npp
: Net Primary Production (NPP) (MODIS TERRA Net_PP_GapFil_Yearly_500m (M*D17A3HGF))tree
: Percentage of Tree Cover, from Vegetation Continuous Fields (MODIS TERRA Veg_Cont_Fields_Yearly_250m (MOD44B))nontree
: Percentage of No Tree Cover, from Vegetation Continuous Fields (MODIS TERRA Veg_Cont_Fields_Yearly_250m (MOD44B))nonveg
: Percentage of Non Tree Vegetation Cover, from Vegetation Continuous Fields (MODIS TERRA Veg_Cont_Fields_Yearly_250m (MOD44B))
Code
<- rast('big_data/bio_high.tif')
bio <- rast('big_data/elev_high.tif')
elev <- rast('big_data/urban_high.tif') %>% resample(., elev)
urban <- rast('big_data/barren_high.tif') %>% resample(., elev)
barren <- rast('big_data/water_high.tif') %>% resample(., elev)
water <- rast('big_data/savanna_high.tif') %>% resample(., elev)
savanna <- rast('big_data/woodysavanna_high.tif') %>% resample(., elev)
woodysavanna <- rast('big_data/wetland_high.tif') %>% resample(., elev)
wetland <- rast('big_data/grass_high.tif') %>% resample(., elev)
grass <- rast('big_data/npp_high.tif') %>% resample(., elev)
npp names(npp) <- 'npp'
<- rast('big_data/tree_high.tif') %>% resample(., elev)
tree <- rast('big_data/nontree_high.tif') %>% resample(., elev)
nontree <- rast('big_data/nonveg_high.tif') %>% resample(., elev)
nonveg
<- c(bio, elev, urban, barren, water,
env
savanna, woodysavanna, wetland, %>% scale()
grass, npp, tree, nontree, nonveg)
rm(bio, elev, urban, barren, water,
savanna, woodysavanna, wetland,
grass, npp, tree, nontree, nonveg)
gc()
Nasua nasua’ preferences
We will use the data from both periods
Code
<- readRDS('data/species_POPA_data/PA_nnasua_time1_blobs.rds')%>% ungroup()
PA_time1 <- readRDS('data/species_POPA_data/PA_nnasua_time2_blobs.rds')%>% ungroup()
PA_time2
%>% st_drop_geometry() %>% head() %>% kable() PA_time1
ID | presence | temporalSpan | effort | blobArea |
---|---|---|---|---|
1 | 1 | 5589 days | 93771 | 2761279588 [m^2] |
2 | 0 | 270 days | 381 | 160668368 [m^2] |
3 | 0 | 527 days | 507 | 13742467 [m^2] |
4 | 0 | 31 days | 676 | 3581363 [m^2] |
5 | 1 | 2208 days | 51168 | 435868381 [m^2] |
6 | 0 | 0 days | 360 | 65695043 [m^2] |
Code
%>% st_drop_geometry() %>% head() %>% kable() PA_time2
ID | presence | temporalSpan | effort | blobArea |
---|---|---|---|---|
1 | 0 | 92 days | 95 | 3998173 [m^2] |
2 | 1 | 92 days | 92 | 3998173 [m^2] |
3 | 0 | 276 days | 269 | 10776792 [m^2] |
4 | 0 | 92 days | 95 | 3998173 [m^2] |
5 | 1 | 92 days | 3231 | 147932384 [m^2] |
6 | 1 | 184 days | 177 | 6948021 [m^2] |
Presence-absence data for the second period
Preparation of data for the tests
Code
# combine pre and pos datasets
<- st_join(PA_time1, PA_time2 %>% dplyr::select(presence), left = T) %>%
PA.data group_by(ID) %>%
mutate(presence=max(presence.x, presence.y, na.rm = T))
# calculate area, coordinates, and extract env predictors for each blob
<- st_coordinates(st_centroid(PA.data)) %>% as_tibble()
PA.coords <- as.numeric(PA.data$blobArea)
PA.area
<- terra::extract(x = env, y = vect(PA.data),
PA.env fun = mean, rm.na=T) %>%
mutate(across(where(is.numeric), ~ifelse(is.nan(.), NA, .)))
## the data
<- data.frame(PA.coords,
PA area = PA.area,
presabs = PA.data$presence,
env = PA.env)
Correlation between variables
Code
%>% filter(!if_any(everything(), is.na)) %>% dplyr::select(-c(1:5)) %>% cor() %>% kable() PA
env.bio_1 | env.bio_2 | env.bio_3 | env.bio_4 | env.bio_5 | env.bio_6 | env.bio_7 | env.bio_8 | env.bio_9 | env.bio_10 | env.bio_11 | env.bio_12 | env.bio_13 | env.bio_14 | env.bio_15 | env.bio_16 | env.bio_17 | env.bio_18 | env.bio_19 | env.elev | env.urban | env.barren | env.water | env.savanna | env.woodysavanna | env.wetland | env.grass | env.npp | env.tree | env.nontree | env.nonveg | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
env.bio_1 | 1.0000000 | 0.9277685 | 0.9680772 | 0.2307470 | 0.3634981 | -0.0951485 | 0.2746619 | 0.4118926 | -0.1070184 | -0.2463900 | 0.2045213 | -0.2089985 | 0.6945268 | -0.6845689 | 0.8431389 | 0.9127796 | -0.5574188 | 0.8656259 | 0.9064203 | -0.6672470 | -0.2199917 | -0.0988993 | 0.2970331 | 0.0157981 | -0.0178632 | 0.1717186 | -0.0952232 | -0.5597867 | 0.2240506 | 0.2062536 | 0.3363748 |
env.bio_2 | 0.9277685 | 1.0000000 | 0.8165906 | 0.1075245 | 0.1188005 | -0.0142668 | 0.1113807 | 0.1634706 | -0.0229253 | -0.3061136 | 0.1963059 | -0.1434531 | 0.4374044 | -0.3765883 | 0.9281506 | 0.7803705 | -0.3280903 | 0.8630663 | 0.7864866 | -0.8299466 | -0.2426688 | -0.1149203 | 0.2763437 | 0.0455453 | 0.0059932 | 0.2431852 | -0.1858529 | -0.6187896 | 0.2406395 | 0.2166631 | 0.3296479 |
env.bio_3 | 0.9680772 | 0.8165906 | 1.0000000 | 0.3259163 | 0.4848414 | -0.0862766 | 0.3152193 | 0.5419459 | -0.0982183 | -0.2458973 | 0.2525386 | -0.2802071 | 0.8211485 | -0.8416269 | 0.7325133 | 0.9543484 | -0.6895251 | 0.7810742 | 0.9355039 | -0.5441296 | -0.1766341 | -0.0771973 | 0.3212806 | -0.0055106 | -0.0356177 | 0.0992988 | -0.0863876 | -0.4406327 | 0.2522378 | 0.1850997 | 0.3456002 |
env.bio_4 | 0.2307470 | 0.1075245 | 0.3259163 | 1.0000000 | 0.7697691 | 0.7195441 | -0.4505835 | 0.7897426 | 0.7175210 | 0.3221163 | 0.7402330 | -0.5344230 | 0.5338214 | -0.4328267 | -0.0489799 | 0.4499365 | -0.6074777 | 0.0880539 | 0.3581213 | -0.2316853 | 0.0159292 | -0.1427406 | 0.3069321 | -0.4263131 | -0.1084147 | -0.1130280 | -0.1652261 | 0.2228391 | 0.5550972 | -0.0621585 | 0.2637806 |
env.bio_5 | 0.3634981 | 0.1188005 | 0.4848414 | 0.7697691 | 1.0000000 | 0.1873097 | 0.1478717 | 0.9786573 | 0.1769194 | 0.3501940 | 0.4335205 | -0.3416387 | 0.6839703 | -0.6703316 | 0.0004906 | 0.4999338 | -0.6356556 | 0.2278849 | 0.4294807 | -0.0316409 | 0.0445628 | -0.1593074 | 0.2457074 | -0.3591374 | -0.0754648 | -0.1285543 | 0.1192867 | 0.0732885 | 0.3146959 | 0.0111147 | 0.2166840 |
env.bio_6 | -0.0951485 | -0.0142668 | -0.0862766 | 0.7195441 | 0.1873097 | 1.0000000 | -0.8746471 | 0.1881482 | 0.9964870 | 0.1761052 | 0.7688182 | -0.5222235 | 0.1060483 | 0.1135350 | -0.1837474 | 0.1253199 | -0.2910181 | -0.1386426 | 0.0230732 | -0.2932452 | -0.0364798 | -0.0480476 | 0.2863280 | -0.3565638 | -0.0936928 | -0.0002935 | -0.3410927 | 0.2860967 | 0.5876459 | -0.0182868 | 0.2489975 |
env.bio_7 | 0.2746619 | 0.1113807 | 0.3152193 | -0.4505835 | 0.1478717 | -0.8746471 | 1.0000000 | 0.1455048 | -0.8872850 | -0.1179562 | -0.5677000 | 0.3637339 | 0.2293253 | -0.3953841 | 0.2278896 | 0.1230539 | 0.0066533 | 0.2619221 | 0.1867343 | 0.2580057 | 0.0373240 | -0.0025900 | -0.1561542 | 0.2429381 | 0.0735001 | -0.0444759 | 0.3032344 | -0.2380475 | -0.4243439 | 0.0426928 | -0.1363232 |
env.bio_8 | 0.4118926 | 0.1634706 | 0.5419459 | 0.7897426 | 0.9786573 | 0.1881482 | 0.1455048 | 1.0000000 | 0.1783178 | 0.3072965 | 0.4548494 | -0.4161515 | 0.7139923 | -0.7222646 | 0.0371262 | 0.5697294 | -0.6982123 | 0.2514146 | 0.4978131 | -0.0735110 | 0.0636457 | -0.1553539 | 0.2695250 | -0.3166474 | -0.0585876 | -0.1564683 | 0.0376607 | 0.0834781 | 0.3369544 | -0.0021094 | 0.2275318 |
env.bio_9 | -0.1070184 | -0.0229253 | -0.0982183 | 0.7175210 | 0.1769194 | 0.9964870 | -0.8872850 | 0.1783178 | 1.0000000 | 0.1760919 | 0.7694968 | -0.5173054 | 0.0944417 | 0.1243957 | -0.1905535 | 0.1136467 | -0.2810418 | -0.1510809 | 0.0117426 | -0.2924391 | -0.0366887 | -0.0505332 | 0.2804922 | -0.3593879 | -0.0946451 | -0.0003621 | -0.3486109 | 0.2977312 | 0.5871058 | -0.0262272 | 0.2427548 |
env.bio_10 | -0.2463900 | -0.3061136 | -0.2458973 | 0.3221163 | 0.3501940 | 0.1761052 | -0.1179562 | 0.3072965 | 0.1760919 | 1.0000000 | -0.1256464 | -0.0827932 | -0.0937538 | 0.1139535 | -0.4535522 | -0.2379504 | -0.0220895 | -0.0386619 | -0.3600452 | 0.2518724 | 0.2617832 | -0.1299675 | -0.1532953 | -0.2420074 | -0.0106526 | -0.0554615 | 0.0994479 | 0.2626821 | -0.0447537 | -0.1895589 | -0.1940213 |
env.bio_11 | 0.2045213 | 0.1963059 | 0.2525386 | 0.7402330 | 0.4335205 | 0.7688182 | -0.5677000 | 0.4548494 | 0.7694968 | -0.1256464 | 1.0000000 | -0.6408949 | 0.4522777 | -0.2363703 | 0.0194468 | 0.4631666 | -0.5753058 | 0.0249800 | 0.3802550 | -0.3926181 | -0.0959995 | -0.0360959 | 0.4112421 | -0.3482173 | -0.0579890 | -0.0341574 | -0.2920978 | 0.1263147 | 0.6163044 | 0.0485094 | 0.3631482 |
env.bio_12 | -0.2089985 | -0.1434531 | -0.2802071 | -0.5344230 | -0.3416387 | -0.5222235 | 0.3637339 | -0.4161515 | -0.5173054 | -0.0827932 | -0.6408949 | 1.0000000 | -0.3687343 | 0.3259618 | 0.1702596 | -0.5332588 | 0.8003318 | -0.0745264 | -0.3635566 | 0.3196728 | -0.0849807 | 0.0204207 | -0.4559694 | 0.3405011 | 0.0051159 | -0.0858233 | 0.3819510 | -0.1825077 | -0.6015148 | -0.0864016 | -0.3824726 |
env.bio_13 | 0.6945268 | 0.4374044 | 0.8211485 | 0.5338214 | 0.6839703 | 0.1060483 | 0.2293253 | 0.7139923 | 0.0944417 | -0.0937538 | 0.4522777 | -0.3687343 | 1.0000000 | -0.9127157 | 0.3237383 | 0.8344648 | -0.8297503 | 0.4765709 | 0.7668214 | -0.2104476 | -0.1099554 | -0.0015494 | 0.3433190 | -0.1472673 | -0.0848086 | -0.0657356 | -0.0084892 | -0.1492964 | 0.2964585 | 0.1473409 | 0.3316464 |
env.bio_14 | -0.6845689 | -0.3765883 | -0.8416269 | -0.4328267 | -0.6703316 | 0.1135350 | -0.3953841 | -0.7222646 | 0.1243957 | 0.1139535 | -0.2363703 | 0.3259618 | -0.9127157 | 1.0000000 | -0.3081329 | -0.8064516 | 0.8052880 | -0.4432812 | -0.7677597 | 0.1058742 | 0.0473841 | 0.0148215 | -0.2620952 | 0.0616427 | 0.0564150 | 0.0741740 | -0.0230030 | 0.1162072 | -0.1952645 | -0.0869051 | -0.2510543 |
env.bio_15 | 0.8431389 | 0.9281506 | 0.7325133 | -0.0489799 | 0.0004906 | -0.1837474 | 0.2278896 | 0.0371262 | -0.1905535 | -0.4535522 | 0.0194468 | 0.1702596 | 0.3237383 | -0.3081329 | 1.0000000 | 0.6208725 | -0.0737256 | 0.7699132 | 0.7046433 | -0.7249237 | -0.2729520 | -0.1012924 | 0.1337540 | 0.1749436 | 0.0061381 | 0.1864473 | -0.0801856 | -0.6339015 | 0.0609958 | 0.1713212 | 0.2109901 |
env.bio_16 | 0.9127796 | 0.7803705 | 0.9543484 | 0.4499365 | 0.4999338 | 0.1253199 | 0.1230539 | 0.5697294 | 0.1136467 | -0.2379504 | 0.4631666 | -0.5332588 | 0.8344648 | -0.8064516 | 0.6208725 | 1.0000000 | -0.8275524 | 0.7031109 | 0.9372507 | -0.6145115 | -0.1500558 | -0.0641372 | 0.4249134 | -0.1007138 | -0.0388713 | 0.1214282 | -0.2129549 | -0.3433415 | 0.4187299 | 0.1926602 | 0.4277087 |
env.bio_17 | -0.5574188 | -0.3280903 | -0.6895251 | -0.6074777 | -0.6356556 | -0.2910181 | 0.0066533 | -0.6982123 | -0.2810418 | -0.0220895 | -0.5753058 | 0.8003318 | -0.8297503 | 0.8052880 | -0.0737256 | -0.8275524 | 1.0000000 | -0.3431217 | -0.6877325 | 0.2626257 | -0.0045728 | 0.0090549 | -0.4447811 | 0.2534100 | 0.0538471 | -0.0209570 | 0.2134936 | -0.0171675 | -0.4890194 | -0.1224094 | -0.3930256 |
env.bio_18 | 0.8656259 | 0.8630663 | 0.7810742 | 0.0880539 | 0.2278849 | -0.1386426 | 0.2619221 | 0.2514146 | -0.1510809 | -0.0386619 | 0.0249800 | -0.0745264 | 0.4765709 | -0.4432812 | 0.7699132 | 0.7031109 | -0.3431217 | 1.0000000 | 0.6030993 | -0.5932420 | -0.1325791 | -0.0854560 | 0.1957556 | -0.0224175 | 0.0303643 | 0.2194431 | -0.0799501 | -0.5467745 | 0.1622566 | 0.1452967 | 0.2479591 |
env.bio_19 | 0.9064203 | 0.7864866 | 0.9355039 | 0.3581213 | 0.4294807 | 0.0230732 | 0.1867343 | 0.4978131 | 0.0117426 | -0.3600452 | 0.3802550 | -0.3635566 | 0.7668214 | -0.7677597 | 0.7046433 | 0.9372507 | -0.6877325 | 0.6030993 | 1.0000000 | -0.6138045 | -0.2184383 | -0.0579593 | 0.3513282 | 0.0298117 | -0.0538343 | 0.0817392 | -0.1339679 | -0.4222120 | 0.2793405 | 0.2046471 | 0.3658683 |
env.elev | -0.6672470 | -0.8299466 | -0.5441296 | -0.2316853 | -0.0316409 | -0.2932452 | 0.2580057 | -0.0735110 | -0.2924391 | 0.2518724 | -0.3926181 | 0.3196728 | -0.2104476 | 0.1058742 | -0.7249237 | -0.6145115 | 0.2626257 | -0.5932420 | -0.6138045 | 1.0000000 | 0.1939057 | 0.1056507 | -0.2768266 | 0.0679176 | 0.0033027 | -0.2224196 | 0.3587738 | 0.3987217 | -0.3934171 | -0.1110525 | -0.3183675 |
env.urban | -0.2199917 | -0.2426688 | -0.1766341 | 0.0159292 | 0.0445628 | -0.0364798 | 0.0373240 | 0.0636457 | -0.0366887 | 0.2617832 | -0.0959995 | -0.0849807 | -0.1099554 | 0.0473841 | -0.2729520 | -0.1500558 | -0.0045728 | -0.1325791 | -0.2184383 | 0.1939057 | 1.0000000 | -0.0113513 | -0.0629070 | -0.0503602 | 0.0548994 | -0.0616338 | -0.0789070 | 0.1355983 | -0.0391381 | -0.0759533 | -0.0996535 |
env.barren | -0.0988993 | -0.1149203 | -0.0771973 | -0.1427406 | -0.1593074 | -0.0480476 | -0.0025900 | -0.1553539 | -0.0505332 | -0.1299675 | -0.0360959 | 0.0204207 | -0.0015494 | 0.0148215 | -0.1012924 | -0.0641372 | 0.0090549 | -0.0854560 | -0.0579593 | 0.1056507 | -0.0113513 | 1.0000000 | -0.0121373 | -0.0370293 | -0.0153823 | -0.0118264 | -0.0243199 | -0.0791489 | -0.0552519 | -0.0807519 | 0.0969951 |
env.water | 0.2970331 | 0.2763437 | 0.3212806 | 0.3069321 | 0.2457074 | 0.2863280 | -0.1561542 | 0.2695250 | 0.2804922 | -0.1532953 | 0.4112421 | -0.4559694 | 0.3433190 | -0.2620952 | 0.1337540 | 0.4249134 | -0.4447811 | 0.1957556 | 0.3513282 | -0.2768266 | -0.0629070 | -0.0121373 | 1.0000000 | -0.1945147 | -0.0935378 | 0.1394400 | -0.1367836 | -0.3666331 | 0.7312940 | 0.7510133 | 0.9155486 |
env.savanna | 0.0157981 | 0.0455453 | -0.0055106 | -0.4263131 | -0.3591374 | -0.3565638 | 0.2429381 | -0.3166474 | -0.3593879 | -0.2420074 | -0.3482173 | 0.3405011 | -0.1472673 | 0.0616427 | 0.1749436 | -0.1007138 | 0.2534100 | -0.0224175 | 0.0298117 | 0.0679176 | -0.0503602 | -0.0370293 | -0.1945147 | 1.0000000 | -0.0895060 | -0.1647097 | -0.1329225 | -0.1422405 | -0.4728660 | 0.1121871 | -0.2116674 |
env.woodysavanna | -0.0178632 | 0.0059932 | -0.0356177 | -0.1084147 | -0.0754648 | -0.0936928 | 0.0735001 | -0.0585876 | -0.0946451 | -0.0106526 | -0.0579890 | 0.0051159 | -0.0848086 | 0.0564150 | 0.0061381 | -0.0388713 | 0.0538471 | 0.0303643 | -0.0538343 | 0.0033027 | 0.0548994 | -0.0153823 | -0.0935378 | -0.0895060 | 1.0000000 | -0.0826217 | -0.0950113 | -0.0010226 | -0.0703156 | -0.1242026 | -0.0928695 |
env.wetland | 0.1717186 | 0.2431852 | 0.0992988 | -0.1130280 | -0.1285543 | -0.0002935 | -0.0444759 | -0.1564683 | -0.0003621 | -0.0554615 | -0.0341574 | -0.0858233 | -0.0657356 | 0.0741740 | 0.1864473 | 0.1214282 | -0.0209570 | 0.2194431 | 0.0817392 | -0.2224196 | -0.0616338 | -0.0118264 | 0.1394400 | -0.1647097 | -0.0826217 | 1.0000000 | -0.1324671 | -0.3579071 | 0.2280567 | 0.2518196 | 0.2815450 |
env.grass | -0.0952232 | -0.1858529 | -0.0863876 | -0.1652261 | 0.1192867 | -0.3410927 | 0.3032344 | 0.0376607 | -0.3486109 | 0.0994479 | -0.2920978 | 0.3819510 | -0.0084892 | -0.0230030 | -0.0801856 | -0.2129549 | 0.2134936 | -0.0799501 | -0.1339679 | 0.3587738 | -0.0789070 | -0.0243199 | -0.1367836 | -0.1329225 | -0.0950113 | -0.1324671 | 1.0000000 | -0.1315989 | -0.4713395 | 0.2060164 | -0.1088121 |
env.npp | -0.5597867 | -0.6187896 | -0.4406327 | 0.2228391 | 0.0732885 | 0.2860967 | -0.2380475 | 0.0834781 | 0.2977312 | 0.2626821 | 0.1263147 | -0.1825077 | -0.1492964 | 0.1162072 | -0.6339015 | -0.3433415 | -0.0171675 | -0.5467745 | -0.4222120 | 0.3987217 | 0.1355983 | -0.0791489 | -0.3666331 | -0.1422405 | -0.0010226 | -0.3579071 | -0.1315989 | 1.0000000 | -0.0514793 | -0.5282644 | -0.4655389 |
env.tree | 0.2240506 | 0.2406395 | 0.2522378 | 0.5550972 | 0.3146959 | 0.5876459 | -0.4243439 | 0.3369544 | 0.5871058 | -0.0447537 | 0.6163044 | -0.6015148 | 0.2964585 | -0.1952645 | 0.0609958 | 0.4187299 | -0.4890194 | 0.1622566 | 0.2793405 | -0.3934171 | -0.0391381 | -0.0552519 | 0.7312940 | -0.4728660 | -0.0703156 | 0.2280567 | -0.4713395 | -0.0514793 | 1.0000000 | 0.2829091 | 0.7448210 |
env.nontree | 0.2062536 | 0.2166631 | 0.1850997 | -0.0621585 | 0.0111147 | -0.0182868 | 0.0426928 | -0.0021094 | -0.0262272 | -0.1895589 | 0.0485094 | -0.0864016 | 0.1473409 | -0.0869051 | 0.1713212 | 0.1926602 | -0.1224094 | 0.1452967 | 0.2046471 | -0.1110525 | -0.0759533 | -0.0807519 | 0.7510133 | 0.1121871 | -0.1242026 | 0.2518196 | 0.2060164 | -0.5282644 | 0.2829091 | 1.0000000 | 0.7915296 |
env.nonveg | 0.3363748 | 0.3296479 | 0.3456002 | 0.2637806 | 0.2166840 | 0.2489975 | -0.1363232 | 0.2275318 | 0.2427548 | -0.1940213 | 0.3631482 | -0.3824726 | 0.3316464 | -0.2510543 | 0.2109901 | 0.4277087 | -0.3930256 | 0.2479591 | 0.3658683 | -0.3183675 | -0.0996535 | 0.0969951 | 0.9155486 | -0.2116674 | -0.0928695 | 0.2815450 | -0.1088121 | -0.4655389 | 0.7448210 | 0.7915296 | 1.0000000 |
Variable Importance analyses
Simple GLM
Code
<- PA %>%
presabs.glm ::select(-c(1,2,3,5)) %>%
dplyrfilter(!is.na(env.elev)&!is.na(env.bio_1))
<- glm(presabs ~.,
glm.fullfamily = "binomial",
data = presabs.glm)
summary(glm.full)
Call:
glm(formula = presabs ~ ., family = "binomial", data = presabs.glm)
Deviance Residuals:
Min 1Q Median 3Q Max
-2.9411 -0.7118 -0.2832 0.8501 2.7646
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) -1.220e+02 1.268e+02 -0.962 0.336191
env.bio_1 2.068e+01 7.414e+00 2.790 0.005278 **
env.bio_2 2.001e+01 8.120e+00 2.465 0.013713 *
env.bio_3 -4.800e+01 1.577e+01 -3.043 0.002339 **
env.bio_4 -6.146e-01 1.880e+00 -0.327 0.743698
env.bio_5 -4.680e+00 1.519e+00 -3.081 0.002064 **
env.bio_6 -1.877e+00 1.527e+00 -1.230 0.218850
env.bio_7 6.954e-01 5.638e-01 1.233 0.217399
env.bio_8 5.318e+00 2.119e+00 2.510 0.012080 *
env.bio_9 3.470e+00 2.011e+00 1.725 0.084451 .
env.bio_10 -8.813e-01 4.301e-01 -2.049 0.040455 *
env.bio_11 -1.889e-02 5.247e-01 -0.036 0.971286
env.bio_12 6.526e+00 1.963e+00 3.324 0.000887 ***
env.bio_13 -3.026e+00 1.358e+00 -2.229 0.025816 *
env.bio_14 -2.300e+01 8.595e+00 -2.677 0.007437 **
env.bio_15 1.619e+05 9.427e+05 0.172 0.863623
env.bio_16 -2.714e+05 1.580e+06 -0.172 0.863618
env.bio_17 -2.307e+05 1.343e+06 -0.172 0.863613
env.bio_18 2.675e-01 9.097e-01 0.294 0.768753
env.bio_19 -1.730e+00 1.368e+00 -1.265 0.205919
env.elev -1.383e+00 9.514e-01 -1.454 0.146024
env.urban 8.859e-01 3.034e-01 2.919 0.003506 **
env.barren -6.111e+02 6.400e+02 -0.955 0.339672
env.water -4.209e-01 2.489e-01 -1.691 0.090901 .
env.savanna 4.336e-01 2.248e-01 1.928 0.053795 .
env.woodysavanna 1.082e-01 2.400e-01 0.451 0.651936
env.wetland -2.363e-01 1.399e-01 -1.689 0.091182 .
env.grass 1.459e-01 3.068e-01 0.475 0.634437
env.npp 3.387e-02 2.974e-01 0.114 0.909338
env.tree 6.086e-01 5.136e-01 1.185 0.236028
env.nontree -7.827e-01 4.629e-01 -1.691 0.090836 .
env.nonveg 6.077e-01 5.866e-01 1.036 0.300211
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
(Dispersion parameter for binomial family taken to be 1)
Null deviance: 737.83 on 538 degrees of freedom
Residual deviance: 530.80 on 507 degrees of freedom
AIC: 594.8
Number of Fisher Scoring iterations: 14
Code
step(glm.full) # step might not work with gam so glm
Start: AIC=594.8
presabs ~ env.bio_1 + env.bio_2 + env.bio_3 + env.bio_4 + env.bio_5 +
env.bio_6 + env.bio_7 + env.bio_8 + env.bio_9 + env.bio_10 +
env.bio_11 + env.bio_12 + env.bio_13 + env.bio_14 + env.bio_15 +
env.bio_16 + env.bio_17 + env.bio_18 + env.bio_19 + env.elev +
env.urban + env.barren + env.water + env.savanna + env.woodysavanna +
env.wetland + env.grass + env.npp + env.tree + env.nontree +
env.nonveg
Df Deviance AIC
- env.bio_11 1 530.80 592.80
- env.npp 1 530.82 592.82
- env.bio_15 1 530.83 592.83
- env.bio_16 1 530.83 592.83
- env.bio_17 1 530.83 592.83
- env.bio_18 1 530.89 592.89
- env.bio_4 1 530.91 592.91
- env.woodysavanna 1 531.01 593.01
- env.grass 1 531.03 593.03
- env.nonveg 1 531.88 593.88
- env.tree 1 532.23 594.23
- env.bio_6 1 532.34 594.34
- env.bio_7 1 532.35 594.35
- env.bio_19 1 532.61 594.61
<none> 530.80 594.80
- env.elev 1 532.89 594.89
- env.nontree 1 533.68 595.68
- env.bio_9 1 533.87 595.87
- env.water 1 533.98 595.98
- env.barren 1 534.47 596.47
- env.wetland 1 534.55 596.55
- env.savanna 1 534.60 596.60
- env.bio_10 1 535.19 597.19
- env.bio_13 1 536.24 598.24
- env.bio_8 1 537.24 599.24
- env.bio_2 1 537.32 599.32
- env.bio_14 1 538.48 600.48
- env.bio_1 1 538.91 600.91
- env.bio_3 1 540.65 602.65
- env.bio_5 1 540.74 602.74
- env.urban 1 542.38 604.38
- env.bio_12 1 542.70 604.70
Step: AIC=592.8
presabs ~ env.bio_1 + env.bio_2 + env.bio_3 + env.bio_4 + env.bio_5 +
env.bio_6 + env.bio_7 + env.bio_8 + env.bio_9 + env.bio_10 +
env.bio_12 + env.bio_13 + env.bio_14 + env.bio_15 + env.bio_16 +
env.bio_17 + env.bio_18 + env.bio_19 + env.elev + env.urban +
env.barren + env.water + env.savanna + env.woodysavanna +
env.wetland + env.grass + env.npp + env.tree + env.nontree +
env.nonveg
Df Deviance AIC
- env.npp 1 530.82 590.82
- env.bio_15 1 530.83 590.83
- env.bio_16 1 530.83 590.83
- env.bio_17 1 530.83 590.83
- env.bio_18 1 530.89 590.89
- env.bio_4 1 530.91 590.91
- env.woodysavanna 1 531.01 591.01
- env.grass 1 531.03 591.03
- env.nonveg 1 531.88 591.88
- env.tree 1 532.24 592.24
- env.bio_6 1 532.36 592.36
- env.bio_7 1 532.43 592.43
- env.bio_19 1 532.62 592.62
<none> 530.80 592.80
- env.elev 1 532.89 592.89
- env.nontree 1 533.72 593.72
- env.bio_9 1 533.91 593.91
- env.water 1 534.01 594.01
- env.barren 1 534.48 594.48
- env.wetland 1 534.57 594.57
- env.savanna 1 534.63 594.63
- env.bio_13 1 536.71 596.71
- env.bio_10 1 536.77 596.77
- env.bio_8 1 537.27 597.27
- env.bio_2 1 537.46 597.46
- env.bio_14 1 538.51 598.51
- env.bio_1 1 538.91 598.91
- env.bio_3 1 540.88 600.88
- env.bio_5 1 540.90 600.90
- env.urban 1 542.38 602.38
- env.bio_12 1 542.72 602.72
Step: AIC=590.82
presabs ~ env.bio_1 + env.bio_2 + env.bio_3 + env.bio_4 + env.bio_5 +
env.bio_6 + env.bio_7 + env.bio_8 + env.bio_9 + env.bio_10 +
env.bio_12 + env.bio_13 + env.bio_14 + env.bio_15 + env.bio_16 +
env.bio_17 + env.bio_18 + env.bio_19 + env.elev + env.urban +
env.barren + env.water + env.savanna + env.woodysavanna +
env.wetland + env.grass + env.tree + env.nontree + env.nonveg
Df Deviance AIC
- env.bio_15 1 530.85 588.85
- env.bio_16 1 530.85 588.85
- env.bio_17 1 530.85 588.85
- env.bio_18 1 530.90 588.90
- env.bio_4 1 530.95 588.95
- env.woodysavanna 1 531.01 589.01
- env.grass 1 531.05 589.05
- env.nonveg 1 531.98 589.98
- env.bio_6 1 532.46 590.46
- env.bio_7 1 532.49 590.49
- env.tree 1 532.51 590.51
- env.bio_19 1 532.71 590.71
<none> 530.82 590.82
- env.elev 1 533.09 591.09
- env.nontree 1 533.80 591.80
- env.bio_9 1 534.20 592.20
- env.water 1 534.29 592.29
- env.barren 1 534.49 592.49
- env.savanna 1 534.63 592.63
- env.wetland 1 534.73 592.73
- env.bio_13 1 536.71 594.71
- env.bio_10 1 536.84 594.84
- env.bio_2 1 537.76 595.76
- env.bio_8 1 537.99 595.99
- env.bio_14 1 538.84 596.84
- env.bio_1 1 539.28 597.28
- env.bio_3 1 540.95 598.95
- env.bio_5 1 541.28 599.28
- env.bio_12 1 542.76 600.76
- env.urban 1 543.77 601.77
Step: AIC=588.85
presabs ~ env.bio_1 + env.bio_2 + env.bio_3 + env.bio_4 + env.bio_5 +
env.bio_6 + env.bio_7 + env.bio_8 + env.bio_9 + env.bio_10 +
env.bio_12 + env.bio_13 + env.bio_14 + env.bio_16 + env.bio_17 +
env.bio_18 + env.bio_19 + env.elev + env.urban + env.barren +
env.water + env.savanna + env.woodysavanna + env.wetland +
env.grass + env.tree + env.nontree + env.nonveg
Df Deviance AIC
- env.bio_18 1 530.93 586.93
- env.bio_4 1 530.97 586.97
- env.woodysavanna 1 531.05 587.05
- env.grass 1 531.08 587.08
- env.nonveg 1 532.02 588.02
- env.bio_6 1 532.48 588.48
- env.tree 1 532.52 588.52
- env.bio_7 1 532.59 588.59
- env.bio_19 1 532.74 588.74
<none> 530.85 588.85
- env.elev 1 533.10 589.10
- env.nontree 1 533.84 589.84
- env.bio_9 1 534.21 590.21
- env.water 1 534.33 590.33
- env.bio_16 1 534.36 590.36
- env.barren 1 534.56 590.56
- env.savanna 1 534.65 590.65
- env.wetland 1 534.75 590.75
- env.bio_10 1 536.85 592.85
- env.bio_13 1 537.14 593.14
- env.bio_2 1 537.97 593.97
- env.bio_8 1 537.99 593.99
- env.bio_14 1 539.04 595.04
- env.bio_1 1 539.35 595.35
- env.bio_3 1 541.27 597.27
- env.bio_5 1 541.33 597.33
- env.bio_12 1 543.30 599.30
- env.urban 1 543.80 599.80
- env.bio_17 1 548.90 604.90
Step: AIC=586.93
presabs ~ env.bio_1 + env.bio_2 + env.bio_3 + env.bio_4 + env.bio_5 +
env.bio_6 + env.bio_7 + env.bio_8 + env.bio_9 + env.bio_10 +
env.bio_12 + env.bio_13 + env.bio_14 + env.bio_16 + env.bio_17 +
env.bio_19 + env.elev + env.urban + env.barren + env.water +
env.savanna + env.woodysavanna + env.wetland + env.grass +
env.tree + env.nontree + env.nonveg
Df Deviance AIC
- env.bio_4 1 531.05 585.05
- env.woodysavanna 1 531.15 585.15
- env.grass 1 531.18 585.18
- env.nonveg 1 532.10 586.10
- env.bio_6 1 532.51 586.51
- env.tree 1 532.64 586.64
- env.bio_7 1 532.67 586.67
<none> 530.93 586.93
- env.elev 1 533.18 587.18
- env.nontree 1 533.95 587.95
- env.bio_9 1 534.22 588.22
- env.water 1 534.41 588.41
- env.bio_16 1 534.41 588.41
- env.barren 1 534.60 588.60
- env.wetland 1 534.81 588.81
- env.savanna 1 534.88 588.88
- env.bio_19 1 534.93 588.93
- env.bio_10 1 536.86 590.86
- env.bio_13 1 537.15 591.15
- env.bio_2 1 537.97 591.97
- env.bio_8 1 538.07 592.07
- env.bio_14 1 539.04 593.04
- env.bio_1 1 539.62 593.62
- env.bio_3 1 541.27 595.27
- env.bio_5 1 541.45 595.45
- env.bio_12 1 543.35 597.35
- env.urban 1 544.05 598.05
- env.bio_17 1 548.94 602.94
Step: AIC=585.05
presabs ~ env.bio_1 + env.bio_2 + env.bio_3 + env.bio_5 + env.bio_6 +
env.bio_7 + env.bio_8 + env.bio_9 + env.bio_10 + env.bio_12 +
env.bio_13 + env.bio_14 + env.bio_16 + env.bio_17 + env.bio_19 +
env.elev + env.urban + env.barren + env.water + env.savanna +
env.woodysavanna + env.wetland + env.grass + env.tree + env.nontree +
env.nonveg
Df Deviance AIC
- env.grass 1 531.27 583.27
- env.woodysavanna 1 531.29 583.29
- env.nonveg 1 532.19 584.19
- env.bio_6 1 532.55 584.55
- env.tree 1 532.78 584.78
<none> 531.05 585.05
- env.elev 1 533.22 585.22
- env.bio_7 1 533.48 585.48
- env.nontree 1 533.97 585.97
- env.bio_9 1 534.41 586.41
- env.bio_16 1 534.58 586.58
- env.water 1 534.61 586.61
- env.barren 1 534.75 586.75
- env.savanna 1 535.01 587.01
- env.bio_19 1 535.16 587.16
- env.wetland 1 535.28 587.28
- env.bio_13 1 537.76 589.76
- env.bio_10 1 538.11 590.11
- env.bio_2 1 538.35 590.35
- env.bio_14 1 539.06 591.06
- env.bio_1 1 539.63 591.63
- env.bio_3 1 541.42 593.42
- env.bio_5 1 541.46 593.46
- env.bio_8 1 541.48 593.48
- env.urban 1 544.07 596.07
- env.bio_12 1 545.45 597.45
- env.bio_17 1 554.49 606.49
Step: AIC=583.27
presabs ~ env.bio_1 + env.bio_2 + env.bio_3 + env.bio_5 + env.bio_6 +
env.bio_7 + env.bio_8 + env.bio_9 + env.bio_10 + env.bio_12 +
env.bio_13 + env.bio_14 + env.bio_16 + env.bio_17 + env.bio_19 +
env.elev + env.urban + env.barren + env.water + env.savanna +
env.woodysavanna + env.wetland + env.tree + env.nontree +
env.nonveg
Df Deviance AIC
- env.woodysavanna 1 531.41 581.41
- env.nonveg 1 532.67 582.67
- env.bio_6 1 532.70 582.70
- env.tree 1 532.81 582.81
- env.elev 1 533.26 583.26
<none> 531.27 583.27
- env.bio_7 1 533.51 583.51
- env.nontree 1 534.02 584.02
- env.bio_9 1 534.50 584.50
- env.bio_16 1 534.64 584.64
- env.water 1 534.98 584.98
- env.barren 1 535.18 585.18
- env.bio_19 1 535.30 585.30
- env.savanna 1 536.05 586.05
- env.wetland 1 536.38 586.38
- env.bio_13 1 538.06 588.06
- env.bio_10 1 538.17 588.17
- env.bio_2 1 538.96 588.96
- env.bio_14 1 540.07 590.07
- env.bio_1 1 540.13 590.13
- env.bio_8 1 541.82 591.82
- env.bio_5 1 541.92 591.92
- env.bio_3 1 542.42 592.42
- env.urban 1 544.10 594.10
- env.bio_12 1 545.52 595.52
- env.bio_17 1 554.54 604.54
Step: AIC=581.41
presabs ~ env.bio_1 + env.bio_2 + env.bio_3 + env.bio_5 + env.bio_6 +
env.bio_7 + env.bio_8 + env.bio_9 + env.bio_10 + env.bio_12 +
env.bio_13 + env.bio_14 + env.bio_16 + env.bio_17 + env.bio_19 +
env.elev + env.urban + env.barren + env.water + env.savanna +
env.wetland + env.tree + env.nontree + env.nonveg
Df Deviance AIC
- env.bio_6 1 532.80 580.80
- env.tree 1 532.84 580.84
- env.nonveg 1 532.97 580.97
- env.elev 1 533.34 581.34
<none> 531.41 581.41
- env.bio_7 1 533.68 581.68
- env.nontree 1 534.35 582.35
- env.bio_9 1 534.61 582.61
- env.bio_16 1 534.71 582.71
- env.water 1 535.11 583.11
- env.bio_19 1 535.50 583.50
- env.barren 1 535.56 583.56
- env.savanna 1 536.05 584.05
- env.wetland 1 536.70 584.70
- env.bio_10 1 538.38 586.38
- env.bio_13 1 538.52 586.52
- env.bio_2 1 539.59 587.59
- env.bio_1 1 540.53 588.53
- env.bio_14 1 540.91 588.91
- env.bio_8 1 542.15 590.15
- env.bio_5 1 542.34 590.34
- env.bio_3 1 543.50 591.50
- env.urban 1 544.26 592.26
- env.bio_12 1 545.97 593.97
- env.bio_17 1 554.89 602.89
Step: AIC=580.8
presabs ~ env.bio_1 + env.bio_2 + env.bio_3 + env.bio_5 + env.bio_7 +
env.bio_8 + env.bio_9 + env.bio_10 + env.bio_12 + env.bio_13 +
env.bio_14 + env.bio_16 + env.bio_17 + env.bio_19 + env.elev +
env.urban + env.barren + env.water + env.savanna + env.wetland +
env.tree + env.nontree + env.nonveg
Df Deviance AIC
- env.tree 1 534.10 580.10
- env.bio_7 1 534.33 580.33
- env.nonveg 1 534.38 580.38
<none> 532.80 580.80
- env.elev 1 534.92 580.92
- env.nontree 1 535.99 581.99
- env.water 1 536.23 582.23
- env.bio_19 1 536.60 582.60
- env.savanna 1 537.04 583.04
- env.barren 1 537.05 583.05
- env.bio_9 1 537.16 583.16
- env.bio_16 1 537.22 583.22
- env.wetland 1 537.58 583.58
- env.bio_10 1 539.58 585.58
- env.bio_13 1 539.62 585.62
- env.bio_1 1 540.64 586.64
- env.bio_14 1 542.09 588.09
- env.bio_2 1 542.52 588.52
- env.bio_3 1 544.07 590.07
- env.bio_8 1 544.48 590.48
- env.bio_5 1 544.52 590.52
- env.urban 1 545.00 591.00
- env.bio_12 1 547.98 593.98
- env.bio_17 1 559.33 605.33
Step: AIC=580.1
presabs ~ env.bio_1 + env.bio_2 + env.bio_3 + env.bio_5 + env.bio_7 +
env.bio_8 + env.bio_9 + env.bio_10 + env.bio_12 + env.bio_13 +
env.bio_14 + env.bio_16 + env.bio_17 + env.bio_19 + env.elev +
env.urban + env.barren + env.water + env.savanna + env.wetland +
env.nontree + env.nonveg
Df Deviance AIC
- env.bio_7 1 535.94 579.94
- env.elev 1 536.02 580.02
<none> 534.10 580.10
- env.water 1 536.55 580.55
- env.savanna 1 537.76 581.76
- env.wetland 1 537.98 581.98
- env.bio_19 1 538.15 582.15
- env.bio_16 1 538.59 582.59
- env.bio_9 1 539.72 583.72
- env.bio_1 1 541.15 585.15
- env.bio_10 1 541.32 585.32
- env.bio_13 1 542.37 586.37
- env.bio_14 1 543.34 587.34
- env.bio_2 1 544.77 588.77
- env.barren 1 545.18 589.18
- env.bio_3 1 545.32 589.32
- env.bio_5 1 545.49 589.49
- env.bio_8 1 545.58 589.58
- env.urban 1 546.60 590.60
- env.nonveg 1 547.41 591.41
- env.bio_12 1 552.05 596.05
- env.nontree 1 556.67 600.67
- env.bio_17 1 566.22 610.22
Step: AIC=579.94
presabs ~ env.bio_1 + env.bio_2 + env.bio_3 + env.bio_5 + env.bio_8 +
env.bio_9 + env.bio_10 + env.bio_12 + env.bio_13 + env.bio_14 +
env.bio_16 + env.bio_17 + env.bio_19 + env.elev + env.urban +
env.barren + env.water + env.savanna + env.wetland + env.nontree +
env.nonveg
Df Deviance AIC
- env.elev 1 537.27 579.27
<none> 535.94 579.94
- env.water 1 538.11 580.11
- env.wetland 1 539.18 581.18
- env.bio_19 1 539.42 581.42
- env.savanna 1 539.95 581.95
- env.bio_1 1 541.65 583.65
- env.bio_16 1 541.84 583.84
- env.bio_10 1 542.14 584.14
- env.bio_9 1 542.22 584.22
- env.bio_13 1 542.41 584.41
- env.bio_5 1 545.73 587.73
- env.bio_8 1 546.19 588.19
- env.bio_14 1 546.40 588.40
- env.barren 1 547.20 589.20
- env.bio_3 1 547.36 589.36
- env.urban 1 547.72 589.72
- env.nonveg 1 548.73 590.73
- env.bio_2 1 550.51 592.51
- env.bio_12 1 552.19 594.19
- env.nontree 1 559.47 601.47
- env.bio_17 1 567.58 609.58
Step: AIC=579.27
presabs ~ env.bio_1 + env.bio_2 + env.bio_3 + env.bio_5 + env.bio_8 +
env.bio_9 + env.bio_10 + env.bio_12 + env.bio_13 + env.bio_14 +
env.bio_16 + env.bio_17 + env.bio_19 + env.urban + env.barren +
env.water + env.savanna + env.wetland + env.nontree + env.nonveg
Df Deviance AIC
<none> 537.27 579.27
- env.water 1 539.68 579.68
- env.bio_19 1 540.02 580.02
- env.wetland 1 541.08 581.08
- env.savanna 1 541.08 581.08
- env.bio_16 1 542.17 582.17
- env.bio_1 1 542.29 582.29
- env.bio_10 1 542.44 582.44
- env.bio_9 1 544.31 584.31
- env.bio_5 1 546.10 586.10
- env.bio_8 1 546.59 586.59
- env.bio_13 1 547.31 587.31
- env.barren 1 548.64 588.64
- env.bio_14 1 548.69 588.69
- env.urban 1 548.71 588.71
- env.bio_3 1 549.78 589.78
- env.nonveg 1 551.15 591.15
- env.bio_2 1 555.03 595.03
- env.bio_12 1 556.13 596.13
- env.nontree 1 562.25 602.25
- env.bio_17 1 569.29 609.29
Call: glm(formula = presabs ~ env.bio_1 + env.bio_2 + env.bio_3 + env.bio_5 +
env.bio_8 + env.bio_9 + env.bio_10 + env.bio_12 + env.bio_13 +
env.bio_14 + env.bio_16 + env.bio_17 + env.bio_19 + env.urban +
env.barren + env.water + env.savanna + env.wetland + env.nontree +
env.nonveg, family = "binomial", data = presabs.glm)
Coefficients:
(Intercept) env.bio_1 env.bio_2 env.bio_3 env.bio_5 env.bio_8
-122.0334 14.0910 28.1436 -49.7123 -3.7771 4.2779
env.bio_9 env.bio_10 env.bio_12 env.bio_13 env.bio_14 env.bio_16
0.6677 -0.7139 7.0507 -3.1310 -25.8005 -10.7271
env.bio_17 env.bio_19 env.urban env.barren env.water env.savanna
-18.5109 -1.4214 0.7897 -614.0368 -0.3299 0.3177
env.wetland env.nontree env.nonveg
-0.2031 -1.1967 1.1297
Degrees of Freedom: 538 Total (i.e. Null); 518 Residual
Null Deviance: 737.8
Residual Deviance: 537.3 AIC: 579.3
Boosted regression trees
Boosted regression trees were fitted using packages: gbm
and dismo
— specifically the gbm.step()
function (Hijmans et al., 2017)
Code
# cross-validation optimisation of a boosted regression tree model
<- gbm.step(data = PA,
brt gbm.x = 6:ncol(PA),
gbm.y = "presabs",
family = "bernoulli")
GBM STEP - version 2.9
Performing cross-validation optimisation of a boosted regression tree model
for NA and using a family of bernoulli
Using 545 observations and 31 predictors
creating 10 initial models of 50 trees
folds are stratified by prevalence
total mean deviance = 1.3663
tolerance is fixed at 0.0014
ntrees resid. dev.
50 1.2713
now adding trees...
100 1.2111
150 1.1706
200 1.1426
250 1.1206
300 1.1025
350 1.0877
400 1.0752
450 1.0656
500 1.0565
550 1.0499
600 1.042
650 1.0366
700 1.0312
750 1.0269
800 1.0225
850 1.0192
900 1.0161
950 1.0117
1000 1.0087
1050 1.0059
1100 1.0037
1150 1.0022
1200 1.0016
1250 0.9994
1300 0.9991
1350 0.9983
1400 0.9979
1450 0.9978
1500 0.9981
1550 0.9978
1600 0.9977
1650 0.9976
1700 0.9987
1750 0.9968
1800 0.9967
1850 0.9955
1900 0.9964
1950 0.9965
2000 0.9966
2050 0.9963
2100 0.9963
2150 0.9964
2200 0.996
2250 0.9959
2300 0.9956
2350 0.9959
mean total deviance = 1.366
mean residual deviance = 0.764
estimated cv deviance = 0.995 ; se = 0.047
training data correlation = 0.731
cv correlation = 0.569 ; se = 0.038
training data AUC score = 0.922
cv AUC score = 0.826 ; se = 0.022
elapsed time - 0.11 minutes
Code
summary(brt)
var rel.inf
env.nontree env.nontree 17.5928871
env.bio_10 env.bio_10 13.4379629
env.bio_13 env.bio_13 11.3103461
env.urban env.urban 10.5688152
env.bio_5 env.bio_5 6.4292307
env.grass env.grass 4.9087640
env.bio_7 env.bio_7 4.5415318
env.bio_8 env.bio_8 4.3201342
env.bio_9 env.bio_9 4.1736495
env.tree env.tree 2.6962604
env.npp env.npp 2.3169705
env.bio_19 env.bio_19 1.9970997
env.bio_14 env.bio_14 1.9688255
env.bio_16 env.bio_16 1.8024975
env.elev env.elev 1.5543143
env.bio_15 env.bio_15 1.4762665
env.savanna env.savanna 1.3464401
env.bio_12 env.bio_12 1.2741631
env.bio_4 env.bio_4 1.1078061
env.bio_2 env.bio_2 0.9875704
env.bio_17 env.bio_17 0.9012152
env.bio_3 env.bio_3 0.8142793
env.nonveg env.nonveg 0.5975114
env.bio_11 env.bio_11 0.5656003
env.bio_18 env.bio_18 0.5225713
env.woodysavanna env.woodysavanna 0.4742354
env.wetland env.wetland 0.1236958
env.bio_6 env.bio_6 0.1162681
env.water env.water 0.0730878
env.bio_1 env.bio_1 0.0000000
env.barren env.barren 0.0000000
Code
<- brt$contributions[1:6,] %>% pull(var)
variables_brt #exploration of shape of relationships
#gbm.plot(brt, n.plots = 12, plot.layout=c(6, 2))
Random forest
Code
<- PA %>%
presabs.rf ::select(-c(1,2,3,5)) %>%
dplyrmutate(presabs = as.factor(presabs))
<- randomForest(presabs ~ .,
rf data=presabs.rf,
importance=T,
nperm=2, # two permutations per tree to estimate importance
na.action=na.omit,
mtry= 1/3*ncol(presabs.rf)-1)
varImpPlot(rf, type=2)
Code
<- rf$importance %>% as_tibble(rownames = 'var') %>% arrange(desc(MeanDecreaseGini)) %>% head(n=6) %>% pull(var) variables_rf
Ranger
Code
<- PA %>%
presabs.ranger ::select(-c(1,2,3,5)) %>%
dplyrfilter(!if_any(everything(), is.na)) %>%
mutate(presabs = as.factor(presabs))
## Learn the model:
<- ranger(presabs ~ .,
ranger data = presabs.ranger,
num.trees = 150,
mtry = 1/3*ncol(presabs.ranger)-1,
min.node.size = 5,
max.depth = NULL,
write.forest = TRUE,
importance = "impurity")
# Get the variable importance
importance(ranger)
env.bio_1 env.bio_2 env.bio_3 env.bio_4
4.8710126 5.7534748 6.2222304 6.8403644
env.bio_5 env.bio_6 env.bio_7 env.bio_8
10.8069284 6.2467870 9.3548681 8.9145375
env.bio_9 env.bio_10 env.bio_11 env.bio_12
7.4783494 17.1915980 6.0545874 8.8358500
env.bio_13 env.bio_14 env.bio_15 env.bio_16
15.4474758 11.3579645 7.2062521 6.0903619
env.bio_17 env.bio_18 env.bio_19 env.elev
7.6264652 7.2550260 7.3659486 8.2135374
env.urban env.barren env.water env.savanna
11.9348489 0.1475352 1.0732435 5.1637631
env.woodysavanna env.wetland env.grass env.npp
4.6569940 1.8065060 5.9712772 13.1924531
env.tree env.nontree env.nonveg
8.0459004 23.4488548 7.0019669
Code
importance(ranger) %>%
as.data.frame(row.names = names(.)) %>%
setNames(c("Importance")) %>%
rownames_to_column("covariate") %>%
# mutate(covariate = case_when(
# covariate == "env.bio_1" ~ "Annual Mean Temperature",
# )) %>%
ggplot(aes(x = Importance, y = reorder(covariate, Importance))) +
ylab('')+
geom_point() + theme_bw()
Code
<- importance(ranger) %>% as_tibble(rownames = 'var') %>% arrange(desc(value)) %>% head(n=6) %>% pull(var) variables_ranger
Correlation
Correlation between the six more important variables detected.
- Boosted regression tree: env.nontree, env.bio_10, env.bio_13, env.urban, env.bio_5, env.grass
- Random forest: env.nontree, env.bio_10, env.bio_13, env.urban, env.bio_5, env.npp
- Ranger: env.nontree, env.bio_10, env.bio_13, env.npp, env.urban, env.bio_14
Code
<- unique(c(variables_brt, variables_rf, variables_ranger))
selectedVariables
%>%
PA filter(!if_any(everything(), is.na)) %>%
::select(selectedVariables) %>%
dplyrpairs()
Code
%>%
PA filter(!if_any(everything(), is.na)) %>%
::select(selectedVariables) %>%
dplyrcor() %>% kable()
env.nontree | env.bio_10 | env.bio_13 | env.urban | env.bio_5 | env.grass | env.npp | env.bio_14 | |
---|---|---|---|---|---|---|---|---|
env.nontree | 1.0000000 | -0.1895589 | 0.1473409 | -0.0759533 | 0.0111147 | 0.2060164 | -0.5282644 | -0.0869051 |
env.bio_10 | -0.1895589 | 1.0000000 | -0.0937538 | 0.2617832 | 0.3501940 | 0.0994479 | 0.2626821 | 0.1139535 |
env.bio_13 | 0.1473409 | -0.0937538 | 1.0000000 | -0.1099554 | 0.6839703 | -0.0084892 | -0.1492964 | -0.9127157 |
env.urban | -0.0759533 | 0.2617832 | -0.1099554 | 1.0000000 | 0.0445628 | -0.0789070 | 0.1355983 | 0.0473841 |
env.bio_5 | 0.0111147 | 0.3501940 | 0.6839703 | 0.0445628 | 1.0000000 | 0.1192867 | 0.0732885 | -0.6703316 |
env.grass | 0.2060164 | 0.0994479 | -0.0084892 | -0.0789070 | 0.1192867 | 1.0000000 | -0.1315989 | -0.0230030 |
env.npp | -0.5282644 | 0.2626821 | -0.1492964 | 0.1355983 | 0.0732885 | -0.1315989 | 1.0000000 | 0.1162072 |
env.bio_14 | -0.0869051 | 0.1139535 | -0.9127157 | 0.0473841 | -0.6703316 | -0.0230030 | 0.1162072 | 1.0000000 |
Code
tmpFiles(remove=T)