col=c('red', 'mediumseagreen'), pch=16, cex=0.7 ) # vs restricted target sites plot(targetInBuffer$WC01, targetInBuffer$WC12, pch=16, col=alpha('red', 0.05), main='Target Sites in Buffer', xlab='MAT (deg C)', ylab='MAP (mm)', xlim=c(min(targetBg$WC01), max(targetBg$WC01)), ylim=c(0, max(targetBg$WC12)) ) points(records$WC01, records$WC12, pch=21, bg=alpha('mediumseagreen', 0.5) ) legend('topright', legend=c('background', 'presence'), col=c('red', 'mediumseagreen'), pch=16, cex=0.7 ) You can see that the environmental range of the background observable to the model has been truncated greatly--but that's appropriate since we're assuming the species has not been able to disperse to environments outside this. Let's train our niche model! # make training data frame with predictors and vector of 1/0 for presence/background envData <- rbind( records[ , predictors], targetInBuffer[ , predictors] ) presBg <- c(rep(1, nrow(records)), rep(0, nrow(targetInBuffer))) trainData <- cbind(presBg, envData) # create output directory for model object and rasters dirCreate('./Models/Model 11 Niche Model') # smooth model nicheModel <- trainMaxNet( data=trainData, regMult=c(0.5, 1:3), classes='default', verbose=TRUE,
col=c('red', 'mediumseagreen'), pch=16, cex=0.7 ) # vs restricted target sites plot(targetInBuffer$WC01, targetInBuffer$WC12, pch=16, col=alpha('red', 0.05), main='Target Sites in Buffer', xlab='MAT (deg C)', ylab='MAP (mm)', xlim=c(min(targetBg$WC01), max(targetBg$WC01)), ylim=c(0, max(targetBg$WC12)) ) points(records$WC01, records$WC12, pch=21, bg=alpha('mediumseagreen', 0.5) ) legend('topright', legend=c('background', 'presence'), col=c('red', 'mediumseagreen'), pch=16, cex=0.7 ) You can see that the environmental range of the background observable to the model has been truncated greatly--but that's appropriate since we're assuming the species has not been able to disperse to environments outside this. Let's train our niche model! # make training data frame with predictors and vector of 1/0 for presence/background envData <- rbind( records[ , predictors], targetInBuffer[ , predictors] ) presBg <- c(rep(1, nrow(records)), rep(0, nrow(targetInBuffer))) trainData <- cbind(presBg, envData) # create output directory for model object and rasters dirCreate('./Models/Model 11 Niche Model') # smooth model nicheModel <- trainMaxNet( data=trainData, regMult=c(0.5, 1:3), classes='default', verbose=TRUE,
Exercise_13_Niche_versus_Distribution_Modeling.docx