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)
Chrysocyon brachyurus Variable Selection
Variable Selection for Chrysocyon brachyurus, 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()
Chrysocyon brachyurus’ preferences
We will use the data from both periods
Code
<- readRDS('data/species_POPA_data/PA_cbrachyurus_time1_blobs.rds')%>% ungroup()
PA_time1 <- readRDS('data/species_POPA_data/PA_cbrachyurus_time2_blobs.rds')%>% ungroup()
PA_time2
%>% st_drop_geometry() %>% head() %>% kable() PA_time1
ID | presence | temporalSpan | effort | blobArea |
---|---|---|---|---|
1 | 0 | 1365 days | 1043 | 241873943 [m^2] |
2 | 0 | 1769 days | 2404 | 537081878 [m^2] |
3 | 0 | 6222 days | 11078 | 2241827859 [m^2] |
4 | 0 | 720 days | 1291 | 162791738 [m^2] |
5 | 0 | 1769 days | 1779 | 756798182 [m^2] |
6 | 0 | 304 days | 3300 | 19990863 [m^2] |
Code
%>% st_drop_geometry() %>% head() %>% kable() PA_time2
ID | presence | temporalSpan | effort | blobArea |
---|---|---|---|---|
1 | 0 | 510 days | 11095 | 2.229446e+09 [m^2] |
2 | 0 | 150 days | 12276 | 1.542295e+03 [m^2] |
3 | 0 | 407 days | 1585 | 1.049520e-01 [m^2] |
4 | 0 | 869 days | 1440 | 7.494574e+01 [m^2] |
5 | 0 | 70 days | 400 | 2.546836e+01 [m^2] |
6 | 0 | 756 days | 7164 | 2.398904e-01 [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.9296441 | 0.9683961 | 0.2245524 | 0.3650713 | -0.0974913 | 0.2598362 | 0.4133726 | -0.1088920 | -0.2171595 | 0.1956382 | -0.2049978 | 0.6915905 | -0.6813646 | 0.8361199 | 0.9132283 | -0.5533539 | 0.8696582 | 0.9064849 | -0.6579087 | -0.2201133 | -0.0977410 | 0.2893823 | -0.0024650 | 0.0280840 | 0.1505896 | -0.1029622 | -0.5423448 | 0.2241057 | 0.1944363 | 0.3216861 |
env.bio_2 | 0.9296441 | 1.0000000 | 0.8201186 | 0.1070940 | 0.1263286 | -0.0188141 | 0.1075105 | 0.1704404 | -0.0270968 | -0.2734955 | 0.1868085 | -0.1426003 | 0.4381869 | -0.3771548 | 0.9194218 | 0.7840670 | -0.3309997 | 0.8667005 | 0.7893311 | -0.8088566 | -0.2416197 | -0.1129521 | 0.2673516 | 0.0269795 | 0.0437261 | 0.2158389 | -0.1911302 | -0.5957826 | 0.2394162 | 0.2026016 | 0.3128536 |
env.bio_3 | 0.9683961 | 0.8201186 | 1.0000000 | 0.3145337 | 0.4841739 | -0.0902739 | 0.3019023 | 0.5416489 | -0.1019188 | -0.2194668 | 0.2423853 | -0.2688312 | 0.8182906 | -0.8385889 | 0.7284579 | 0.9531144 | -0.6805953 | 0.7863656 | 0.9351986 | -0.5387853 | -0.1778445 | -0.0766928 | 0.3146130 | -0.0212454 | 0.0151050 | 0.0830030 | -0.0941385 | -0.4287304 | 0.2510269 | 0.1763470 | 0.3326884 |
env.bio_4 | 0.2245524 | 0.1070940 | 0.3145337 | 1.0000000 | 0.7642354 | 0.7267723 | -0.4858212 | 0.7801517 | 0.7257054 | 0.3332077 | 0.7446606 | -0.5595604 | 0.5005643 | -0.4148608 | -0.0696912 | 0.4462757 | -0.6123342 | 0.0898132 | 0.3375557 | -0.2702648 | 0.0226405 | -0.1373670 | 0.3077364 | -0.4152737 | -0.1495779 | -0.1146293 | -0.1512988 | 0.2195306 | 0.5598284 | -0.0677038 | 0.2675771 |
env.bio_5 | 0.3650713 | 0.1263286 | 0.4841739 | 0.7642354 | 1.0000000 | 0.1933128 | 0.1171199 | 0.9784670 | 0.1835373 | 0.3598166 | 0.4346112 | -0.3516015 | 0.6733107 | -0.6659381 | -0.0034808 | 0.5031871 | -0.6367356 | 0.2330854 | 0.4266622 | -0.0644255 | 0.0457209 | -0.1574742 | 0.2459976 | -0.3587865 | -0.0619659 | -0.1330635 | 0.1157962 | 0.0741961 | 0.3196852 | 0.0073694 | 0.2150625 |
env.bio_6 | -0.0974913 | -0.0188141 | -0.0902739 | 0.7267723 | 0.1933128 | 1.0000000 | -0.8648488 | 0.1913458 | 0.9965494 | 0.1837194 | 0.7740640 | -0.5300579 | 0.0892696 | 0.1186764 | -0.1996677 | 0.1249108 | -0.3001855 | -0.1378122 | 0.0099549 | -0.3037383 | -0.0295608 | -0.0459756 | 0.2895092 | -0.3454885 | -0.1352915 | -0.0004524 | -0.3242425 | 0.2813411 | 0.5902548 | -0.0208942 | 0.2560326 |
env.bio_7 | 0.2598362 | 0.1075105 | 0.3019023 | -0.4858212 | 0.1171199 | -0.8648488 | 1.0000000 | 0.1220172 | -0.8782263 | -0.1345391 | -0.5756748 | 0.4185941 | 0.2440087 | -0.3840589 | 0.2496259 | 0.1033349 | 0.0482055 | 0.2443413 | 0.1945389 | 0.2985608 | 0.0225795 | -0.0051382 | -0.1606119 | 0.2264854 | 0.1850820 | -0.0391527 | 0.2617882 | -0.2260104 | -0.4273476 | 0.0504557 | -0.1488980 |
env.bio_8 | 0.4133726 | 0.1704404 | 0.5416489 | 0.7801517 | 0.9784670 | 0.1913458 | 0.1220172 | 1.0000000 | 0.1819016 | 0.3180265 | 0.4533295 | -0.4161798 | 0.7057661 | -0.7191324 | 0.0339333 | 0.5715997 | -0.6962200 | 0.2568050 | 0.4948495 | -0.1003456 | 0.0642175 | -0.1537781 | 0.2693363 | -0.3170436 | -0.0375880 | -0.1611847 | 0.0346935 | 0.0835534 | 0.3395489 | -0.0039337 | 0.2253595 |
env.bio_9 | -0.1088920 | -0.0270968 | -0.1019188 | 0.7257054 | 0.1835373 | 0.9965494 | -0.8782263 | 0.1819016 | 1.0000000 | 0.1840244 | 0.7748265 | -0.5272262 | 0.0770351 | 0.1295226 | -0.2067214 | 0.1137978 | -0.2912206 | -0.1496451 | -0.0013905 | -0.3043808 | -0.0294760 | -0.0483047 | 0.2836730 | -0.3479909 | -0.1389403 | -0.0005642 | -0.3307918 | 0.2925463 | 0.5897787 | -0.0290542 | 0.2499643 |
env.bio_10 | -0.2171595 | -0.2734955 | -0.2194668 | 0.3332077 | 0.3598166 | 0.1837194 | -0.1345391 | 0.3180265 | 0.1840244 | 1.0000000 | -0.1092807 | -0.1343382 | -0.0811383 | 0.1021154 | -0.4429341 | -0.1997582 | -0.0648619 | -0.0145843 | -0.3385074 | 0.1685297 | 0.2582501 | -0.1263971 | -0.1456711 | -0.2570984 | 0.0182359 | -0.0638922 | 0.0956723 | 0.2583383 | -0.0288362 | -0.1901205 | -0.1873301 |
env.bio_11 | 0.1956382 | 0.1868085 | 0.2423853 | 0.7446606 | 0.4346112 | 0.7740640 | -0.5756748 | 0.4533295 | 0.7748265 | -0.1092807 | 1.0000000 | -0.6357030 | 0.4318087 | -0.2273811 | -0.0001334 | 0.4547914 | -0.5733417 | 0.0224191 | 0.3619071 | -0.3934250 | -0.0896497 | -0.0345635 | 0.4128212 | -0.3398411 | -0.0967487 | -0.0340330 | -0.2794210 | 0.1254955 | 0.6191653 | 0.0444401 | 0.3673542 |
env.bio_12 | -0.2049978 | -0.1426003 | -0.2688312 | -0.5595604 | -0.3516015 | -0.5300579 | 0.4185941 | -0.4161798 | -0.5272262 | -0.1343382 | -0.6357030 | 1.0000000 | -0.3325137 | 0.3049036 | 0.1966475 | -0.5250598 | 0.8023981 | -0.0861157 | -0.3309889 | 0.3821173 | -0.0890791 | 0.0167159 | -0.4386322 | 0.3434812 | 0.0467406 | -0.0727980 | 0.3469681 | -0.1737652 | -0.5951082 | -0.0668483 | -0.3700583 |
env.bio_13 | 0.6915905 | 0.4381869 | 0.8182906 | 0.5005643 | 0.6733107 | 0.0892696 | 0.2440087 | 0.7057661 | 0.0770351 | -0.0811383 | 0.4318087 | -0.3325137 | 1.0000000 | -0.9118016 | 0.3261453 | 0.8255327 | -0.8073928 | 0.4789765 | 0.7641805 | -0.2005044 | -0.1124490 | -0.0021708 | 0.3366226 | -0.1551412 | -0.0112436 | -0.0695311 | -0.0158723 | -0.1472418 | 0.2873553 | 0.1459596 | 0.3206495 |
env.bio_14 | -0.6813646 | -0.3771548 | -0.8385889 | -0.4148608 | -0.6659381 | 0.1186764 | -0.3840589 | -0.7191324 | 0.1295226 | 0.1021154 | -0.2273811 | 0.3049036 | -0.9118016 | 1.0000000 | -0.3065325 | -0.8003439 | 0.7896644 | -0.4447706 | -0.7650724 | 0.1075528 | 0.0491570 | 0.0151001 | -0.2590556 | 0.0693126 | 0.0098816 | 0.0774311 | -0.0168947 | 0.1143688 | -0.1926304 | -0.0852376 | -0.2445389 |
env.bio_15 | 0.8361199 | 0.9194218 | 0.7284579 | -0.0696912 | -0.0034808 | -0.1996677 | 0.2496259 | 0.0339333 | -0.2067214 | -0.4429341 | -0.0001334 | 0.1966475 | 0.3261453 | -0.3065325 | 1.0000000 | 0.6102757 | -0.0543381 | 0.7628378 | 0.7072778 | -0.6630353 | -0.2740025 | -0.1002805 | 0.1226871 | 0.1672372 | 0.0462821 | 0.1653903 | -0.0906072 | -0.6102193 | 0.0503882 | 0.1630034 | 0.1918470 |
env.bio_16 | 0.9132283 | 0.7840670 | 0.9531144 | 0.4462757 | 0.5031871 | 0.1249108 | 0.1033349 | 0.5715997 | 0.1137978 | -0.1997582 | 0.4547914 | -0.5250598 | 0.8255327 | -0.8003439 | 0.6102757 | 1.0000000 | -0.8241800 | 0.7110844 | 0.9320639 | -0.6213394 | -0.1491519 | -0.0630686 | 0.4173645 | -0.1202489 | 0.0029894 | 0.1034344 | -0.2159955 | -0.3303117 | 0.4202314 | 0.1793595 | 0.4141109 |
env.bio_17 | -0.5533539 | -0.3309997 | -0.6805953 | -0.6123342 | -0.6367356 | -0.3001855 | 0.0482055 | -0.6962200 | -0.2912206 | -0.0648619 | -0.5733417 | 0.8023981 | -0.8073928 | 0.7896644 | -0.0543381 | -0.8241800 | 1.0000000 | -0.3509483 | -0.6692034 | 0.3091761 | -0.0078816 | 0.0078058 | -0.4383634 | 0.2711251 | 0.0293186 | -0.0121391 | 0.2074795 | -0.0198950 | -0.4936629 | -0.1095460 | -0.3848206 |
env.bio_18 | 0.8696582 | 0.8667005 | 0.7863656 | 0.0898132 | 0.2330854 | -0.1378122 | 0.2443413 | 0.2568050 | -0.1496451 | -0.0145843 | 0.0224191 | -0.0861157 | 0.4789765 | -0.4447706 | 0.7628378 | 0.7110844 | -0.3509483 | 1.0000000 | 0.6106291 | -0.5930138 | -0.1337635 | -0.0844168 | 0.1904426 | -0.0413308 | 0.0667723 | 0.1977084 | -0.0870639 | -0.5298813 | 0.1649284 | 0.1344020 | 0.2359080 |
env.bio_19 | 0.9064849 | 0.7893311 | 0.9351986 | 0.3375557 | 0.4266622 | 0.0099549 | 0.1945389 | 0.4948495 | -0.0013905 | -0.3385074 | 0.3619071 | -0.3309889 | 0.7641805 | -0.7650724 | 0.7072778 | 0.9320639 | -0.6692034 | 0.6106291 | 1.0000000 | -0.5894832 | -0.2207150 | -0.0580746 | 0.3417830 | 0.0150607 | 0.0015716 | 0.0673108 | -0.1438877 | -0.4089540 | 0.2748842 | 0.1941162 | 0.3490410 |
env.elev | -0.6579087 | -0.8088566 | -0.5387853 | -0.2702648 | -0.0644255 | -0.3037383 | 0.2985608 | -0.1003456 | -0.3043808 | 0.1685297 | -0.3934250 | 0.3821173 | -0.2005044 | 0.1075528 | -0.6630353 | -0.6213394 | 0.3091761 | -0.5930138 | -0.5894832 | 1.0000000 | 0.1776808 | 0.0973969 | -0.2664306 | 0.0973135 | 0.0062860 | -0.1804121 | 0.3347777 | 0.3623028 | -0.3968661 | -0.0874815 | -0.3009313 |
env.urban | -0.2201133 | -0.2416197 | -0.1778445 | 0.0226405 | 0.0457209 | -0.0295608 | 0.0225795 | 0.0642175 | -0.0294760 | 0.2582501 | -0.0896497 | -0.0890791 | -0.1124490 | 0.0491570 | -0.2740025 | -0.1491519 | -0.0078816 | -0.1337635 | -0.2207150 | 0.1776808 | 1.0000000 | -0.0109690 | -0.0607542 | -0.0470701 | 0.0318901 | -0.0606497 | -0.0753713 | 0.1344147 | -0.0366332 | -0.0745566 | -0.0958183 |
env.barren | -0.0977410 | -0.1129521 | -0.0766928 | -0.1373670 | -0.1574742 | -0.0459756 | -0.0051382 | -0.1537781 | -0.0483047 | -0.1263971 | -0.0345635 | 0.0167159 | -0.0021708 | 0.0151001 | -0.1002805 | -0.0630686 | 0.0078058 | -0.0844168 | -0.0580746 | 0.0973969 | -0.0109690 | 1.0000000 | -0.0116914 | -0.0361940 | -0.0154035 | -0.0116054 | -0.0235731 | -0.0790421 | -0.0543190 | -0.0802550 | 0.0973328 |
env.water | 0.2893823 | 0.2673516 | 0.3146130 | 0.3077364 | 0.2459976 | 0.2895092 | -0.1606119 | 0.2693363 | 0.2836730 | -0.1456711 | 0.4128212 | -0.4386322 | 0.3366226 | -0.2590556 | 0.1226871 | 0.4173645 | -0.4383634 | 0.1904426 | 0.3417830 | -0.2664306 | -0.0607542 | -0.0116914 | 1.0000000 | -0.1898651 | -0.0920385 | 0.1375010 | -0.1324898 | -0.3658775 | 0.7287007 | 0.7473932 | 0.9149495 |
env.savanna | -0.0024650 | 0.0269795 | -0.0212454 | -0.4152737 | -0.3587865 | -0.3454885 | 0.2264854 | -0.3170436 | -0.3479909 | -0.2570984 | -0.3398411 | 0.3434812 | -0.1551412 | 0.0693126 | 0.1672372 | -0.1202489 | 0.2711251 | -0.0413308 | 0.0150607 | 0.0973135 | -0.0470701 | -0.0361940 | -0.1898651 | 1.0000000 | -0.1167850 | -0.1579102 | -0.1249173 | -0.1437237 | -0.4725033 | 0.1212126 | -0.2018991 |
env.woodysavanna | 0.0280840 | 0.0437261 | 0.0151050 | -0.1495779 | -0.0619659 | -0.1352915 | 0.1850820 | -0.0375880 | -0.1389403 | 0.0182359 | -0.0967487 | 0.0467406 | -0.0112436 | 0.0098816 | 0.0462821 | 0.0029894 | 0.0293186 | 0.0667723 | 0.0015716 | 0.0062860 | 0.0318901 | -0.0154035 | -0.0920385 | -0.1167850 | 1.0000000 | -0.0847233 | -0.1104016 | 0.0006886 | -0.0777231 | -0.1006558 | -0.1058182 |
env.wetland | 0.1505896 | 0.2158389 | 0.0830030 | -0.1146293 | -0.1330635 | -0.0004524 | -0.0391527 | -0.1611847 | -0.0005642 | -0.0638922 | -0.0340330 | -0.0727980 | -0.0695311 | 0.0774311 | 0.1653903 | 0.1034344 | -0.0121391 | 0.1977084 | 0.0673108 | -0.1804121 | -0.0606497 | -0.0116054 | 0.1375010 | -0.1579102 | -0.0847233 | 1.0000000 | -0.1258117 | -0.3612828 | 0.2205404 | 0.2479464 | 0.2796946 |
env.grass | -0.1029622 | -0.1911302 | -0.0941385 | -0.1512988 | 0.1157962 | -0.3242425 | 0.2617882 | 0.0346935 | -0.3307918 | 0.0956723 | -0.2794210 | 0.3469681 | -0.0158723 | -0.0168947 | -0.0906072 | -0.2159955 | 0.2074795 | -0.0870639 | -0.1438877 | 0.3347777 | -0.0753713 | -0.0235731 | -0.1324898 | -0.1249173 | -0.1104016 | -0.1258117 | 1.0000000 | -0.1337146 | -0.4646464 | 0.2073061 | -0.1003525 |
env.npp | -0.5423448 | -0.5957826 | -0.4287304 | 0.2195306 | 0.0741961 | 0.2813411 | -0.2260104 | 0.0835534 | 0.2925463 | 0.2583383 | 0.1254955 | -0.1737652 | -0.1472418 | 0.1143688 | -0.6102193 | -0.3303117 | -0.0198950 | -0.5298813 | -0.4089540 | 0.3623028 | 0.1344147 | -0.0790421 | -0.3658775 | -0.1437237 | 0.0006886 | -0.3612828 | -0.1337146 | 1.0000000 | -0.0468240 | -0.5293037 | -0.4653541 |
env.tree | 0.2241057 | 0.2394162 | 0.2510269 | 0.5598284 | 0.3196852 | 0.5902548 | -0.4273476 | 0.3395489 | 0.5897787 | -0.0288362 | 0.6191653 | -0.5951082 | 0.2873553 | -0.1926304 | 0.0503882 | 0.4202314 | -0.4936629 | 0.1649284 | 0.2748842 | -0.3968661 | -0.0366332 | -0.0543190 | 0.7287007 | -0.4725033 | -0.0777231 | 0.2205404 | -0.4646464 | -0.0468240 | 1.0000000 | 0.2718941 | 0.7398183 |
env.nontree | 0.1944363 | 0.2026016 | 0.1763470 | -0.0677038 | 0.0073694 | -0.0208942 | 0.0504557 | -0.0039337 | -0.0290542 | -0.1901205 | 0.0444401 | -0.0668483 | 0.1459596 | -0.0852376 | 0.1630034 | 0.1793595 | -0.1095460 | 0.1344020 | 0.1941162 | -0.0874815 | -0.0745566 | -0.0802550 | 0.7473932 | 0.1212126 | -0.1006558 | 0.2479464 | 0.2073061 | -0.5293037 | 0.2718941 | 1.0000000 | 0.7880283 |
env.nonveg | 0.3216861 | 0.3128536 | 0.3326884 | 0.2675771 | 0.2150625 | 0.2560326 | -0.1488980 | 0.2253595 | 0.2499643 | -0.1873301 | 0.3673542 | -0.3700583 | 0.3206495 | -0.2445389 | 0.1918470 | 0.4141109 | -0.3848206 | 0.2359080 | 0.3490410 | -0.3009313 | -0.0958183 | 0.0973328 | 0.9149495 | -0.2018991 | -0.1058182 | 0.2796946 | -0.1003525 | -0.4653541 | 0.7398183 | 0.7880283 | 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
-3.6037 -0.3785 -0.1062 -0.0001 3.0603
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) -9.376e+00 1.165e+01 -0.805 0.42093
env.bio_1 -1.744e+01 1.257e+01 -1.387 0.16548
env.bio_2 -2.182e+01 1.161e+01 -1.880 0.06005 .
env.bio_3 5.053e+01 2.508e+01 2.015 0.04388 *
env.bio_4 2.279e+00 4.644e+00 0.491 0.62356
env.bio_5 -4.237e+00 2.403e+00 -1.763 0.07790 .
env.bio_6 2.398e-01 3.313e+00 0.072 0.94228
env.bio_7 -1.663e+00 1.568e+00 -1.060 0.28902
env.bio_8 5.367e+00 4.517e+00 1.188 0.23474
env.bio_9 -2.506e+00 4.261e+00 -0.588 0.55643
env.bio_10 4.155e-01 6.959e-01 0.597 0.55045
env.bio_11 -4.993e+00 3.198e+00 -1.561 0.11846
env.bio_12 1.345e+01 5.938e+00 2.265 0.02349 *
env.bio_13 -7.406e+00 4.552e+00 -1.627 0.10371
env.bio_14 3.276e+01 1.309e+01 2.503 0.01231 *
env.bio_15 -1.572e+06 1.535e+06 -1.024 0.30564
env.bio_16 2.635e+06 2.572e+06 1.024 0.30564
env.bio_17 2.239e+06 2.186e+06 1.024 0.30564
env.bio_18 -4.991e-01 1.832e+00 -0.272 0.78533
env.bio_19 1.121e+00 2.639e+00 0.425 0.67101
env.elev -2.721e+00 1.570e+00 -1.733 0.08302 .
env.urban 8.317e-01 3.222e-01 2.582 0.00984 **
env.barren -5.103e+00 5.512e+01 -0.093 0.92623
env.water -2.696e+00 3.431e+01 -0.079 0.93738
env.savanna -3.718e-01 3.056e-01 -1.217 0.22367
env.woodysavanna 3.843e-02 4.084e-01 0.094 0.92504
env.wetland 2.029e-04 1.035e+00 0.000 0.99984
env.grass 5.473e-02 3.985e-01 0.137 0.89078
env.npp 1.159e+00 5.654e-01 2.051 0.04030 *
env.tree -7.101e-01 1.885e+00 -0.377 0.70636
env.nontree 6.037e-01 1.644e+00 0.367 0.71338
env.nonveg -8.580e-01 1.508e+00 -0.569 0.56945
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
(Dispersion parameter for binomial family taken to be 1)
Null deviance: 515.88 on 558 degrees of freedom
Residual deviance: 276.17 on 527 degrees of freedom
AIC: 340.17
Number of Fisher Scoring iterations: 16
Code
step(glm.full) # step might not work with gam so glm
Start: AIC=340.17
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.wetland 1 276.17 338.17
- env.bio_6 1 276.18 338.18
- env.woodysavanna 1 276.18 338.18
- env.water 1 276.19 338.19
- env.barren 1 276.19 338.19
- env.grass 1 276.19 338.19
- env.bio_18 1 276.25 338.24
- env.nontree 1 276.29 338.29
- env.tree 1 276.34 338.34
- env.bio_19 1 276.35 338.35
- env.bio_4 1 276.41 338.41
- env.bio_10 1 276.53 338.53
- env.bio_9 1 276.53 338.53
- env.nonveg 1 276.54 338.54
- env.bio_17 1 277.23 339.23
- env.bio_16 1 277.23 339.23
- env.bio_15 1 277.23 339.23
- env.bio_7 1 277.36 339.36
- env.bio_8 1 277.62 339.61
- env.savanna 1 277.65 339.65
- env.bio_1 1 278.13 340.13
<none> 276.17 340.17
- env.bio_11 1 279.26 341.26
- env.elev 1 279.39 341.39
- env.bio_5 1 279.40 341.40
- env.bio_2 1 279.81 341.81
- env.bio_13 1 280.34 342.34
- env.bio_3 1 280.66 342.66
- env.npp 1 280.67 342.67
- env.bio_14 1 283.12 345.12
- env.urban 1 283.96 345.97
- env.bio_12 1 283.98 345.98
Step: AIC=338.17
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.grass + env.npp + env.tree + env.nontree + env.nonveg
Df Deviance AIC
- env.bio_6 1 276.18 336.18
- env.woodysavanna 1 276.18 336.18
- env.water 1 276.19 336.19
- env.barren 1 276.19 336.19
- env.grass 1 276.19 336.19
- env.bio_18 1 276.25 336.24
- env.nontree 1 276.29 336.29
- env.bio_19 1 276.35 336.35
- env.tree 1 276.35 336.35
- env.bio_4 1 276.41 336.41
- env.bio_10 1 276.53 336.53
- env.bio_9 1 276.53 336.53
- env.nonveg 1 276.57 336.57
- env.bio_17 1 277.23 337.23
- env.bio_16 1 277.23 337.23
- env.bio_15 1 277.23 337.23
- env.bio_7 1 277.36 337.36
- env.bio_8 1 277.62 337.62
- env.savanna 1 277.65 337.65
- env.bio_1 1 278.14 338.14
<none> 276.17 338.17
- env.bio_11 1 279.26 339.26
- env.elev 1 279.39 339.39
- env.bio_5 1 279.42 339.42
- env.bio_2 1 279.82 339.82
- env.bio_13 1 280.35 340.35
- env.bio_3 1 280.67 340.67
- env.npp 1 280.72 340.72
- env.bio_14 1 283.12 343.12
- env.urban 1 283.97 343.97
- env.bio_12 1 283.99 343.98
Step: AIC=336.18
presabs ~ env.bio_1 + env.bio_2 + env.bio_3 + env.bio_4 + env.bio_5 +
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.grass + env.npp + env.tree + env.nontree + env.nonveg
Df Deviance AIC
- env.woodysavanna 1 276.19 334.19
- env.water 1 276.19 334.19
- env.barren 1 276.19 334.20
- env.grass 1 276.20 334.20
- env.bio_18 1 276.25 334.25
- env.nontree 1 276.30 334.30
- env.tree 1 276.36 334.36
- env.bio_19 1 276.36 334.36
- env.bio_4 1 276.41 334.41
- env.bio_10 1 276.54 334.54
- env.nonveg 1 276.59 334.59
- env.bio_9 1 277.08 335.08
- env.bio_17 1 277.23 335.23
- env.bio_16 1 277.23 335.23
- env.bio_15 1 277.23 335.23
- env.bio_7 1 277.36 335.36
- env.bio_8 1 277.62 335.62
- env.savanna 1 277.65 335.65
<none> 276.18 336.18
- env.bio_1 1 278.18 336.18
- env.bio_11 1 279.31 337.31
- env.elev 1 279.42 337.42
- env.bio_5 1 279.47 337.47
- env.bio_2 1 279.91 337.91
- env.bio_13 1 280.54 338.54
- env.npp 1 280.73 338.73
- env.bio_3 1 280.74 338.74
- env.bio_14 1 283.13 341.13
- env.urban 1 284.01 342.01
- env.bio_12 1 284.04 342.04
Step: AIC=334.19
presabs ~ env.bio_1 + env.bio_2 + env.bio_3 + env.bio_4 + env.bio_5 +
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.grass + env.npp +
env.tree + env.nontree + env.nonveg
Df Deviance AIC
- env.water 1 276.20 332.20
- env.grass 1 276.20 332.20
- env.barren 1 276.20 332.20
- env.bio_18 1 276.26 332.26
- env.nontree 1 276.31 332.31
- env.bio_19 1 276.36 332.36
- env.tree 1 276.37 332.37
- env.bio_4 1 276.42 332.41
- env.bio_10 1 276.56 332.56
- env.nonveg 1 276.60 332.60
- env.bio_9 1 277.10 333.10
- env.bio_17 1 277.24 333.24
- env.bio_16 1 277.24 333.24
- env.bio_15 1 277.24 333.24
- env.bio_7 1 277.36 333.36
- env.bio_8 1 277.63 333.63
- env.savanna 1 277.76 333.76
- env.bio_1 1 278.18 334.18
<none> 276.19 334.19
- env.bio_11 1 279.36 335.36
- env.bio_5 1 279.48 335.48
- env.elev 1 279.49 335.49
- env.bio_2 1 279.91 335.91
- env.bio_13 1 280.54 336.54
- env.bio_3 1 280.75 336.75
- env.npp 1 280.77 336.77
- env.bio_14 1 283.18 339.18
- env.urban 1 284.01 340.01
- env.bio_12 1 284.05 340.05
Step: AIC=332.2
presabs ~ env.bio_1 + env.bio_2 + env.bio_3 + env.bio_4 + env.bio_5 +
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.savanna + env.grass + env.npp + env.tree +
env.nontree + env.nonveg
Df Deviance AIC
- env.grass 1 276.22 330.22
- env.barren 1 276.22 330.22
- env.bio_18 1 276.27 330.27
- env.nontree 1 276.31 330.31
- env.bio_19 1 276.38 330.38
- env.bio_4 1 276.43 330.43
- env.tree 1 276.47 330.47
- env.bio_10 1 276.57 330.57
- env.nonveg 1 276.73 330.73
- env.bio_9 1 277.12 331.12
- env.bio_17 1 277.25 331.25
- env.bio_16 1 277.25 331.25
- env.bio_15 1 277.25 331.25
- env.bio_7 1 277.40 331.40
- env.bio_8 1 277.64 331.64
- env.savanna 1 277.79 331.78
<none> 276.20 332.20
- env.bio_1 1 278.22 332.22
- env.bio_11 1 279.39 333.39
- env.bio_5 1 279.48 333.48
- env.elev 1 279.53 333.53
- env.bio_2 1 279.92 333.92
- env.bio_13 1 280.56 334.56
- env.bio_3 1 280.78 334.78
- env.npp 1 280.79 334.79
- env.bio_14 1 283.20 337.20
- env.urban 1 284.01 338.02
- env.bio_12 1 284.07 338.07
Step: AIC=330.22
presabs ~ env.bio_1 + env.bio_2 + env.bio_3 + env.bio_4 + env.bio_5 +
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.savanna + env.npp + env.tree + env.nontree +
env.nonveg
Df Deviance AIC
- env.barren 1 276.23 328.23
- env.bio_18 1 276.29 328.29
- env.nontree 1 276.32 328.32
- env.bio_19 1 276.39 328.39
- env.bio_4 1 276.45 328.45
- env.tree 1 276.58 328.58
- env.bio_10 1 276.63 328.63
- env.nonveg 1 276.74 328.74
- env.bio_9 1 277.16 329.16
- env.bio_17 1 277.28 329.28
- env.bio_15 1 277.28 329.28
- env.bio_16 1 277.28 329.28
- env.bio_7 1 277.45 329.45
- env.bio_8 1 277.66 329.66
<none> 276.22 330.22
- env.bio_1 1 278.23 330.23
- env.bio_11 1 279.39 331.39
- env.savanna 1 279.42 331.42
- env.elev 1 279.58 331.58
- env.bio_5 1 279.70 331.70
- env.bio_2 1 279.93 331.93
- env.bio_13 1 280.83 332.83
- env.bio_3 1 280.87 332.87
- env.npp 1 280.93 332.93
- env.bio_14 1 283.36 335.36
- env.urban 1 284.21 336.21
- env.bio_12 1 284.21 336.21
Step: AIC=328.23
presabs ~ env.bio_1 + env.bio_2 + env.bio_3 + env.bio_4 + env.bio_5 +
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.savanna + env.npp + env.tree + env.nontree + env.nonveg
Df Deviance AIC
- env.bio_18 1 276.30 326.30
- env.nontree 1 276.33 326.33
- env.bio_19 1 276.42 326.41
- env.bio_4 1 276.46 326.46
- env.bio_10 1 276.64 326.64
- env.tree 1 276.65 326.65
- env.nonveg 1 276.82 326.83
- env.bio_9 1 277.17 327.17
- env.bio_17 1 277.29 327.29
- env.bio_15 1 277.29 327.29
- env.bio_16 1 277.29 327.29
- env.bio_7 1 277.46 327.46
- env.bio_8 1 277.68 327.67
<none> 276.23 328.23
- env.bio_1 1 278.24 328.24
- env.savanna 1 279.43 329.43
- env.elev 1 279.58 329.58
- env.bio_11 1 279.59 329.59
- env.bio_5 1 279.75 329.75
- env.bio_2 1 279.94 329.94
- env.bio_13 1 280.84 330.84
- env.bio_3 1 280.89 330.89
- env.npp 1 280.94 330.94
- env.bio_14 1 283.37 333.37
- env.bio_12 1 284.21 334.21
- env.urban 1 284.22 334.22
Step: AIC=326.3
presabs ~ env.bio_1 + env.bio_2 + env.bio_3 + env.bio_4 + env.bio_5 +
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_19 + env.elev + env.urban + env.savanna +
env.npp + env.tree + env.nontree + env.nonveg
Df Deviance AIC
- env.nontree 1 276.41 324.41
- env.bio_4 1 276.57 324.58
- env.bio_10 1 276.67 324.67
- env.bio_19 1 276.68 324.68
- env.tree 1 276.72 324.72
- env.nonveg 1 276.88 324.88
- env.bio_9 1 277.32 325.32
- env.bio_17 1 277.37 325.37
- env.bio_16 1 277.37 325.37
- env.bio_15 1 277.37 325.37
- env.bio_7 1 277.52 325.52
- env.bio_8 1 277.70 325.70
<none> 276.30 326.30
- env.bio_1 1 278.49 326.49
- env.savanna 1 279.45 327.45
- env.elev 1 279.60 327.60
- env.bio_11 1 279.61 327.61
- env.bio_5 1 279.81 327.81
- env.bio_2 1 280.02 328.02
- env.bio_13 1 280.86 328.86
- env.bio_3 1 280.92 328.92
- env.npp 1 281.14 329.14
- env.bio_14 1 283.43 331.43
- env.urban 1 284.22 332.22
- env.bio_12 1 284.25 332.25
Step: AIC=324.41
presabs ~ env.bio_1 + env.bio_2 + env.bio_3 + env.bio_4 + env.bio_5 +
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_19 + env.elev + env.urban + env.savanna +
env.npp + env.tree + env.nonveg
Df Deviance AIC
- env.bio_4 1 276.67 322.67
- env.bio_10 1 276.73 322.73
- env.bio_19 1 276.80 322.80
- env.bio_9 1 277.37 323.36
- env.nonveg 1 277.46 323.46
- env.bio_17 1 277.46 323.46
- env.bio_16 1 277.46 323.46
- env.bio_15 1 277.46 323.46
- env.bio_7 1 277.58 323.58
- env.bio_8 1 277.76 323.76
<none> 276.41 324.41
- env.bio_1 1 278.69 324.69
- env.savanna 1 279.56 325.56
- env.elev 1 279.73 325.73
- env.bio_5 1 279.81 325.81
- env.bio_11 1 279.82 325.82
- env.bio_2 1 280.07 326.07
- env.bio_13 1 281.04 327.04
- env.bio_3 1 281.11 327.11
- env.npp 1 281.25 327.25
- env.bio_14 1 283.58 329.58
- env.urban 1 284.44 330.44
- env.bio_12 1 284.50 330.50
- env.tree 1 284.66 330.66
Step: AIC=322.67
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_11 + env.bio_12 +
env.bio_13 + env.bio_14 + env.bio_15 + env.bio_16 + env.bio_17 +
env.bio_19 + env.elev + env.urban + env.savanna + env.npp +
env.tree + env.nonveg
Df Deviance AIC
- env.bio_10 1 277.06 321.06
- env.bio_19 1 277.11 321.11
- env.bio_9 1 277.37 321.37
- env.bio_17 1 277.67 321.67
- env.bio_16 1 277.67 321.67
- env.bio_15 1 277.67 321.67
- env.nonveg 1 277.69 321.69
<none> 276.67 322.67
- env.bio_1 1 279.15 323.15
- env.savanna 1 279.77 323.77
- env.bio_11 1 279.97 323.97
- env.bio_7 1 280.05 324.05
- env.elev 1 280.07 324.07
- env.bio_5 1 280.18 324.18
- env.bio_2 1 280.90 324.90
- env.bio_13 1 281.07 325.07
- env.npp 1 281.26 325.26
- env.bio_3 1 282.19 326.19
- env.bio_8 1 283.52 327.52
- env.bio_14 1 284.09 328.09
- env.tree 1 284.67 328.67
- env.urban 1 284.95 328.95
- env.bio_12 1 284.95 328.95
Step: AIC=321.06
presabs ~ env.bio_1 + env.bio_2 + env.bio_3 + env.bio_5 + env.bio_7 +
env.bio_8 + env.bio_9 + env.bio_11 + env.bio_12 + env.bio_13 +
env.bio_14 + env.bio_15 + env.bio_16 + env.bio_17 + env.bio_19 +
env.elev + env.urban + env.savanna + env.npp + env.tree +
env.nonveg
Df Deviance AIC
- env.bio_19 1 277.46 319.46
- env.bio_9 1 277.51 319.51
- env.bio_17 1 278.04 320.04
- env.bio_16 1 278.04 320.04
- env.bio_15 1 278.04 320.04
- env.nonveg 1 278.14 320.14
<none> 277.06 321.06
- env.bio_1 1 279.29 321.29
- env.bio_7 1 280.20 322.20
- env.savanna 1 280.21 322.21
- env.bio_5 1 280.48 322.47
- env.elev 1 280.82 322.82
- env.bio_2 1 281.03 323.03
- env.bio_11 1 281.27 323.27
- env.npp 1 281.28 323.28
- env.bio_13 1 281.53 323.53
- env.bio_3 1 282.35 324.35
- env.bio_14 1 284.40 326.40
- env.tree 1 284.76 326.76
- env.bio_8 1 285.38 327.38
- env.bio_12 1 285.60 327.60
- env.urban 1 286.45 328.45
Step: AIC=319.46
presabs ~ env.bio_1 + env.bio_2 + env.bio_3 + env.bio_5 + env.bio_7 +
env.bio_8 + env.bio_9 + env.bio_11 + env.bio_12 + env.bio_13 +
env.bio_14 + env.bio_15 + env.bio_16 + env.bio_17 + env.elev +
env.urban + env.savanna + env.npp + env.tree + env.nonveg
Df Deviance AIC
- env.bio_9 1 277.91 317.91
- env.bio_17 1 278.45 318.45
- env.bio_16 1 278.45 318.45
- env.bio_15 1 278.45 318.45
- env.nonveg 1 278.52 318.52
- env.bio_1 1 279.38 319.38
<none> 277.46 319.46
- env.bio_7 1 280.22 320.22
- env.savanna 1 280.48 320.48
- env.bio_5 1 280.89 320.89
- env.npp 1 281.46 321.46
- env.bio_11 1 281.49 321.49
- env.elev 1 281.62 321.62
- env.bio_13 1 281.82 321.82
- env.bio_2 1 281.96 321.96
- env.bio_3 1 282.65 322.65
- env.bio_14 1 284.58 324.58
- env.tree 1 285.29 325.29
- env.bio_8 1 285.59 325.59
- env.bio_12 1 285.83 325.83
- env.urban 1 286.72 326.72
Step: AIC=317.91
presabs ~ env.bio_1 + env.bio_2 + env.bio_3 + env.bio_5 + env.bio_7 +
env.bio_8 + env.bio_11 + env.bio_12 + env.bio_13 + env.bio_14 +
env.bio_15 + env.bio_16 + env.bio_17 + env.elev + env.urban +
env.savanna + env.npp + env.tree + env.nonveg
Df Deviance AIC
- env.bio_17 1 278.95 316.95
- env.bio_16 1 278.95 316.95
- env.bio_15 1 278.95 316.95
- env.nonveg 1 279.00 317.00
- env.bio_1 1 279.50 317.51
<none> 277.91 317.91
- env.savanna 1 280.61 318.61
- env.bio_7 1 280.77 318.77
- env.bio_5 1 281.04 319.04
- env.npp 1 281.46 319.46
- env.bio_13 1 282.25 320.25
- env.elev 1 282.62 320.61
- env.bio_3 1 282.93 320.93
- env.bio_2 1 283.35 321.35
- env.bio_14 1 284.98 322.97
- env.bio_8 1 285.59 323.59
- env.bio_12 1 285.94 323.94
- env.tree 1 286.25 324.25
- env.urban 1 286.87 324.87
- env.bio_11 1 287.06 325.06
Step: AIC=316.95
presabs ~ env.bio_1 + env.bio_2 + env.bio_3 + env.bio_5 + env.bio_7 +
env.bio_8 + env.bio_11 + env.bio_12 + env.bio_13 + env.bio_14 +
env.bio_15 + env.bio_16 + env.elev + env.urban + env.savanna +
env.npp + env.tree + env.nonveg
Df Deviance AIC
- env.nonveg 1 280.19 316.19
- env.bio_1 1 280.54 316.54
<none> 278.95 316.95
- env.bio_16 1 281.95 317.95
- env.bio_7 1 282.06 318.06
- env.bio_5 1 282.07 318.07
- env.savanna 1 282.09 318.09
- env.npp 1 282.32 318.32
- env.bio_13 1 283.01 319.01
- env.elev 1 283.70 319.70
- env.bio_3 1 284.02 320.02
- env.bio_2 1 284.56 320.56
- env.bio_14 1 286.14 322.14
- env.bio_8 1 286.62 322.62
- env.bio_12 1 286.68 322.68
- env.bio_15 1 286.87 322.87
- env.tree 1 287.59 323.59
- env.urban 1 288.02 324.02
- env.bio_11 1 288.71 324.71
Step: AIC=316.19
presabs ~ env.bio_1 + env.bio_2 + env.bio_3 + env.bio_5 + env.bio_7 +
env.bio_8 + env.bio_11 + env.bio_12 + env.bio_13 + env.bio_14 +
env.bio_15 + env.bio_16 + env.elev + env.urban + env.savanna +
env.npp + env.tree
Df Deviance AIC
<none> 280.19 316.19
- env.bio_1 1 282.52 316.52
- env.bio_7 1 282.60 316.60
- env.bio_5 1 282.78 316.78
- env.savanna 1 282.97 316.97
- env.bio_16 1 283.49 317.49
- env.elev 1 284.48 318.48
- env.bio_13 1 285.05 319.05
- env.bio_2 1 286.04 320.04
- env.npp 1 286.89 320.89
- env.bio_8 1 287.12 321.12
- env.bio_3 1 287.68 321.68
- env.tree 1 288.01 322.01
- env.bio_11 1 288.90 322.90
- env.bio_14 1 289.48 323.48
- env.bio_12 1 289.71 323.71
- env.bio_15 1 291.38 325.38
- env.urban 1 292.54 326.54
Call: glm(formula = presabs ~ env.bio_1 + env.bio_2 + env.bio_3 + env.bio_5 +
env.bio_7 + env.bio_8 + env.bio_11 + env.bio_12 + env.bio_13 +
env.bio_14 + env.bio_15 + env.bio_16 + env.elev + env.urban +
env.savanna + env.npp + env.tree, family = "binomial", data = presabs.glm)
Coefficients:
(Intercept) env.bio_1 env.bio_2 env.bio_3 env.bio_5 env.bio_7
-8.2255 -16.3068 -25.8381 57.2347 -3.1839 -1.1943
env.bio_8 env.bio_11 env.bio_12 env.bio_13 env.bio_14 env.bio_15
5.8231 -5.8465 12.8665 -7.4649 35.1820 -15.4135
env.bio_16 env.elev env.urban env.savanna env.npp env.tree
23.3775 -3.1351 0.9506 -0.3606 1.1219 -1.2764
Degrees of Freedom: 558 Total (i.e. Null); 541 Residual
Null Deviance: 515.9
Residual Deviance: 280.2 AIC: 316.2
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 565 observations and 31 predictors
creating 10 initial models of 50 trees
folds are stratified by prevalence
total mean deviance = 0.9171
tolerance is fixed at 9e-04
ntrees resid. dev.
50 0.7312
now adding trees...
100 0.65
150 0.6009
200 0.5668
250 0.5435
300 0.5273
350 0.5163
400 0.5075
450 0.501
500 0.4957
550 0.4913
600 0.4871
650 0.483
700 0.479
750 0.4747
800 0.4714
850 0.4682
900 0.4652
950 0.4633
1000 0.4605
1050 0.4578
1100 0.455
1150 0.4527
1200 0.4505
1250 0.449
1300 0.4472
1350 0.4451
1400 0.4429
1450 0.4406
1500 0.4395
1550 0.4386
1600 0.4371
1650 0.4354
1700 0.4329
1750 0.4316
1800 0.4313
1850 0.4299
1900 0.4289
1950 0.4277
2000 0.4267
2050 0.4249
2100 0.4248
2150 0.4236
2200 0.4229
2250 0.4226
2300 0.4223
2350 0.421
2400 0.4207
2450 0.4202
2500 0.4199
2550 0.4199
2600 0.4196
2650 0.4187
2700 0.4187
2750 0.4186
2800 0.4182
2850 0.4171
2900 0.4168
2950 0.4165
3000 0.4162
3050 0.4152
3100 0.4151
3150 0.4156
3200 0.4156
3250 0.4147
3300 0.4138
3350 0.4133
3400 0.4135
3450 0.4126
3500 0.413
3550 0.4125
3600 0.4118
3650 0.4114
3700 0.4117
3750 0.4123
3800 0.4115
3850 0.4111
3900 0.4109
3950 0.4109
4000 0.4109
4050 0.4109
4100 0.4104
4150 0.4107
4200 0.4108
4250 0.4107
4300 0.4105
4350 0.4106
4400 0.4106
4450 0.4103
4500 0.4103
mean total deviance = 0.917
mean residual deviance = 0.178
estimated cv deviance = 0.41 ; se = 0.042
training data correlation = 0.93
cv correlation = 0.771 ; se = 0.025
training data AUC score = 0.994
cv AUC score = 0.944 ; se = 0.012
elapsed time - 0.23 minutes
Code
summary(brt)
var rel.inf
env.elev env.elev 28.1928762
env.urban env.urban 23.2101230
env.grass env.grass 9.6814582
env.bio_10 env.bio_10 6.0272322
env.tree env.tree 4.8640347
env.bio_2 env.bio_2 4.1923052
env.bio_15 env.bio_15 3.1509609
env.bio_4 env.bio_4 2.7770137
env.bio_11 env.bio_11 2.7636696
env.bio_12 env.bio_12 2.3681828
env.bio_17 env.bio_17 1.6628462
env.bio_6 env.bio_6 1.1529195
env.bio_3 env.bio_3 1.1315659
env.woodysavanna env.woodysavanna 1.0669455
env.savanna env.savanna 1.0587951
env.nontree env.nontree 1.0311981
env.bio_1 env.bio_1 0.9736314
env.bio_19 env.bio_19 0.8649571
env.nonveg env.nonveg 0.7891550
env.bio_14 env.bio_14 0.5298846
env.bio_13 env.bio_13 0.4729947
env.bio_5 env.bio_5 0.4436379
env.bio_9 env.bio_9 0.4303205
env.bio_18 env.bio_18 0.3804318
env.npp env.npp 0.3596909
env.bio_7 env.bio_7 0.1925652
env.bio_16 env.bio_16 0.1900647
env.bio_8 env.bio_8 0.0405392
env.barren env.barren 0.0000000
env.water env.water 0.0000000
env.wetland env.wetland 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
3.92797694 10.39918740 3.97590052 2.97435776
env.bio_5 env.bio_6 env.bio_7 env.bio_8
8.44167026 3.01378730 3.60499176 7.63845672
env.bio_9 env.bio_10 env.bio_11 env.bio_12
2.57367694 5.08138806 4.20264827 5.27707172
env.bio_13 env.bio_14 env.bio_15 env.bio_16
3.85453597 8.34691849 9.56655249 3.21308129
env.bio_17 env.bio_18 env.bio_19 env.elev
4.30703478 6.95038951 2.55815324 15.74791329
env.urban env.barren env.water env.savanna
17.88706715 0.01115468 0.02402116 3.00030515
env.woodysavanna env.wetland env.grass env.npp
3.37101272 0.48035473 4.51394216 2.41380500
env.tree env.nontree env.nonveg
3.72381998 2.75005015 1.95996900
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.elev, env.urban, env.grass, env.bio_10, env.tree, env.bio_2
- Random forest: env.urban, env.elev, env.bio_2, env.bio_5, env.bio_8, env.bio_14
- Ranger: env.urban, env.elev, env.bio_2, env.bio_15, env.bio_5, 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.elev | env.urban | env.grass | env.bio_10 | env.tree | env.bio_2 | env.bio_5 | env.bio_8 | env.bio_14 | env.bio_15 | |
---|---|---|---|---|---|---|---|---|---|---|
env.elev | 1.0000000 | 0.1776808 | 0.3347777 | 0.1685297 | -0.3968661 | -0.8088566 | -0.0644255 | -0.1003456 | 0.1075528 | -0.6630353 |
env.urban | 0.1776808 | 1.0000000 | -0.0753713 | 0.2582501 | -0.0366332 | -0.2416197 | 0.0457209 | 0.0642175 | 0.0491570 | -0.2740025 |
env.grass | 0.3347777 | -0.0753713 | 1.0000000 | 0.0956723 | -0.4646464 | -0.1911302 | 0.1157962 | 0.0346935 | -0.0168947 | -0.0906072 |
env.bio_10 | 0.1685297 | 0.2582501 | 0.0956723 | 1.0000000 | -0.0288362 | -0.2734955 | 0.3598166 | 0.3180265 | 0.1021154 | -0.4429341 |
env.tree | -0.3968661 | -0.0366332 | -0.4646464 | -0.0288362 | 1.0000000 | 0.2394162 | 0.3196852 | 0.3395489 | -0.1926304 | 0.0503882 |
env.bio_2 | -0.8088566 | -0.2416197 | -0.1911302 | -0.2734955 | 0.2394162 | 1.0000000 | 0.1263286 | 0.1704404 | -0.3771548 | 0.9194218 |
env.bio_5 | -0.0644255 | 0.0457209 | 0.1157962 | 0.3598166 | 0.3196852 | 0.1263286 | 1.0000000 | 0.9784670 | -0.6659381 | -0.0034808 |
env.bio_8 | -0.1003456 | 0.0642175 | 0.0346935 | 0.3180265 | 0.3395489 | 0.1704404 | 0.9784670 | 1.0000000 | -0.7191324 | 0.0339333 |
env.bio_14 | 0.1075528 | 0.0491570 | -0.0168947 | 0.1021154 | -0.1926304 | -0.3771548 | -0.6659381 | -0.7191324 | 1.0000000 | -0.3065325 |
env.bio_15 | -0.6630353 | -0.2740025 | -0.0906072 | -0.4429341 | 0.0503882 | 0.9194218 | -0.0034808 | 0.0339333 | -0.3065325 | 1.0000000 |
Code
tmpFiles(remove=T)