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)
Pteronura brasiliensis Variable Selection
Variable Selection for Pteronura brasiliensis, 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()
Pteronura brasiliensis’ preferences
We will use the data from both periods
Code
<- readRDS('data/species_POPA_data/PA_pbrasiliensis_time1_blobs.rds')%>% ungroup()
PA_time1 <- readRDS('data/species_POPA_data/PA_pbrasiliensis_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
-1.246e-04 -2.100e-08 -2.100e-08 -2.100e-08 1.301e-04
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) -3.552e+02 2.149e+05 -0.002 0.999
env.bio_1 -2.181e+02 4.120e+06 0.000 1.000
env.bio_2 -2.952e+03 2.195e+06 -0.001 0.999
env.bio_3 5.151e+03 9.792e+06 0.001 1.000
env.bio_4 -6.408e+02 8.862e+05 -0.001 0.999
env.bio_5 -2.555e+02 3.446e+05 -0.001 0.999
env.bio_6 6.365e+02 6.869e+05 0.001 0.999
env.bio_7 -1.828e+02 1.835e+05 -0.001 0.999
env.bio_8 7.769e+02 8.770e+05 0.001 0.999
env.bio_9 -5.941e+02 6.247e+05 -0.001 0.999
env.bio_10 -8.495e+00 1.625e+05 0.000 1.000
env.bio_11 6.496e+01 1.939e+05 0.000 1.000
env.bio_12 1.270e+02 7.755e+05 0.000 1.000
env.bio_13 -2.305e+02 3.590e+05 -0.001 0.999
env.bio_14 2.952e+03 3.569e+06 0.001 0.999
env.bio_15 -4.660e+07 7.446e+10 -0.001 1.000
env.bio_16 7.812e+07 1.248e+11 0.001 1.000
env.bio_17 6.638e+07 1.061e+11 0.001 1.000
env.bio_18 -1.146e+02 2.898e+05 0.000 1.000
env.bio_19 -6.337e+01 3.816e+05 0.000 1.000
env.elev -4.997e+01 1.928e+05 0.000 1.000
env.urban 3.965e+01 3.250e+04 0.001 0.999
env.barren 5.577e+01 6.369e+04 0.001 0.999
env.water 1.151e+01 1.447e+05 0.000 1.000
env.savanna 1.850e+01 4.115e+04 0.000 1.000
env.woodysavanna 5.122e+01 3.225e+04 0.002 0.999
env.wetland 1.229e+01 2.189e+04 0.001 1.000
env.grass 1.194e+02 4.272e+04 0.003 0.998
env.npp -5.318e+00 3.339e+04 0.000 1.000
env.tree 8.774e+01 1.132e+05 0.001 0.999
env.nontree -7.628e+01 9.595e+04 -0.001 0.999
env.nonveg 7.912e+00 1.019e+05 0.000 1.000
(Dispersion parameter for binomial family taken to be 1)
Null deviance: 6.6348e+01 on 558 degrees of freedom
Residual deviance: 1.5411e-07 on 527 degrees of freedom
AIC: 64
Number of Fisher Scoring iterations: 25
Code
step(glm.full) # step might not work with gam so glm
Start: AIC=64
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_19 1 1.5081e-07 62
- env.bio_18 1 1.5335e-07 62
- env.nonveg 1 1.5404e-07 62
- env.water 1 1.5413e-07 62
- env.bio_1 1 1.5418e-07 62
- env.bio_10 1 1.5460e-07 62
- env.barren 1 1.5510e-07 62
- env.npp 1 1.5563e-07 62
- env.bio_12 1 1.5652e-07 62
- env.elev 1 1.5778e-07 62
- env.wetland 1 1.5914e-07 62
- env.savanna 1 1.5914e-07 62
- env.bio_16 1 1.5926e-07 62
- env.bio_15 1 1.5926e-07 62
- env.bio_17 1 1.5926e-07 62
- env.urban 1 1.6184e-07 62
- env.bio_13 1 1.7397e-07 62
- env.tree 1 1.7604e-07 62
- env.bio_11 1 1.7801e-07 62
- env.bio_5 1 2.0620e-07 62
- env.bio_7 1 2.1965e-07 62
- env.nontree 1 2.2226e-07 62
- env.bio_9 1 2.3329e-07 62
- env.bio_4 1 2.8605e-07 62
- env.bio_3 1 2.9417e-07 62
- env.woodysavanna 1 3.0731e-07 62
- env.grass 1 3.4593e-07 62
- env.bio_8 1 3.5792e-07 62
- env.bio_14 1 3.6520e-07 62
- env.bio_6 1 3.9019e-07 62
- env.bio_2 1 5.5425e-07 62
<none> 1.5411e-07 64
Step: AIC=62
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.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.nonveg 1 1.5023e-07 60
- env.bio_1 1 1.5103e-07 60
- env.bio_10 1 1.5162e-07 60
- env.barren 1 1.5174e-07 60
- env.water 1 1.5295e-07 60
- env.npp 1 1.5295e-07 60
- env.bio_12 1 1.5434e-07 60
- env.bio_18 1 1.5440e-07 60
- env.elev 1 1.5573e-07 60
- env.wetland 1 1.5612e-07 60
- env.bio_16 1 1.5653e-07 60
- env.bio_15 1 1.5653e-07 60
- env.bio_17 1 1.5653e-07 60
- env.savanna 1 1.5830e-07 60
- env.urban 1 1.5859e-07 60
- env.bio_11 1 1.7711e-07 60
- env.bio_13 1 1.8211e-07 60
- env.tree 1 1.8489e-07 60
- env.bio_7 1 2.1154e-07 60
- env.bio_5 1 2.1777e-07 60
- env.nontree 1 2.1921e-07 60
- env.bio_9 1 2.3067e-07 60
- env.bio_4 1 2.7965e-07 60
- env.bio_3 1 2.9966e-07 60
- env.woodysavanna 1 3.0574e-07 60
- env.bio_14 1 3.5783e-07 60
- env.bio_8 1 3.6428e-07 60
- env.grass 1 3.9704e-07 60
- env.bio_6 1 4.3475e-07 60
- env.bio_2 1 6.8512e-07 60
<none> 1.5081e-07 62
Step: AIC=60
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.elev + env.urban +
env.barren + env.water + env.savanna + env.woodysavanna +
env.wetland + env.grass + env.npp + env.tree + env.nontree
Df Deviance AIC
- env.bio_1 1 1.5063e-07 58
- env.barren 1 1.5097e-07 58
- env.bio_10 1 1.5133e-07 58
- env.npp 1 1.5275e-07 58
- env.bio_18 1 1.5395e-07 58
- env.bio_12 1 1.5452e-07 58
- env.water 1 1.5496e-07 58
- env.wetland 1 1.5593e-07 58
- env.bio_16 1 1.5595e-07 58
- env.bio_15 1 1.5595e-07 58
- env.bio_17 1 1.5595e-07 58
- env.elev 1 1.5669e-07 58
- env.savanna 1 1.5794e-07 58
- env.urban 1 1.5797e-07 58
- env.bio_11 1 1.7767e-07 58
- env.bio_13 1 1.8139e-07 58
- env.tree 1 1.9129e-07 58
- env.bio_5 1 2.2083e-07 58
- env.bio_7 1 2.2338e-07 58
- env.bio_9 1 2.3211e-07 58
- env.bio_4 1 2.8025e-07 58
- env.bio_3 1 2.9868e-07 58
- env.woodysavanna 1 3.1010e-07 58
- env.bio_14 1 3.7947e-07 58
- env.bio_8 1 3.9897e-07 58
- env.nontree 1 3.9922e-07 58
- env.grass 1 4.1388e-07 58
- env.bio_6 1 4.3339e-07 58
- env.bio_2 1 8.2430e-07 58
<none> 1.5023e-07 60
Step: AIC=58
presabs ~ 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.elev + env.urban + env.barren +
env.water + env.savanna + env.woodysavanna + env.wetland +
env.grass + env.npp + env.tree + env.nontree
Df Deviance AIC
- env.barren 1 0.0 56.0
- env.bio_18 1 0.0 56.0
- env.water 1 0.0 56.0
- env.npp 1 0.0 56.0
- env.wetland 1 0.0 56.0
- env.savanna 1 0.0 56.0
- env.elev 1 0.0 56.0
- env.bio_16 1 0.0 56.0
- env.bio_15 1 0.0 56.0
- env.bio_17 1 0.0 56.0
- env.bio_12 1 0.0 56.0
- env.bio_10 1 0.0 56.0
- env.urban 1 0.0 56.0
- env.bio_11 1 0.0 56.0
- env.bio_13 1 0.0 56.0
- env.tree 1 0.0 56.0
- env.bio_5 1 0.0 56.0
- env.bio_9 1 0.0 56.0
- env.bio_7 1 0.0 56.0
- env.bio_4 1 0.0 56.0
- env.woodysavanna 1 0.0 56.0
- env.grass 1 0.0 56.0
- env.bio_8 1 0.0 56.0
- env.bio_6 1 0.0 56.0
- env.bio_14 1 0.0 56.0
- env.bio_2 1 0.0 56.0
- env.bio_3 1 0.0 56.0
<none> 0.0 58.0
- env.nontree 1 576.7 632.7
Step: AIC=56
presabs ~ 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.elev + env.urban + env.water +
env.savanna + env.woodysavanna + env.wetland + env.grass +
env.npp + env.tree + env.nontree
Df Deviance AIC
- env.bio_18 1 0.00 54.00
- env.npp 1 0.00 54.00
- env.water 1 0.00 54.00
- env.wetland 1 0.00 54.00
- env.savanna 1 0.00 54.00
- env.elev 1 0.00 54.00
- env.bio_16 1 0.00 54.00
- env.bio_15 1 0.00 54.00
- env.bio_17 1 0.00 54.00
- env.urban 1 0.00 54.00
- env.bio_12 1 0.00 54.00
- env.bio_10 1 0.00 54.00
- env.bio_11 1 0.00 54.00
- env.bio_13 1 0.00 54.00
- env.tree 1 0.00 54.00
- env.bio_5 1 0.00 54.00
- env.bio_9 1 0.00 54.00
- env.bio_7 1 0.00 54.00
- env.bio_4 1 0.00 54.00
- env.woodysavanna 1 0.00 54.00
- env.grass 1 0.00 54.00
- env.bio_8 1 0.00 54.00
- env.bio_6 1 0.00 54.00
- env.bio_14 1 0.00 54.00
- env.bio_3 1 0.00 54.00
- env.bio_2 1 0.00 54.00
<none> 0.00 56.00
- env.nontree 1 792.96 846.96
Step: AIC=54
presabs ~ 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.elev + env.urban + env.water + env.savanna +
env.woodysavanna + env.wetland + env.grass + env.npp + env.tree +
env.nontree
Df Deviance AIC
- env.water 1 0.0 52.0
- env.npp 1 0.0 52.0
- env.wetland 1 0.0 52.0
- env.elev 1 0.0 52.0
- env.savanna 1 0.0 52.0
- env.bio_16 1 0.0 52.0
- env.bio_15 1 0.0 52.0
- env.bio_17 1 0.0 52.0
- env.urban 1 0.0 52.0
- env.bio_12 1 0.0 52.0
- env.bio_10 1 0.0 52.0
- env.bio_11 1 0.0 52.0
- env.bio_13 1 0.0 52.0
- env.tree 1 0.0 52.0
- env.bio_5 1 0.0 52.0
- env.bio_9 1 0.0 52.0
- env.bio_7 1 0.0 52.0
- env.bio_4 1 0.0 52.0
- env.woodysavanna 1 0.0 52.0
- env.grass 1 0.0 52.0
- env.bio_8 1 0.0 52.0
- env.bio_6 1 0.0 52.0
- env.bio_2 1 0.0 52.0
- env.bio_3 1 0.0 52.0
<none> 0.0 54.0
- env.bio_14 1 576.7 628.7
- env.nontree 1 576.7 628.7
Step: AIC=52
presabs ~ 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.elev + env.urban + env.savanna + env.woodysavanna +
env.wetland + env.grass + env.npp + env.tree + env.nontree
Df Deviance AIC
- env.elev 1 1.6089e-07 50
- env.wetland 1 1.6372e-07 50
- env.npp 1 1.6379e-07 50
- env.savanna 1 1.6469e-07 50
- env.urban 1 1.6521e-07 50
- env.bio_16 1 1.6712e-07 50
- env.bio_15 1 1.6712e-07 50
- env.bio_17 1 1.6712e-07 50
- env.bio_12 1 1.7178e-07 50
- env.bio_10 1 1.7466e-07 50
- env.bio_11 1 1.8913e-07 50
- env.bio_13 1 1.9561e-07 50
- env.bio_9 1 2.3893e-07 50
- env.bio_5 1 2.4513e-07 50
- env.bio_7 1 2.5462e-07 50
- env.tree 1 2.5594e-07 50
- env.bio_4 1 2.9573e-07 50
- env.woodysavanna 1 3.2647e-07 50
- env.grass 1 4.3555e-07 50
- env.bio_6 1 5.0913e-07 50
- env.bio_8 1 5.1589e-07 50
- env.nontree 1 7.4931e-07 50
- env.bio_2 1 9.2133e-07 50
- env.bio_14 1 1.3489e-06 50
- env.bio_3 1 2.2164e-06 50
<none> 1.5856e-07 52
Step: AIC=50
presabs ~ 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.urban + env.savanna + env.woodysavanna +
env.wetland + env.grass + env.npp + env.tree + env.nontree
Df Deviance AIC
- env.wetland 1 1.6504e-07 48
- env.savanna 1 1.6577e-07 48
- env.bio_16 1 1.6585e-07 48
- env.bio_15 1 1.6585e-07 48
- env.bio_17 1 1.6585e-07 48
- env.npp 1 1.6752e-07 48
- env.urban 1 1.6818e-07 48
- env.bio_12 1 1.7565e-07 48
- env.bio_10 1 1.8333e-07 48
- env.bio_13 1 2.0041e-07 48
- env.bio_11 1 2.0175e-07 48
- env.bio_9 1 2.3740e-07 48
- env.tree 1 2.5156e-07 48
- env.bio_5 1 2.5511e-07 48
- env.bio_7 1 2.5713e-07 48
- env.bio_4 1 3.1079e-07 48
- env.woodysavanna 1 3.4370e-07 48
- env.grass 1 4.7755e-07 48
- env.bio_8 1 5.4618e-07 48
- env.bio_6 1 5.7412e-07 48
- env.nontree 1 7.4570e-07 48
- env.bio_2 1 9.2035e-07 48
- env.bio_14 1 1.1280e-06 48
- env.bio_3 1 2.3853e-06 48
<none> 1.6089e-07 50
Step: AIC=48
presabs ~ 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.urban + env.savanna + env.woodysavanna +
env.grass + env.npp + env.tree + env.nontree
Df Deviance AIC
- env.savanna 1 1.6893e-07 46
- env.bio_16 1 1.6916e-07 46
- env.bio_17 1 1.6916e-07 46
- env.bio_15 1 1.6916e-07 46
- env.urban 1 1.7204e-07 46
- env.npp 1 1.7457e-07 46
- env.bio_12 1 1.7862e-07 46
- env.bio_10 1 1.8638e-07 46
- env.bio_11 1 2.0272e-07 46
- env.bio_13 1 2.0446e-07 46
- env.bio_9 1 2.3820e-07 46
- env.bio_5 1 2.5824e-07 46
- env.tree 1 2.6162e-07 46
- env.bio_7 1 2.6370e-07 46
- env.bio_4 1 3.1955e-07 46
- env.woodysavanna 1 3.6104e-07 46
- env.grass 1 5.0249e-07 46
- env.bio_8 1 5.5827e-07 46
- env.bio_6 1 5.9052e-07 46
- env.nontree 1 7.5270e-07 46
- env.bio_2 1 9.7566e-07 46
- env.bio_14 1 1.1779e-06 46
- env.bio_3 1 2.5586e-06 46
<none> 1.6504e-07 48
Step: AIC=46
presabs ~ 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.urban + env.woodysavanna + env.grass + env.npp +
env.tree + env.nontree
Df Deviance AIC
- env.bio_16 1 0.00 44.00
- env.bio_17 1 0.00 44.00
- env.bio_15 1 0.00 44.00
- env.urban 1 0.00 44.00
- env.bio_12 1 0.00 44.00
- env.bio_10 1 0.00 44.00
- env.npp 1 0.00 44.00
- env.bio_11 1 0.00 44.00
- env.bio_13 1 0.00 44.00
- env.bio_9 1 0.00 44.00
- env.bio_5 1 0.00 44.00
- env.tree 1 0.00 44.00
- env.bio_7 1 0.00 44.00
- env.bio_4 1 0.00 44.00
- env.bio_8 1 0.00 44.00
- env.woodysavanna 1 0.00 44.00
- env.bio_6 1 0.00 44.00
- env.grass 1 0.00 44.00
- env.nontree 1 0.00 44.00
- env.bio_2 1 0.00 44.00
- env.bio_14 1 0.00 44.00
<none> 0.00 46.00
- env.bio_3 1 432.52 476.52
Step: AIC=44
presabs ~ 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_17 +
env.urban + env.woodysavanna + env.grass + env.npp + env.tree +
env.nontree
Df Deviance AIC
- env.bio_15 1 0.00 42.00
- env.bio_17 1 0.00 42.00
- env.urban 1 0.00 42.00
- env.bio_12 1 0.00 42.00
- env.bio_10 1 0.00 42.00
- env.bio_13 1 0.00 42.00
- env.npp 1 0.00 42.00
- env.bio_11 1 0.00 42.00
- env.tree 1 0.00 42.00
- env.bio_7 1 0.00 42.00
- env.bio_5 1 0.00 42.00
- env.bio_9 1 0.00 42.00
- env.bio_4 1 0.00 42.00
- env.woodysavanna 1 0.00 42.00
- env.bio_8 1 0.00 42.00
- env.bio_6 1 0.00 42.00
- env.bio_2 1 0.00 42.00
- env.bio_3 1 0.00 42.00
<none> 0.00 44.00
- env.bio_14 1 504.61 546.61
- env.grass 1 504.61 546.61
- env.nontree 1 504.61 546.61
Step: AIC=42
presabs ~ 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_17 + env.urban +
env.woodysavanna + env.grass + env.npp + env.tree + env.nontree
Df Deviance AIC
- env.bio_17 1 0.00 40.00
- env.urban 1 0.00 40.00
- env.bio_12 1 0.00 40.00
- env.bio_10 1 0.00 40.00
- env.bio_13 1 0.00 40.00
- env.npp 1 0.00 40.00
- env.bio_11 1 0.00 40.00
- env.tree 1 0.00 40.00
- env.bio_7 1 0.00 40.00
- env.bio_5 1 0.00 40.00
- env.bio_9 1 0.00 40.00
- env.bio_4 1 0.00 40.00
- env.woodysavanna 1 0.00 40.00
- env.nontree 1 0.00 40.00
- env.bio_6 1 0.00 40.00
- env.bio_8 1 0.00 40.00
- env.bio_14 1 0.00 40.00
- env.bio_2 1 0.00 40.00
<none> 0.00 42.00
- env.bio_3 1 504.61 544.61
- env.grass 1 576.70 616.70
Step: AIC=40
presabs ~ 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.urban + env.woodysavanna +
env.grass + env.npp + env.tree + env.nontree
Df Deviance AIC
- env.urban 1 0.00 38.00
- env.npp 1 0.00 38.00
- env.bio_10 1 0.00 38.00
- env.bio_11 1 0.00 38.00
- env.bio_12 1 0.00 38.00
- env.tree 1 0.00 38.00
- env.bio_7 1 0.00 38.00
- env.bio_13 1 0.00 38.00
- env.bio_5 1 0.00 38.00
- env.bio_9 1 0.00 38.00
- env.bio_4 1 0.00 38.00
- env.woodysavanna 1 0.00 38.00
- env.nontree 1 0.00 38.00
- env.bio_8 1 0.00 38.00
- env.bio_6 1 0.00 38.00
- env.grass 1 0.00 38.00
- env.bio_14 1 0.00 38.00
- env.bio_2 1 0.00 38.00
<none> 0.00 40.00
- env.bio_3 1 648.79 686.79
Step: AIC=38
presabs ~ 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.woodysavanna +
env.grass + env.npp + env.tree + env.nontree
Df Deviance AIC
- env.bio_10 1 0.00 36.00
- env.npp 1 0.00 36.00
- env.bio_11 1 0.00 36.00
- env.bio_12 1 0.00 36.00
- env.tree 1 0.00 36.00
- env.bio_7 1 0.00 36.00
- env.bio_13 1 0.00 36.00
- env.bio_5 1 0.00 36.00
- env.bio_9 1 0.00 36.00
- env.bio_4 1 0.00 36.00
- env.woodysavanna 1 0.00 36.00
- env.nontree 1 0.00 36.00
- env.bio_8 1 0.00 36.00
- env.bio_6 1 0.00 36.00
- env.grass 1 0.00 36.00
- env.bio_14 1 0.00 36.00
- env.bio_2 1 0.00 36.00
<none> 0.00 38.00
- env.bio_3 1 432.52 468.52
Step: AIC=36
presabs ~ 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_11 + env.bio_12 +
env.bio_13 + env.bio_14 + env.woodysavanna + env.grass +
env.npp + env.tree + env.nontree
Df Deviance AIC
- env.npp 1 0.00 34.00
- env.bio_12 1 0.00 34.00
- env.tree 1 0.00 34.00
- env.bio_11 1 0.00 34.00
- env.bio_7 1 0.00 34.00
- env.bio_5 1 0.00 34.00
- env.bio_13 1 0.00 34.00
- env.bio_4 1 0.00 34.00
- env.bio_9 1 0.00 34.00
- env.woodysavanna 1 0.00 34.00
- env.bio_8 1 0.00 34.00
- env.bio_6 1 0.00 34.00
- env.nontree 1 0.00 34.00
- env.bio_14 1 0.00 34.00
- env.bio_2 1 0.00 34.00
<none> 0.00 36.00
- env.bio_3 1 16.08 50.08
- env.grass 1 504.61 538.61
Step: AIC=34
presabs ~ 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_11 + env.bio_12 +
env.bio_13 + env.bio_14 + env.woodysavanna + env.grass +
env.tree + env.nontree
Df Deviance AIC
- env.tree 1 0.000 32.000
- env.bio_11 1 0.000 32.000
- env.bio_12 1 0.000 32.000
- env.bio_7 1 0.000 32.000
- env.bio_5 1 0.000 32.000
- env.bio_13 1 0.000 32.000
- env.bio_4 1 0.000 32.000
- env.bio_9 1 0.000 32.000
- env.bio_8 1 0.000 32.000
- env.nontree 1 0.000 32.000
- env.bio_6 1 0.000 32.000
- env.woodysavanna 1 0.000 32.000
- env.grass 1 0.000 32.000
<none> 0.000 34.000
- env.bio_14 1 12.234 44.234
- env.bio_2 1 13.663 45.663
- env.bio_3 1 17.744 49.744
Step: AIC=32
presabs ~ 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_11 + env.bio_12 +
env.bio_13 + env.bio_14 + env.woodysavanna + env.grass +
env.nontree
Df Deviance AIC
- env.bio_12 1 0.00 30.00
- env.bio_11 1 0.00 30.00
- env.bio_7 1 0.00 30.00
- env.bio_5 1 0.00 30.00
- env.bio_9 1 0.00 30.00
- env.bio_8 1 0.00 30.00
- env.bio_13 1 0.00 30.00
- env.bio_6 1 0.00 30.00
- env.bio_4 1 0.00 30.00
- env.woodysavanna 1 0.00 30.00
<none> 0.00 32.00
- env.bio_14 1 13.41 43.41
- env.bio_2 1 14.16 44.16
- env.bio_3 1 18.05 48.05
- env.nontree 1 432.52 462.52
- env.grass 1 504.61 534.61
Step: AIC=30
presabs ~ 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_11 + env.bio_13 +
env.bio_14 + env.woodysavanna + env.grass + env.nontree
Df Deviance AIC
- env.bio_11 1 0.00 28.00
- env.bio_7 1 0.00 28.00
- env.bio_5 1 0.00 28.00
- env.bio_9 1 0.00 28.00
- env.bio_13 1 0.00 28.00
- env.bio_8 1 0.00 28.00
- env.bio_6 1 0.00 28.00
- env.bio_4 1 0.00 28.00
<none> 0.00 30.00
- env.woodysavanna 1 14.16 42.16
- env.bio_14 1 15.21 43.21
- env.bio_2 1 15.36 43.36
- env.bio_3 1 19.63 47.63
- env.nontree 1 504.61 532.61
- env.grass 1 648.79 676.79
Step: AIC=28
presabs ~ 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_13 + env.bio_14 +
env.woodysavanna + env.grass + env.nontree
Df Deviance AIC
- env.bio_5 1 0.00 26.00
- env.bio_9 1 0.00 26.00
- env.bio_7 1 0.00 26.00
- env.bio_13 1 0.00 26.00
- env.grass 1 0.00 26.00
- env.bio_6 1 0.00 26.00
<none> 0.00 28.00
- env.woodysavanna 1 14.81 40.81
- env.bio_14 1 22.59 48.59
- env.bio_2 1 24.63 50.63
- env.bio_4 1 25.77 51.77
- env.bio_3 1 28.07 54.07
- env.bio_8 1 432.52 458.52
- env.nontree 1 576.70 602.70
Step: AIC=26
presabs ~ env.bio_2 + env.bio_3 + env.bio_4 + env.bio_6 + env.bio_7 +
env.bio_8 + env.bio_9 + env.bio_13 + env.bio_14 + env.woodysavanna +
env.grass + env.nontree
Df Deviance AIC
- env.bio_9 1 0.000 24.000
- env.bio_13 1 0.000 24.000
- env.bio_6 1 0.000 24.000
<none> 0.000 26.000
- env.grass 1 12.028 36.028
- env.bio_7 1 13.442 37.442
- env.nontree 1 15.785 39.785
- env.woodysavanna 1 19.377 43.377
- env.bio_4 1 27.078 51.078
- env.bio_8 1 30.033 54.033
- env.bio_14 1 30.539 54.539
- env.bio_2 1 31.007 55.007
- env.bio_3 1 32.978 56.978
Step: AIC=24
presabs ~ env.bio_2 + env.bio_3 + env.bio_4 + env.bio_6 + env.bio_7 +
env.bio_8 + env.bio_13 + env.bio_14 + env.woodysavanna +
env.grass + env.nontree
Df Deviance AIC
- env.bio_6 1 0.000 22.000
<none> 0.000 24.000
- env.bio_7 1 15.784 37.784
- env.grass 1 20.566 42.566
- env.woodysavanna 1 27.057 49.057
- env.bio_13 1 27.763 49.763
- env.nontree 1 33.793 55.793
- env.bio_8 1 34.273 56.273
- env.bio_4 1 34.860 56.860
- env.bio_14 1 39.346 61.346
- env.bio_2 1 40.045 62.045
- env.bio_3 1 40.950 62.950
Step: AIC=22
presabs ~ env.bio_2 + env.bio_3 + env.bio_4 + env.bio_7 + env.bio_8 +
env.bio_13 + env.bio_14 + env.woodysavanna + env.grass +
env.nontree
Df Deviance AIC
<none> 0.000 22.000
- env.grass 1 23.656 43.656
- env.bio_13 1 27.851 47.851
- env.woodysavanna 1 28.299 48.299
- env.bio_7 1 32.855 52.855
- env.bio_4 1 35.451 55.451
- env.nontree 1 35.835 55.835
- env.bio_8 1 36.948 56.948
- env.bio_14 1 40.021 60.021
- env.bio_2 1 40.236 60.236
- env.bio_3 1 41.125 61.125
Call: glm(formula = presabs ~ env.bio_2 + env.bio_3 + env.bio_4 + env.bio_7 +
env.bio_8 + env.bio_13 + env.bio_14 + env.woodysavanna +
env.grass + env.nontree, family = "binomial", data = presabs.glm)
Coefficients:
(Intercept) env.bio_2 env.bio_3 env.bio_4
-5606.2 -44287.5 71675.3 -7275.1
env.bio_7 env.bio_8 env.bio_13 env.bio_14
-2338.3 6269.2 -1588.5 44819.5
env.woodysavanna env.grass env.nontree
323.5 1060.5 -1593.9
Degrees of Freedom: 558 Total (i.e. Null); 548 Residual
Null Deviance: 66.35
Residual Deviance: 2.981e-05 AIC: 22
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")
summary(brt)
<- 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
0.7647973 0.1917149 0.6891704 0.6700872
env.bio_5 env.bio_6 env.bio_7 env.bio_8
0.4309799 0.2312805 0.1185282 0.4868156
env.bio_9 env.bio_10 env.bio_11 env.bio_12
0.3125106 0.2127310 0.6526621 0.2726826
env.bio_13 env.bio_14 env.bio_15 env.bio_16
0.4897517 0.1855959 0.4739324 0.3260183
env.bio_17 env.bio_18 env.bio_19 env.elev
0.2060451 0.3597311 0.2812198 0.3444804
env.urban env.barren env.water env.savanna
0.2321554 0.0000000 0.0000000 0.2295819
env.woodysavanna env.wetland env.grass env.npp
0.4653634 0.4012018 0.5194698 0.3548405
env.tree env.nontree env.nonveg
0.2182062 0.3152871 0.3010372
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:
variables_brt
- Random forest: env.bio_3, env.bio_5, env.bio_1, env.bio_4, env.bio_11, env.bio_15
- Ranger: env.bio_1, env.bio_3, env.bio_4, env.bio_11, env.grass, env.bio_13
Code
<- unique(c(variables_rf, variables_ranger)) # variables_brt
selectedVariables
%>%
PA filter(!if_any(everything(), is.na)) %>%
::select(selectedVariables) %>%
dplyrpairs()
Code
%>%
PA filter(!if_any(everything(), is.na)) %>%
::select(selectedVariables) %>%
dplyrcor() %>% kable()
env.bio_3 | env.bio_5 | env.bio_1 | env.bio_4 | env.bio_11 | env.bio_15 | env.grass | env.bio_13 | |
---|---|---|---|---|---|---|---|---|
env.bio_3 | 1.0000000 | 0.4841739 | 0.9683961 | 0.3145337 | 0.2423853 | 0.7284579 | -0.0941385 | 0.8182906 |
env.bio_5 | 0.4841739 | 1.0000000 | 0.3650713 | 0.7642354 | 0.4346112 | -0.0034808 | 0.1157962 | 0.6733107 |
env.bio_1 | 0.9683961 | 0.3650713 | 1.0000000 | 0.2245524 | 0.1956382 | 0.8361199 | -0.1029622 | 0.6915905 |
env.bio_4 | 0.3145337 | 0.7642354 | 0.2245524 | 1.0000000 | 0.7446606 | -0.0696912 | -0.1512988 | 0.5005643 |
env.bio_11 | 0.2423853 | 0.4346112 | 0.1956382 | 0.7446606 | 1.0000000 | -0.0001334 | -0.2794210 | 0.4318087 |
env.bio_15 | 0.7284579 | -0.0034808 | 0.8361199 | -0.0696912 | -0.0001334 | 1.0000000 | -0.0906072 | 0.3261453 |
env.grass | -0.0941385 | 0.1157962 | -0.1029622 | -0.1512988 | -0.2794210 | -0.0906072 | 1.0000000 | -0.0158723 |
env.bio_13 | 0.8182906 | 0.6733107 | 0.6915905 | 0.5005643 | 0.4318087 | 0.3261453 | -0.0158723 | 1.0000000 |
Code
tmpFiles(remove=T)