We already modeled the niche and distribution of the species Podarcis muralis in the lecture Running our first ENM/SDM. We, however, tried only two sets of climatic predictors for this species. Here, your task is to re-run the two ENMs from that lecture and two more ENMs using different climatic variables. In particular, you should:
Run 2 more ENMs.
Check their theoretical validity.
Check their statistical support.
Select the best ENM.
Use that ENM for SDM (continuous and binary).
Set-up
To set up the exercise, load all climatic layers and data for ENM/SDM.
Code
library(terra)# load data frame for ENMd <-read.csv("../data/occurrences.csv")# load climate data for SDMff <-list.files("../data", pattern =".tif") # all files with .tif extensionr <-rast(file.path("..", "data", ff))roi <-ext(-13, 33, 33, 62) # roi of Europer <-crop(r, roi) # crop to Europe# ENM-1enm_01_12 <-glm( occ ~poly(wc2.1_10m_bio_1, 2, raw =TRUE) +poly(wc2.1_10m_bio_12, 2, raw =TRUE),data = d,family ="binomial")# ENM-2enm_06_14 <-glm( occ ~poly(wc2.1_10m_bio_6, 2, raw =TRUE) +poly(wc2.1_10m_bio_14, 2, raw =TRUE),data = d,family ="binomial")# Exercise starts from here# ...
Solution
Run 2 more ENMs
Code
# EMN-3 = only temperature variablesenm_01_04 <-glm( occ ~poly(wc2.1_10m_bio_1, 2, raw =TRUE) +poly(wc2.1_10m_bio_4, 2, raw =TRUE),data = d,family ="binomial")# ENM-4 = only precipitation variablesenm_12_15 <-glm( occ ~poly(wc2.1_10m_bio_12, 2, raw =TRUE) +poly(wc2.1_10m_bio_14, 2, raw =TRUE),data = d,family ="binomial")
Check theoretical validity
Code
# function for better codecheck_validity <-function(enm) { beta <-coef(enm) beta2 <- beta[grepl(")2", names(beta))]names(beta2) <-gsub("poly\\(|\\)2|, 2, raw = TRUE|wc2[.]1_10m_","",names(beta2) ) beta2}# named listenms <-list(enm_01_12 = enm_01_12,enm_06_14 = enm_06_14,enm_01_04 = enm_01_04,enm_12_15 = enm_12_15)lapply(enms, \(x) check_validity(x)) # all valid
# AICaic <-AIC(enm_01_12, enm_06_14, enm_01_04, enm_12_15)# order AICaic <- aic[order(aic$AIC), ]# delta AICaic$deltaAIC <- aic$AIC -min(aic$AIC)aic # enm_01_04 is the best model