#################################### # Bootstrapping actual record values #################################### ## Done in addition to GLMs of random points within alpha hulls. # Here we use the actual values of environmental variables, and do 10,000 bootstraps to determine whether contemporary # values are significantly different to the historical values. #### Clear environment and set working directory rm(list = ls()) setwd("E:/mammal_niche_change") # Add current date to environment for output of file names with date currentDate <- Sys.Date() #prevent display in scientific notation options(scipen = 999) library(dplyr) library(ape) library(phytools) library(maptools) library(rgdal) library("raster") library("dismo") library("rgeos") library("rJava") ##################################################### ## Create a raster stack of environmental covariates # Read in raster covariate files files <- list.files("sdms/all_unified_layers1km", pattern = "\\.tif$", full.names=TRUE) files # Choose predictors of biological relevance files <- files[-c(1,3,4,5,6,9,12,13,15,16,18,20)] # Removed annualmeantemp, aspect, bareground, clay, dailymaxtemp, # latefirefreq, raindrymonth, roughness (keeping ruggedness), # seasonality, slope, valleybottom index, vegtype (Tim Clancy recommended just using veg cover better) # Valleybottom is correlated with TWI # Stack covariates into a raster brick predictors <- stack(files) predictors ########################################################### ### Extract all records of target species from ALA & NRMaps ala_mammals <- read.csv("sdms/ala_mammals_data.csv") # Check some stuff species <- ala_mammals colnames(species) species <- species[,c("scientificName","commonName","latitude","longitude","coordinateUncertaintyInMetres","year")] # Double check lat long filters species <- species[species$longitude>129 & species$longitude<138,] species <- species[species$latitude>(-16) & species$latitude<(-10.94),] # Filter out poor quality records species <- species[!is.na(species$longitude) & !is.na(species$latitude), ] # remove incomplete - does nothing species <- species[!is.na(species$year),] # remove w/out dates species <- species[species$coordinateUncertaintyInMetres<500 | is.na(species$coordinateUncertaintyInMetres) , ] # remove inaccurate species <- species[!is.na(species$scientificName), ] # remove any records missing scientific name - does nothing # Filter to all non-volant mammals in study area selected <- c("Trichosurus vulpecula arnhemensis","Trichosurus vulpecula","Dasyurus hallucatus", "Isoodon macrourus","Petaurus breviceps ariel", "Petaurus breviceps", "Notomys aquilo", "Phascogale tapoatafa", "Petrogale brachyotis", "Petrogale brachyotis brachyotis", "Mesembriomys gouldii", "Mesembriomys gouldii gouldii", "Mesembriomys gouldii melvillensis", "Sminthopsis virginae", "Rattus tunneyi", "Conilurus penicillatus","Mesembriomys gouldii", "Rattus colletti","Sminthopsis bindi", "Phascogale pirata", "Melomys burtoni", "Pseudomys nanus", "Zyzomys maini", "Zyzomys argurus","Pseudomys delicatulus", "Phascogale tapoatafa tapoatafa", "Xeromys myoides","Zyzomys woodwardi", "Planigale maculata maculata", "Planigale tenuirostris","Tachyglossus aculeatus", "Hydromys chrysogaster", "Sminthopsis butleri", "Sminthopsis macroura", "Leggadina forresti","Petrogale wilkinsi", "Isoodon auratus", "Pseudantechinus bilarni","Isoodon macrourus macrourus", "Pseudantechinus ningbing", #"Canis lupus", "Petropseudes dahli", "Pseudomys calabyi", "Planigale maculata","Antechinus bellus","Sminthopsis virginiae virginiae", "Planigale ingrami", "Mesembriomys macrurus","Planigale maculata sinualis", "Pseudomys occidentalis","Rattus tunneyi tunneyi", "Petrogale concinna concinna", "Petrogale lateralis pearsoni", "Petrogale concinna","Petrogale lateralis", "Lagorchestes conspicillatus conspicillatus","Lagorchestes conspicillatus", "Onychogalea unguifera", "Pseudomys johnsoni", "Sminthopsis macroura froggatti","Rattus rattus","Rattus villosissimus") ala_mammals <- species[species$scientificName %in% selected,] ### Filter NR Maps records atlas_mammals <- read.csv("sdms/Species_Atlas_FAUNA/fauna_atlas_mammals2019-10-08.csv", row.names = NULL, header=TRUE) atlas_mammals <- atlas_mammals[,c("SCIENTIFICNAME","COMMONNAME","DATE","LATITUDE","LONGITUDE","COORD_UNCERTAINTY_M")] atlas_mammals[1:10,] atlas_mammals$year <- format(as.Date(atlas_mammals$DATE, format="%d/%m/%Y"),"%Y") colnames(atlas_mammals) <- c("scientificName","commonName","date","latitude","longitude","coordinateUncertaintyInMetres","year") atlas_mammals$date <- NULL # remove old date column # Filter to Top End only atlas_mammals <- atlas_mammals[atlas_mammals$longitude>129 & atlas_mammals$longitude<138,] atlas_mammals <- atlas_mammals[atlas_mammals$latitude>(-16) & atlas_mammals$latitude<(-10.94),] # Filter out poor quality records (as above) atlas_mammals <- atlas_mammals[!is.na(atlas_mammals$longitude) & !is.na(atlas_mammals$latitude), ] atlas_mammals <- atlas_mammals[!is.na(atlas_mammals$year),] atlas_mammals <- atlas_mammals[atlas_mammals$coordinateUncertaintyInMetres<500 | is.na(atlas_mammals$coordinateUncertaintyInMetres) , ] atlas_mammals <- atlas_mammals[!is.na(atlas_mammals$scientificName), ] # Filter to selected mammalian species atlas_mammals <- atlas_mammals[atlas_mammals$scientificName %in% selected,] ### Merge NR Maps records with ALA records and delete duplicates every_mammal <- rbind(ala_mammals,atlas_mammals) library(stringr) every_mammal$scientificName <- word(every_mammal$scientificName, 1,2, sep=" ") # Remove subspecies designations every_mammal <- every_mammal[,c("scientificName","latitude","longitude","year")] ############################################## ### FILTER ON DATES allrecords <- 1900 modernrecords <- 2000 every_mammal <- every_mammal[every_mammal$year > allrecords,] # Historical dataset every_mammal <- every_mammal[every_mammal$year >= modernrecords,] # Contemporary dataset ############################################### ###################################### ### SELECT SPECIES OF INTEREST FOR SDM # species <- every_mammal[every_mammal$scientificName=="Dasyurus hallucatus",] # species <- every_mammal[every_mammal$scientificName=="Antechinus bellus",] # species <- every_mammal[every_mammal$scientificName=="Conilurus penicillatus",] # species <- every_mammal[every_mammal$scientificName=="Isoodon macrourus",] # species <- every_mammal[every_mammal$scientificName=="Mesembriomys gouldii",] # species <- every_mammal[every_mammal$scientificName=="Petaurus breviceps",] # species <- every_mammal[every_mammal$scientificName=="Pseudomys nanus",] # species <- every_mammal[every_mammal$scientificName=="Rattus tunneyi",] # species <- every_mammal[every_mammal$scientificName=="Trichosurus vulpecula",] ##################################### # ########################################################### # ### REMOVE PRESENCE POINTS ON ISLANDS (NORTHERN QUOLLS ONLY) # species <- subset(species, species$latitude > (-13.6) | species$latitude < (-14.3) | species$longitude < (136.09)) # Groote Eylandt # species <- subset(species, species$latitude < (-12.14) | species$longitude < (135.45)) # Wessel and English Company Islands # species <- subset(species, species$latitude > (-15.48) | species$latitude < (-15.89) | species$longitude < (136.48)) # Pellew Islands # ########################################################### # # Output table of all records by decade or something per editor's suggestion # allspecies <- every_mammal[every_mammal$scientificName=="Trichosurus vulpecula" | every_mammal$scientificName=="Rattus tunneyi" | # every_mammal$scientificName=="Pseudomys nanus"| every_mammal$scientificName=="Petaurus breviceps" | # every_mammal$scientificName=="Mesembriomys gouldii" | every_mammal$scientificName=="Isoodon macrourus" | # every_mammal$scientificName=="Conilurus penicillatus" | every_mammal$scientificName=="Dasyurus hallucatus" | # every_mammal$scientificName=="Antechinus bellus" ,] # head(allspecies) # allspecies <- allspecies[!duplicated(allspecies), ] # retain one record per species per lat/long per year # head(allspecies) # allspecies$year <- as.integer(allspecies$year) # allspecies$decade <- allspecies$year - allspecies$year %% 10 # change year to decade # library(dplyr) # species_decade <- allspecies %>% count(scientificName,decade) # library(tidyr) # species_decade <- species_decade %>% spread(scientificName, n) ## Remove duplicate records from background sampling and year column from species of interest every_mammal$year <- NULL species$year <- NULL every_mammal <- every_mammal[!duplicated(every_mammal), ] ######################################## ### Thin presence points and plot on map ## Basic map # Make presence points into a spatial df coordinates(species) <- ~longitude + latitude crs(species) <- "+proj=longlat +datum=WGS84" ## Thin presence points # Only retain a single presence point per pixel cells <- cellFromXY(predictors[[1]], species) dups <- duplicated(cells) occ_final <- species[!dups, ] cat(nrow(species) - nrow(occ_final), "records are removed") cat(length(occ_final), "presences remain") ################################ ### Extract environmental values # Extract env values for all presences and background points p_all <- extract(predictors, occ_final) # # For outputting lat longs # latlong <- as.data.frame(occ_final)[,2:3] # p_all <- cbind(p_all,latlong) # Remove shit datapoints p_all <- p_all[complete.cases(p_all), ] # update column names (second one just for outputting lat longs) colnames(p_all) <- c("Rainfall", "Elevation", "FireFreq", "MaxTemp", "MinTemp", "TRI", "TWI", "VegCover") # colnames(p_all) <- c("Rainfall", "Elevation", "FireFreq", "MaxTemp", "MinTemp", "TRI", "TWI", "VegCover","Latitude","Longitude") p_all <- as.data.frame(p_all) ########################################################### ### SET COLUMNS FOR GLMs # p_all$time_period <- "Historical" # p_all$time_period <- "Contemporary" # p_all$species <- "Fawn antechinus" # p_all$species <- "Brush-tailed rabbit-rat" # p_all$species <- "Northern quoll" # p_all$species <- "Northern brown bandicoot" # p_all$species <- "Black-footed tree-rat" # p_all$species <- "Sugar glider" # p_all$species <- "Pale field rat" # p_all$species <- "Common brushtail possum" # p_all$species <- "Western chestnut mouse" ########################################################### # Output points to csv for later GLM write.table(p_all, file="sdms/output/sampled_pres_points_glms.csv", append = T, sep=',', row.names=F, col.names=F ) # ## Output lat and longs for all records to csv # write.table(p_all, # file="sdms/output/pres_points_lat_longs.csv", # append = T, # sep=',', # row.names=F, # col.names=F ) ############################################################################################### ## Get percentile of old values in new records for each combination of species and env variable df <- read.csv("sdms/output/sampled_pres_points_glms.csv") levels(df$species) colnames(df) # # Output pdf file of histograms of presence points by environmental variable for supplementary # pdffilename <- paste("sdms/output/hists_all_vars",currentDate,".pdf",sep="") # pdf(pdffilename, family="Times", width=15, height=15) # par(mfrow=c(9,8)) # par(mar=c(2,2,2,2)) # for(i in unique(df$species)) { # for(j in colnames(df)[1:8]) { # hist(df[df$species==i & df$time_period=="Historical" , j], breaks=15, main=j) # } # } # dev.off() ################### ### Northern quolls ## Rainfall nq <- df[ which(df$species=="Northern quoll"), ] nq_contemp_Rainfall <- mean(nq$Rainfall[nq$time_period=="Contemporary"]) # Get bootstraps of historical data nq_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(nq_hist_bootstrap)){ nq_hist_bootstrap[i] <- mean(sample(nq$Rainfall[nq$time_period=="Historical"], length(nq$Rainfall[nq$time_period=="Contemporary"]), replace=FALSE)) } mean(nq_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data nq_Rainfall <- length(nq_hist_bootstrap[nq_hist_bootstrap>=nq_contemp_Rainfall])/10000 ## Elevation nq <- df[ which(df$species=="Northern quoll"), ] nq_contemp_Elevation <- mean(nq$Elevation[nq$time_period=="Contemporary"]) # Get bootstraps of historical data nq_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(nq_hist_bootstrap)){ nq_hist_bootstrap[i] <- mean(sample(nq$Elevation[nq$time_period=="Historical"], length(nq$Elevation[nq$time_period=="Contemporary"]), replace=FALSE)) } mean(nq_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data nq_Elevation <- length(nq_hist_bootstrap[nq_hist_bootstrap>=nq_contemp_Elevation])/10000 ## FireFreq nq <- df[ which(df$species=="Northern quoll"), ] nq_contemp_FireFreq <- mean(nq$FireFreq[nq$time_period=="Contemporary"]) # Get bootstraps of historical data nq_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(nq_hist_bootstrap)){ nq_hist_bootstrap[i] <- mean(sample(nq$FireFreq[nq$time_period=="Historical"], length(nq$FireFreq[nq$time_period=="Contemporary"]), replace=FALSE)) } mean(nq_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data nq_FireFreq <- length(nq_hist_bootstrap[nq_hist_bootstrap>=nq_contemp_FireFreq])/10000 ## FireFreq nq <- df[ which(df$species=="Northern quoll"), ] nq_contemp_FireFreq <- mean(nq$FireFreq[nq$time_period=="Contemporary"]) # Get bootstraps of historical data nq_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(nq_hist_bootstrap)){ nq_hist_bootstrap[i] <- mean(sample(nq$FireFreq[nq$time_period=="Historical"], length(nq$FireFreq[nq$time_period=="Contemporary"]), replace=FALSE)) } mean(nq_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data nq_FireFreq <- length(nq_hist_bootstrap[nq_hist_bootstrap>=nq_contemp_FireFreq])/10000 ## MaxTemp nq <- df[ which(df$species=="Northern quoll"), ] nq_contemp_MaxTemp <- mean(nq$MaxTemp[nq$time_period=="Contemporary"]) # Get bootstraps of historical data nq_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(nq_hist_bootstrap)){ nq_hist_bootstrap[i] <- mean(sample(nq$MaxTemp[nq$time_period=="Historical"], length(nq$MaxTemp[nq$time_period=="Contemporary"]), replace=FALSE)) } mean(nq_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data nq_MaxTemp <- length(nq_hist_bootstrap[nq_hist_bootstrap>=nq_contemp_MaxTemp])/10000 ## MinTemp nq <- df[ which(df$species=="Northern quoll"), ] nq_contemp_MinTemp <- mean(nq$MinTemp[nq$time_period=="Contemporary"]) # Get bootstraps of historical data nq_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(nq_hist_bootstrap)){ nq_hist_bootstrap[i] <- mean(sample(nq$MinTemp[nq$time_period=="Historical"], length(nq$MinTemp[nq$time_period=="Contemporary"]), replace=FALSE)) } mean(nq_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data nq_MinTemp <- length(nq_hist_bootstrap[nq_hist_bootstrap>=nq_contemp_MinTemp])/10000 ## TRI nq <- df[ which(df$species=="Northern quoll"), ] nq_contemp_TRI <- mean(nq$TRI[nq$time_period=="Contemporary"]) # Get bootstraps of historical data nq_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(nq_hist_bootstrap)){ nq_hist_bootstrap[i] <- mean(sample(nq$TRI[nq$time_period=="Historical"], length(nq$TRI[nq$time_period=="Contemporary"]), replace=FALSE)) } mean(nq_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data nq_TRI <- length(nq_hist_bootstrap[nq_hist_bootstrap>=nq_contemp_TRI])/10000 ## TWI nq <- df[ which(df$species=="Northern quoll"), ] nq_contemp_TWI <- mean(nq$TWI[nq$time_period=="Contemporary"]) # Get bootstraps of historical data nq_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(nq_hist_bootstrap)){ nq_hist_bootstrap[i] <- mean(sample(nq$TWI[nq$time_period=="Historical"], length(nq$TWI[nq$time_period=="Contemporary"]), replace=FALSE)) } mean(nq_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data nq_TWI <- length(nq_hist_bootstrap[nq_hist_bootstrap>=nq_contemp_TWI])/10000 ## VegCover nq <- df[ which(df$species=="Northern quoll"), ] nq_contemp_VegCover <- mean(nq$VegCover[nq$time_period=="Contemporary"]) # Get bootstraps of historical data nq_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(nq_hist_bootstrap)){ nq_hist_bootstrap[i] <- mean(sample(nq$VegCover[nq$time_period=="Historical"], length(nq$VegCover[nq$time_period=="Contemporary"]), replace=FALSE)) } mean(nq_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data nq_VegCover <- length(nq_hist_bootstrap[nq_hist_bootstrap>=nq_contemp_VegCover])/10000 # Get vector of results for each variable NQ <- c(nq_Rainfall, nq_Elevation, nq_FireFreq, nq_MaxTemp, nq_MinTemp, nq_TRI, nq_TWI, nq_VegCover) ################### ### Fawn antechinuss ## Rainfall ante_bel <- df[ which(df$species=="Fawn antechinus"), ] ante_bel_contemp_Rainfall <- mean(ante_bel$Rainfall[ante_bel$time_period=="Contemporary"]) # Get bootstraps of historical data ante_bel_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(ante_bel_hist_bootstrap)){ ante_bel_hist_bootstrap[i] <- mean(sample(ante_bel$Rainfall[ante_bel$time_period=="Historical"], length(ante_bel$Rainfall[ante_bel$time_period=="Contemporary"]), replace=FALSE)) } mean(ante_bel_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data ante_bel_Rainfall <- length(ante_bel_hist_bootstrap[ante_bel_hist_bootstrap>=ante_bel_contemp_Rainfall])/10000 ## Elevation ante_bel <- df[ which(df$species=="Fawn antechinus"), ] ante_bel_contemp_Elevation <- mean(ante_bel$Elevation[ante_bel$time_period=="Contemporary"]) # Get bootstraps of historical data ante_bel_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(ante_bel_hist_bootstrap)){ ante_bel_hist_bootstrap[i] <- mean(sample(ante_bel$Elevation[ante_bel$time_period=="Historical"], length(ante_bel$Elevation[ante_bel$time_period=="Contemporary"]), replace=FALSE)) } mean(ante_bel_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data ante_bel_Elevation <- length(ante_bel_hist_bootstrap[ante_bel_hist_bootstrap>=ante_bel_contemp_Elevation])/10000 ## FireFreq ante_bel <- df[ which(df$species=="Fawn antechinus"), ] ante_bel_contemp_FireFreq <- mean(ante_bel$FireFreq[ante_bel$time_period=="Contemporary"]) # Get bootstraps of historical data ante_bel_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(ante_bel_hist_bootstrap)){ ante_bel_hist_bootstrap[i] <- mean(sample(ante_bel$FireFreq[ante_bel$time_period=="Historical"], length(ante_bel$FireFreq[ante_bel$time_period=="Contemporary"]), replace=FALSE)) } mean(ante_bel_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data ante_bel_FireFreq <- length(ante_bel_hist_bootstrap[ante_bel_hist_bootstrap>=ante_bel_contemp_FireFreq])/10000 ## FireFreq ante_bel <- df[ which(df$species=="Fawn antechinus"), ] ante_bel_contemp_FireFreq <- mean(ante_bel$FireFreq[ante_bel$time_period=="Contemporary"]) # Get bootstraps of historical data ante_bel_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(ante_bel_hist_bootstrap)){ ante_bel_hist_bootstrap[i] <- mean(sample(ante_bel$FireFreq[ante_bel$time_period=="Historical"], length(ante_bel$FireFreq[ante_bel$time_period=="Contemporary"]), replace=FALSE)) } mean(ante_bel_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data ante_bel_FireFreq <- length(ante_bel_hist_bootstrap[ante_bel_hist_bootstrap>=ante_bel_contemp_FireFreq])/10000 ## MaxTemp ante_bel <- df[ which(df$species=="Fawn antechinus"), ] ante_bel_contemp_MaxTemp <- mean(ante_bel$MaxTemp[ante_bel$time_period=="Contemporary"]) # Get bootstraps of historical data ante_bel_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(ante_bel_hist_bootstrap)){ ante_bel_hist_bootstrap[i] <- mean(sample(ante_bel$MaxTemp[ante_bel$time_period=="Historical"], length(ante_bel$MaxTemp[ante_bel$time_period=="Contemporary"]), replace=FALSE)) } mean(ante_bel_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data ante_bel_MaxTemp <- length(ante_bel_hist_bootstrap[ante_bel_hist_bootstrap>=ante_bel_contemp_MaxTemp])/10000 ## MinTemp ante_bel <- df[ which(df$species=="Fawn antechinus"), ] ante_bel_contemp_MinTemp <- mean(ante_bel$MinTemp[ante_bel$time_period=="Contemporary"]) # Get bootstraps of historical data ante_bel_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(ante_bel_hist_bootstrap)){ ante_bel_hist_bootstrap[i] <- mean(sample(ante_bel$MinTemp[ante_bel$time_period=="Historical"], length(ante_bel$MinTemp[ante_bel$time_period=="Contemporary"]), replace=FALSE)) } mean(ante_bel_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data ante_bel_MinTemp <- length(ante_bel_hist_bootstrap[ante_bel_hist_bootstrap>=ante_bel_contemp_MinTemp])/10000 ## TRI ante_bel <- df[ which(df$species=="Fawn antechinus"), ] ante_bel_contemp_TRI <- mean(ante_bel$TRI[ante_bel$time_period=="Contemporary"]) # Get bootstraps of historical data ante_bel_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(ante_bel_hist_bootstrap)){ ante_bel_hist_bootstrap[i] <- mean(sample(ante_bel$TRI[ante_bel$time_period=="Historical"], length(ante_bel$TRI[ante_bel$time_period=="Contemporary"]), replace=FALSE)) } mean(ante_bel_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data ante_bel_TRI <- length(ante_bel_hist_bootstrap[ante_bel_hist_bootstrap>=ante_bel_contemp_TRI])/10000 ## TWI ante_bel <- df[ which(df$species=="Fawn antechinus"), ] ante_bel_contemp_TWI <- mean(ante_bel$TWI[ante_bel$time_period=="Contemporary"]) # Get bootstraps of historical data ante_bel_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(ante_bel_hist_bootstrap)){ ante_bel_hist_bootstrap[i] <- mean(sample(ante_bel$TWI[ante_bel$time_period=="Historical"], length(ante_bel$TWI[ante_bel$time_period=="Contemporary"]), replace=FALSE)) } mean(ante_bel_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data ante_bel_TWI <- length(ante_bel_hist_bootstrap[ante_bel_hist_bootstrap>=ante_bel_contemp_TWI])/10000 ## VegCover ante_bel <- df[ which(df$species=="Fawn antechinus"), ] ante_bel_contemp_VegCover <- mean(ante_bel$VegCover[ante_bel$time_period=="Contemporary"]) # Get bootstraps of historical data ante_bel_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(ante_bel_hist_bootstrap)){ ante_bel_hist_bootstrap[i] <- mean(sample(ante_bel$VegCover[ante_bel$time_period=="Historical"], length(ante_bel$VegCover[ante_bel$time_period=="Contemporary"]), replace=FALSE)) } mean(ante_bel_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data ante_bel_VegCover <- length(ante_bel_hist_bootstrap[ante_bel_hist_bootstrap>=ante_bel_contemp_VegCover])/10000 # Get vector of results for each variable ante_bel <- c(ante_bel_Rainfall, ante_bel_Elevation, ante_bel_FireFreq, ante_bel_MaxTemp, ante_bel_MinTemp, ante_bel_TRI, ante_bel_TWI, ante_bel_VegCover) ################### ### Brush-tailed rabbit-rats ## Rainfall con_pen <- df[ which(df$species=="Brush-tailed rabbit-rat"), ] con_pen_contemp_Rainfall <- mean(con_pen$Rainfall[con_pen$time_period=="Contemporary"]) # Get bootstraps of historical data con_pen_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(con_pen_hist_bootstrap)){ con_pen_hist_bootstrap[i] <- mean(sample(con_pen$Rainfall[con_pen$time_period=="Historical"], length(con_pen$Rainfall[con_pen$time_period=="Contemporary"]), replace=FALSE)) } mean(con_pen_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data con_pen_Rainfall <- length(con_pen_hist_bootstrap[con_pen_hist_bootstrap>=con_pen_contemp_Rainfall])/10000 ## Elevation con_pen <- df[ which(df$species=="Brush-tailed rabbit-rat"), ] con_pen_contemp_Elevation <- mean(con_pen$Elevation[con_pen$time_period=="Contemporary"]) # Get bootstraps of historical data con_pen_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(con_pen_hist_bootstrap)){ con_pen_hist_bootstrap[i] <- mean(sample(con_pen$Elevation[con_pen$time_period=="Historical"], length(con_pen$Elevation[con_pen$time_period=="Contemporary"]), replace=FALSE)) } mean(con_pen_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data con_pen_Elevation <- length(con_pen_hist_bootstrap[con_pen_hist_bootstrap>=con_pen_contemp_Elevation])/10000 ## FireFreq con_pen <- df[ which(df$species=="Brush-tailed rabbit-rat"), ] con_pen_contemp_FireFreq <- mean(con_pen$FireFreq[con_pen$time_period=="Contemporary"]) # Get bootstraps of historical data con_pen_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(con_pen_hist_bootstrap)){ con_pen_hist_bootstrap[i] <- mean(sample(con_pen$FireFreq[con_pen$time_period=="Historical"], length(con_pen$FireFreq[con_pen$time_period=="Contemporary"]), replace=FALSE)) } mean(con_pen_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data con_pen_FireFreq <- length(con_pen_hist_bootstrap[con_pen_hist_bootstrap>=con_pen_contemp_FireFreq])/10000 ## FireFreq con_pen <- df[ which(df$species=="Brush-tailed rabbit-rat"), ] con_pen_contemp_FireFreq <- mean(con_pen$FireFreq[con_pen$time_period=="Contemporary"]) # Get bootstraps of historical data con_pen_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(con_pen_hist_bootstrap)){ con_pen_hist_bootstrap[i] <- mean(sample(con_pen$FireFreq[con_pen$time_period=="Historical"], length(con_pen$FireFreq[con_pen$time_period=="Contemporary"]), replace=FALSE)) } mean(con_pen_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data con_pen_FireFreq <- length(con_pen_hist_bootstrap[con_pen_hist_bootstrap>=con_pen_contemp_FireFreq])/10000 ## MaxTemp con_pen <- df[ which(df$species=="Brush-tailed rabbit-rat"), ] con_pen_contemp_MaxTemp <- mean(con_pen$MaxTemp[con_pen$time_period=="Contemporary"]) # Get bootstraps of historical data con_pen_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(con_pen_hist_bootstrap)){ con_pen_hist_bootstrap[i] <- mean(sample(con_pen$MaxTemp[con_pen$time_period=="Historical"], length(con_pen$MaxTemp[con_pen$time_period=="Contemporary"]), replace=FALSE)) } mean(con_pen_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data con_pen_MaxTemp <- length(con_pen_hist_bootstrap[con_pen_hist_bootstrap>=con_pen_contemp_MaxTemp])/10000 ## MinTemp con_pen <- df[ which(df$species=="Brush-tailed rabbit-rat"), ] con_pen_contemp_MinTemp <- mean(con_pen$MinTemp[con_pen$time_period=="Contemporary"]) # Get bootstraps of historical data con_pen_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(con_pen_hist_bootstrap)){ con_pen_hist_bootstrap[i] <- mean(sample(con_pen$MinTemp[con_pen$time_period=="Historical"], length(con_pen$MinTemp[con_pen$time_period=="Contemporary"]), replace=FALSE)) } mean(con_pen_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data con_pen_MinTemp <- length(con_pen_hist_bootstrap[con_pen_hist_bootstrap>=con_pen_contemp_MinTemp])/10000 ## TRI con_pen <- df[ which(df$species=="Brush-tailed rabbit-rat"), ] con_pen_contemp_TRI <- mean(con_pen$TRI[con_pen$time_period=="Contemporary"]) # Get bootstraps of historical data con_pen_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(con_pen_hist_bootstrap)){ con_pen_hist_bootstrap[i] <- mean(sample(con_pen$TRI[con_pen$time_period=="Historical"], length(con_pen$TRI[con_pen$time_period=="Contemporary"]), replace=FALSE)) } mean(con_pen_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data con_pen_TRI <- length(con_pen_hist_bootstrap[con_pen_hist_bootstrap>=con_pen_contemp_TRI])/10000 ## TWI con_pen <- df[ which(df$species=="Brush-tailed rabbit-rat"), ] con_pen_contemp_TWI <- mean(con_pen$TWI[con_pen$time_period=="Contemporary"]) # Get bootstraps of historical data con_pen_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(con_pen_hist_bootstrap)){ con_pen_hist_bootstrap[i] <- mean(sample(con_pen$TWI[con_pen$time_period=="Historical"], length(con_pen$TWI[con_pen$time_period=="Contemporary"]), replace=FALSE)) } mean(con_pen_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data con_pen_TWI <- length(con_pen_hist_bootstrap[con_pen_hist_bootstrap>=con_pen_contemp_TWI])/10000 ## VegCover con_pen <- df[ which(df$species=="Brush-tailed rabbit-rat"), ] con_pen_contemp_VegCover <- mean(con_pen$VegCover[con_pen$time_period=="Contemporary"]) # Get bootstraps of historical data con_pen_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(con_pen_hist_bootstrap)){ con_pen_hist_bootstrap[i] <- mean(sample(con_pen$VegCover[con_pen$time_period=="Historical"], length(con_pen$VegCover[con_pen$time_period=="Contemporary"]), replace=FALSE)) } mean(con_pen_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data con_pen_VegCover <- length(con_pen_hist_bootstrap[con_pen_hist_bootstrap>=con_pen_contemp_VegCover])/10000 # Get vector of results for each variable con_pen <- c(con_pen_Rainfall, con_pen_Elevation, con_pen_FireFreq, con_pen_MaxTemp, con_pen_MinTemp, con_pen_TRI, con_pen_TWI, con_pen_VegCover) ################### ### Northern brown bandicoots ## Rainfall nor_brown <- df[ which(df$species=="Northern brown bandicoot"), ] nor_brown_contemp_Rainfall <- mean(nor_brown$Rainfall[nor_brown$time_period=="Contemporary"]) # Get bootstraps of historical data nor_brown_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(nor_brown_hist_bootstrap)){ nor_brown_hist_bootstrap[i] <- mean(sample(nor_brown$Rainfall[nor_brown$time_period=="Historical"], length(nor_brown$Rainfall[nor_brown$time_period=="Contemporary"]), replace=FALSE)) } mean(nor_brown_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data nor_brown_Rainfall <- length(nor_brown_hist_bootstrap[nor_brown_hist_bootstrap>=nor_brown_contemp_Rainfall])/10000 ## Elevation nor_brown <- df[ which(df$species=="Northern brown bandicoot"), ] nor_brown_contemp_Elevation <- mean(nor_brown$Elevation[nor_brown$time_period=="Contemporary"]) # Get bootstraps of historical data nor_brown_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(nor_brown_hist_bootstrap)){ nor_brown_hist_bootstrap[i] <- mean(sample(nor_brown$Elevation[nor_brown$time_period=="Historical"], length(nor_brown$Elevation[nor_brown$time_period=="Contemporary"]), replace=FALSE)) } mean(nor_brown_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data nor_brown_Elevation <- length(nor_brown_hist_bootstrap[nor_brown_hist_bootstrap>=nor_brown_contemp_Elevation])/10000 ## FireFreq nor_brown <- df[ which(df$species=="Northern brown bandicoot"), ] nor_brown_contemp_FireFreq <- mean(nor_brown$FireFreq[nor_brown$time_period=="Contemporary"]) # Get bootstraps of historical data nor_brown_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(nor_brown_hist_bootstrap)){ nor_brown_hist_bootstrap[i] <- mean(sample(nor_brown$FireFreq[nor_brown$time_period=="Historical"], length(nor_brown$FireFreq[nor_brown$time_period=="Contemporary"]), replace=FALSE)) } mean(nor_brown_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data nor_brown_FireFreq <- length(nor_brown_hist_bootstrap[nor_brown_hist_bootstrap>=nor_brown_contemp_FireFreq])/10000 ## FireFreq nor_brown <- df[ which(df$species=="Northern brown bandicoot"), ] nor_brown_contemp_FireFreq <- mean(nor_brown$FireFreq[nor_brown$time_period=="Contemporary"]) # Get bootstraps of historical data nor_brown_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(nor_brown_hist_bootstrap)){ nor_brown_hist_bootstrap[i] <- mean(sample(nor_brown$FireFreq[nor_brown$time_period=="Historical"], length(nor_brown$FireFreq[nor_brown$time_period=="Contemporary"]), replace=FALSE)) } mean(nor_brown_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data nor_brown_FireFreq <- length(nor_brown_hist_bootstrap[nor_brown_hist_bootstrap>=nor_brown_contemp_FireFreq])/10000 ## MaxTemp nor_brown <- df[ which(df$species=="Northern brown bandicoot"), ] nor_brown_contemp_MaxTemp <- mean(nor_brown$MaxTemp[nor_brown$time_period=="Contemporary"]) # Get bootstraps of historical data nor_brown_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(nor_brown_hist_bootstrap)){ nor_brown_hist_bootstrap[i] <- mean(sample(nor_brown$MaxTemp[nor_brown$time_period=="Historical"], length(nor_brown$MaxTemp[nor_brown$time_period=="Contemporary"]), replace=FALSE)) } mean(nor_brown_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data nor_brown_MaxTemp <- length(nor_brown_hist_bootstrap[nor_brown_hist_bootstrap>=nor_brown_contemp_MaxTemp])/10000 ## MinTemp nor_brown <- df[ which(df$species=="Northern brown bandicoot"), ] nor_brown_contemp_MinTemp <- mean(nor_brown$MinTemp[nor_brown$time_period=="Contemporary"]) # Get bootstraps of historical data nor_brown_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(nor_brown_hist_bootstrap)){ nor_brown_hist_bootstrap[i] <- mean(sample(nor_brown$MinTemp[nor_brown$time_period=="Historical"], length(nor_brown$MinTemp[nor_brown$time_period=="Contemporary"]), replace=FALSE)) } mean(nor_brown_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data nor_brown_MinTemp <- length(nor_brown_hist_bootstrap[nor_brown_hist_bootstrap>=nor_brown_contemp_MinTemp])/10000 ## TRI nor_brown <- df[ which(df$species=="Northern brown bandicoot"), ] nor_brown_contemp_TRI <- mean(nor_brown$TRI[nor_brown$time_period=="Contemporary"]) # Get bootstraps of historical data nor_brown_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(nor_brown_hist_bootstrap)){ nor_brown_hist_bootstrap[i] <- mean(sample(nor_brown$TRI[nor_brown$time_period=="Historical"], length(nor_brown$TRI[nor_brown$time_period=="Contemporary"]), replace=FALSE)) } mean(nor_brown_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data nor_brown_TRI <- length(nor_brown_hist_bootstrap[nor_brown_hist_bootstrap>=nor_brown_contemp_TRI])/10000 ## TWI nor_brown <- df[ which(df$species=="Northern brown bandicoot"), ] nor_brown_contemp_TWI <- mean(nor_brown$TWI[nor_brown$time_period=="Contemporary"]) # Get bootstraps of historical data nor_brown_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(nor_brown_hist_bootstrap)){ nor_brown_hist_bootstrap[i] <- mean(sample(nor_brown$TWI[nor_brown$time_period=="Historical"], length(nor_brown$TWI[nor_brown$time_period=="Contemporary"]), replace=FALSE)) } mean(nor_brown_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data nor_brown_TWI <- length(nor_brown_hist_bootstrap[nor_brown_hist_bootstrap>=nor_brown_contemp_TWI])/10000 ## VegCover nor_brown <- df[ which(df$species=="Northern brown bandicoot"), ] nor_brown_contemp_VegCover <- mean(nor_brown$VegCover[nor_brown$time_period=="Contemporary"]) # Get bootstraps of historical data nor_brown_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(nor_brown_hist_bootstrap)){ nor_brown_hist_bootstrap[i] <- mean(sample(nor_brown$VegCover[nor_brown$time_period=="Historical"], length(nor_brown$VegCover[nor_brown$time_period=="Contemporary"]), replace=FALSE)) } mean(nor_brown_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data nor_brown_VegCover <- length(nor_brown_hist_bootstrap[nor_brown_hist_bootstrap>=nor_brown_contemp_VegCover])/10000 # Get vector of results for each variable nor_brown <- c(nor_brown_Rainfall, nor_brown_Elevation, nor_brown_FireFreq, nor_brown_MaxTemp, nor_brown_MinTemp, nor_brown_TRI, nor_brown_TWI, nor_brown_VegCover) ################### ### Black-footed tree-rats ## Rainfall mes_gould <- df[ which(df$species=="Black-footed tree-rat"), ] mes_gould_contemp_Rainfall <- mean(mes_gould$Rainfall[mes_gould$time_period=="Contemporary"]) # Get bootstraps of historical data mes_gould_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(mes_gould_hist_bootstrap)){ mes_gould_hist_bootstrap[i] <- mean(sample(mes_gould$Rainfall[mes_gould$time_period=="Historical"], length(mes_gould$Rainfall[mes_gould$time_period=="Contemporary"]), replace=FALSE)) } mean(mes_gould_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data mes_gould_Rainfall <- length(mes_gould_hist_bootstrap[mes_gould_hist_bootstrap>=mes_gould_contemp_Rainfall])/10000 ## Elevation mes_gould <- df[ which(df$species=="Black-footed tree-rat"), ] mes_gould_contemp_Elevation <- mean(mes_gould$Elevation[mes_gould$time_period=="Contemporary"]) # Get bootstraps of historical data mes_gould_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(mes_gould_hist_bootstrap)){ mes_gould_hist_bootstrap[i] <- mean(sample(mes_gould$Elevation[mes_gould$time_period=="Historical"], length(mes_gould$Elevation[mes_gould$time_period=="Contemporary"]), replace=FALSE)) } mean(mes_gould_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data mes_gould_Elevation <- length(mes_gould_hist_bootstrap[mes_gould_hist_bootstrap>=mes_gould_contemp_Elevation])/10000 ## FireFreq mes_gould <- df[ which(df$species=="Black-footed tree-rat"), ] mes_gould_contemp_FireFreq <- mean(mes_gould$FireFreq[mes_gould$time_period=="Contemporary"]) # Get bootstraps of historical data mes_gould_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(mes_gould_hist_bootstrap)){ mes_gould_hist_bootstrap[i] <- mean(sample(mes_gould$FireFreq[mes_gould$time_period=="Historical"], length(mes_gould$FireFreq[mes_gould$time_period=="Contemporary"]), replace=FALSE)) } mean(mes_gould_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data mes_gould_FireFreq <- length(mes_gould_hist_bootstrap[mes_gould_hist_bootstrap>=mes_gould_contemp_FireFreq])/10000 ## FireFreq mes_gould <- df[ which(df$species=="Black-footed tree-rat"), ] mes_gould_contemp_FireFreq <- mean(mes_gould$FireFreq[mes_gould$time_period=="Contemporary"]) # Get bootstraps of historical data mes_gould_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(mes_gould_hist_bootstrap)){ mes_gould_hist_bootstrap[i] <- mean(sample(mes_gould$FireFreq[mes_gould$time_period=="Historical"], length(mes_gould$FireFreq[mes_gould$time_period=="Contemporary"]), replace=FALSE)) } mean(mes_gould_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data mes_gould_FireFreq <- length(mes_gould_hist_bootstrap[mes_gould_hist_bootstrap>=mes_gould_contemp_FireFreq])/10000 ## MaxTemp mes_gould <- df[ which(df$species=="Black-footed tree-rat"), ] mes_gould_contemp_MaxTemp <- mean(mes_gould$MaxTemp[mes_gould$time_period=="Contemporary"]) # Get bootstraps of historical data mes_gould_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(mes_gould_hist_bootstrap)){ mes_gould_hist_bootstrap[i] <- mean(sample(mes_gould$MaxTemp[mes_gould$time_period=="Historical"], length(mes_gould$MaxTemp[mes_gould$time_period=="Contemporary"]), replace=FALSE)) } mean(mes_gould_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data mes_gould_MaxTemp <- length(mes_gould_hist_bootstrap[mes_gould_hist_bootstrap>=mes_gould_contemp_MaxTemp])/10000 ## MinTemp mes_gould <- df[ which(df$species=="Black-footed tree-rat"), ] mes_gould_contemp_MinTemp <- mean(mes_gould$MinTemp[mes_gould$time_period=="Contemporary"]) # Get bootstraps of historical data mes_gould_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(mes_gould_hist_bootstrap)){ mes_gould_hist_bootstrap[i] <- mean(sample(mes_gould$MinTemp[mes_gould$time_period=="Historical"], length(mes_gould$MinTemp[mes_gould$time_period=="Contemporary"]), replace=FALSE)) } mean(mes_gould_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data mes_gould_MinTemp <- length(mes_gould_hist_bootstrap[mes_gould_hist_bootstrap>=mes_gould_contemp_MinTemp])/10000 ## TRI mes_gould <- df[ which(df$species=="Black-footed tree-rat"), ] mes_gould_contemp_TRI <- mean(mes_gould$TRI[mes_gould$time_period=="Contemporary"]) # Get bootstraps of historical data mes_gould_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(mes_gould_hist_bootstrap)){ mes_gould_hist_bootstrap[i] <- mean(sample(mes_gould$TRI[mes_gould$time_period=="Historical"], length(mes_gould$TRI[mes_gould$time_period=="Contemporary"]), replace=FALSE)) } mean(mes_gould_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data mes_gould_TRI <- length(mes_gould_hist_bootstrap[mes_gould_hist_bootstrap>=mes_gould_contemp_TRI])/10000 ## TWI mes_gould <- df[ which(df$species=="Black-footed tree-rat"), ] mes_gould_contemp_TWI <- mean(mes_gould$TWI[mes_gould$time_period=="Contemporary"]) # Get bootstraps of historical data mes_gould_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(mes_gould_hist_bootstrap)){ mes_gould_hist_bootstrap[i] <- mean(sample(mes_gould$TWI[mes_gould$time_period=="Historical"], length(mes_gould$TWI[mes_gould$time_period=="Contemporary"]), replace=FALSE)) } mean(mes_gould_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data mes_gould_TWI <- length(mes_gould_hist_bootstrap[mes_gould_hist_bootstrap>=mes_gould_contemp_TWI])/10000 ## VegCover mes_gould <- df[ which(df$species=="Black-footed tree-rat"), ] mes_gould_contemp_VegCover <- mean(mes_gould$VegCover[mes_gould$time_period=="Contemporary"]) # Get bootstraps of historical data mes_gould_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(mes_gould_hist_bootstrap)){ mes_gould_hist_bootstrap[i] <- mean(sample(mes_gould$VegCover[mes_gould$time_period=="Historical"], length(mes_gould$VegCover[mes_gould$time_period=="Contemporary"]), replace=FALSE)) } mean(mes_gould_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data mes_gould_VegCover <- length(mes_gould_hist_bootstrap[mes_gould_hist_bootstrap>=mes_gould_contemp_VegCover])/10000 # Get vector of results for each variable mes_gould <- c(mes_gould_Rainfall, mes_gould_Elevation, mes_gould_FireFreq, mes_gould_MaxTemp, mes_gould_MinTemp, mes_gould_TRI, mes_gould_TWI, mes_gould_VegCover) ################### ### Sugar gliders ## Rainfall pet_brev <- df[ which(df$species=="Sugar glider"), ] pet_brev_contemp_Rainfall <- mean(pet_brev$Rainfall[pet_brev$time_period=="Contemporary"]) # Get bootstraps of historical data pet_brev_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(pet_brev_hist_bootstrap)){ pet_brev_hist_bootstrap[i] <- mean(sample(pet_brev$Rainfall[pet_brev$time_period=="Historical"], length(pet_brev$Rainfall[pet_brev$time_period=="Contemporary"]), replace=FALSE)) } mean(pet_brev_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data pet_brev_Rainfall <- length(pet_brev_hist_bootstrap[pet_brev_hist_bootstrap>=pet_brev_contemp_Rainfall])/10000 ## Elevation pet_brev <- df[ which(df$species=="Sugar glider"), ] pet_brev_contemp_Elevation <- mean(pet_brev$Elevation[pet_brev$time_period=="Contemporary"]) # Get bootstraps of historical data pet_brev_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(pet_brev_hist_bootstrap)){ pet_brev_hist_bootstrap[i] <- mean(sample(pet_brev$Elevation[pet_brev$time_period=="Historical"], length(pet_brev$Elevation[pet_brev$time_period=="Contemporary"]), replace=FALSE)) } mean(pet_brev_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data pet_brev_Elevation <- length(pet_brev_hist_bootstrap[pet_brev_hist_bootstrap>=pet_brev_contemp_Elevation])/10000 ## FireFreq pet_brev <- df[ which(df$species=="Sugar glider"), ] pet_brev_contemp_FireFreq <- mean(pet_brev$FireFreq[pet_brev$time_period=="Contemporary"]) # Get bootstraps of historical data pet_brev_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(pet_brev_hist_bootstrap)){ pet_brev_hist_bootstrap[i] <- mean(sample(pet_brev$FireFreq[pet_brev$time_period=="Historical"], length(pet_brev$FireFreq[pet_brev$time_period=="Contemporary"]), replace=FALSE)) } mean(pet_brev_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data pet_brev_FireFreq <- length(pet_brev_hist_bootstrap[pet_brev_hist_bootstrap>=pet_brev_contemp_FireFreq])/10000 ## FireFreq pet_brev <- df[ which(df$species=="Sugar glider"), ] pet_brev_contemp_FireFreq <- mean(pet_brev$FireFreq[pet_brev$time_period=="Contemporary"]) # Get bootstraps of historical data pet_brev_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(pet_brev_hist_bootstrap)){ pet_brev_hist_bootstrap[i] <- mean(sample(pet_brev$FireFreq[pet_brev$time_period=="Historical"], length(pet_brev$FireFreq[pet_brev$time_period=="Contemporary"]), replace=FALSE)) } mean(pet_brev_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data pet_brev_FireFreq <- length(pet_brev_hist_bootstrap[pet_brev_hist_bootstrap>=pet_brev_contemp_FireFreq])/10000 ## MaxTemp pet_brev <- df[ which(df$species=="Sugar glider"), ] pet_brev_contemp_MaxTemp <- mean(pet_brev$MaxTemp[pet_brev$time_period=="Contemporary"]) # Get bootstraps of historical data pet_brev_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(pet_brev_hist_bootstrap)){ pet_brev_hist_bootstrap[i] <- mean(sample(pet_brev$MaxTemp[pet_brev$time_period=="Historical"], length(pet_brev$MaxTemp[pet_brev$time_period=="Contemporary"]), replace=FALSE)) } mean(pet_brev_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data pet_brev_MaxTemp <- length(pet_brev_hist_bootstrap[pet_brev_hist_bootstrap>=pet_brev_contemp_MaxTemp])/10000 ## MinTemp pet_brev <- df[ which(df$species=="Sugar glider"), ] pet_brev_contemp_MinTemp <- mean(pet_brev$MinTemp[pet_brev$time_period=="Contemporary"]) # Get bootstraps of historical data pet_brev_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(pet_brev_hist_bootstrap)){ pet_brev_hist_bootstrap[i] <- mean(sample(pet_brev$MinTemp[pet_brev$time_period=="Historical"], length(pet_brev$MinTemp[pet_brev$time_period=="Contemporary"]), replace=FALSE)) } mean(pet_brev_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data pet_brev_MinTemp <- length(pet_brev_hist_bootstrap[pet_brev_hist_bootstrap>=pet_brev_contemp_MinTemp])/10000 ## TRI pet_brev <- df[ which(df$species=="Sugar glider"), ] pet_brev_contemp_TRI <- mean(pet_brev$TRI[pet_brev$time_period=="Contemporary"]) # Get bootstraps of historical data pet_brev_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(pet_brev_hist_bootstrap)){ pet_brev_hist_bootstrap[i] <- mean(sample(pet_brev$TRI[pet_brev$time_period=="Historical"], length(pet_brev$TRI[pet_brev$time_period=="Contemporary"]), replace=FALSE)) } mean(pet_brev_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data pet_brev_TRI <- length(pet_brev_hist_bootstrap[pet_brev_hist_bootstrap>=pet_brev_contemp_TRI])/10000 ## TWI pet_brev <- df[ which(df$species=="Sugar glider"), ] pet_brev_contemp_TWI <- mean(pet_brev$TWI[pet_brev$time_period=="Contemporary"]) # Get bootstraps of historical data pet_brev_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(pet_brev_hist_bootstrap)){ pet_brev_hist_bootstrap[i] <- mean(sample(pet_brev$TWI[pet_brev$time_period=="Historical"], length(pet_brev$TWI[pet_brev$time_period=="Contemporary"]), replace=FALSE)) } mean(pet_brev_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data pet_brev_TWI <- length(pet_brev_hist_bootstrap[pet_brev_hist_bootstrap>=pet_brev_contemp_TWI])/10000 ## VegCover pet_brev <- df[ which(df$species=="Sugar glider"), ] pet_brev_contemp_VegCover <- mean(pet_brev$VegCover[pet_brev$time_period=="Contemporary"]) # Get bootstraps of historical data pet_brev_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(pet_brev_hist_bootstrap)){ pet_brev_hist_bootstrap[i] <- mean(sample(pet_brev$VegCover[pet_brev$time_period=="Historical"], length(pet_brev$VegCover[pet_brev$time_period=="Contemporary"]), replace=FALSE)) } mean(pet_brev_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data pet_brev_VegCover <- length(pet_brev_hist_bootstrap[pet_brev_hist_bootstrap>=pet_brev_contemp_VegCover])/10000 # Get vector of results for each variable pet_brev <- c(pet_brev_Rainfall, pet_brev_Elevation, pet_brev_FireFreq, pet_brev_MaxTemp, pet_brev_MinTemp, pet_brev_TRI, pet_brev_TWI, pet_brev_VegCover) ################### ### Western chestnut mouses ## Rainfall pseud_nan <- df[ which(df$species=="Western chestnut mouse"), ] pseud_nan_contemp_Rainfall <- mean(pseud_nan$Rainfall[pseud_nan$time_period=="Contemporary"]) # Get bootstraps of historical data pseud_nan_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(pseud_nan_hist_bootstrap)){ pseud_nan_hist_bootstrap[i] <- mean(sample(pseud_nan$Rainfall[pseud_nan$time_period=="Historical"], length(pseud_nan$Rainfall[pseud_nan$time_period=="Contemporary"]), replace=FALSE)) } mean(pseud_nan_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data pseud_nan_Rainfall <- length(pseud_nan_hist_bootstrap[pseud_nan_hist_bootstrap>=pseud_nan_contemp_Rainfall])/10000 ## Elevation pseud_nan <- df[ which(df$species=="Western chestnut mouse"), ] pseud_nan_contemp_Elevation <- mean(pseud_nan$Elevation[pseud_nan$time_period=="Contemporary"]) # Get bootstraps of historical data pseud_nan_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(pseud_nan_hist_bootstrap)){ pseud_nan_hist_bootstrap[i] <- mean(sample(pseud_nan$Elevation[pseud_nan$time_period=="Historical"], length(pseud_nan$Elevation[pseud_nan$time_period=="Contemporary"]), replace=FALSE)) } mean(pseud_nan_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data pseud_nan_Elevation <- length(pseud_nan_hist_bootstrap[pseud_nan_hist_bootstrap>=pseud_nan_contemp_Elevation])/10000 ## FireFreq pseud_nan <- df[ which(df$species=="Western chestnut mouse"), ] pseud_nan_contemp_FireFreq <- mean(pseud_nan$FireFreq[pseud_nan$time_period=="Contemporary"]) # Get bootstraps of historical data pseud_nan_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(pseud_nan_hist_bootstrap)){ pseud_nan_hist_bootstrap[i] <- mean(sample(pseud_nan$FireFreq[pseud_nan$time_period=="Historical"], length(pseud_nan$FireFreq[pseud_nan$time_period=="Contemporary"]), replace=FALSE)) } mean(pseud_nan_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data pseud_nan_FireFreq <- length(pseud_nan_hist_bootstrap[pseud_nan_hist_bootstrap>=pseud_nan_contemp_FireFreq])/10000 ## FireFreq pseud_nan <- df[ which(df$species=="Western chestnut mouse"), ] pseud_nan_contemp_FireFreq <- mean(pseud_nan$FireFreq[pseud_nan$time_period=="Contemporary"]) # Get bootstraps of historical data pseud_nan_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(pseud_nan_hist_bootstrap)){ pseud_nan_hist_bootstrap[i] <- mean(sample(pseud_nan$FireFreq[pseud_nan$time_period=="Historical"], length(pseud_nan$FireFreq[pseud_nan$time_period=="Contemporary"]), replace=FALSE)) } mean(pseud_nan_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data pseud_nan_FireFreq <- length(pseud_nan_hist_bootstrap[pseud_nan_hist_bootstrap>=pseud_nan_contemp_FireFreq])/10000 ## MaxTemp pseud_nan <- df[ which(df$species=="Western chestnut mouse"), ] pseud_nan_contemp_MaxTemp <- mean(pseud_nan$MaxTemp[pseud_nan$time_period=="Contemporary"]) # Get bootstraps of historical data pseud_nan_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(pseud_nan_hist_bootstrap)){ pseud_nan_hist_bootstrap[i] <- mean(sample(pseud_nan$MaxTemp[pseud_nan$time_period=="Historical"], length(pseud_nan$MaxTemp[pseud_nan$time_period=="Contemporary"]), replace=FALSE)) } mean(pseud_nan_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data pseud_nan_MaxTemp <- length(pseud_nan_hist_bootstrap[pseud_nan_hist_bootstrap>=pseud_nan_contemp_MaxTemp])/10000 ## MinTemp pseud_nan <- df[ which(df$species=="Western chestnut mouse"), ] pseud_nan_contemp_MinTemp <- mean(pseud_nan$MinTemp[pseud_nan$time_period=="Contemporary"]) # Get bootstraps of historical data pseud_nan_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(pseud_nan_hist_bootstrap)){ pseud_nan_hist_bootstrap[i] <- mean(sample(pseud_nan$MinTemp[pseud_nan$time_period=="Historical"], length(pseud_nan$MinTemp[pseud_nan$time_period=="Contemporary"]), replace=FALSE)) } mean(pseud_nan_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data pseud_nan_MinTemp <- length(pseud_nan_hist_bootstrap[pseud_nan_hist_bootstrap>=pseud_nan_contemp_MinTemp])/10000 ## TRI pseud_nan <- df[ which(df$species=="Western chestnut mouse"), ] pseud_nan_contemp_TRI <- mean(pseud_nan$TRI[pseud_nan$time_period=="Contemporary"]) # Get bootstraps of historical data pseud_nan_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(pseud_nan_hist_bootstrap)){ pseud_nan_hist_bootstrap[i] <- mean(sample(pseud_nan$TRI[pseud_nan$time_period=="Historical"], length(pseud_nan$TRI[pseud_nan$time_period=="Contemporary"]), replace=FALSE)) } mean(pseud_nan_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data pseud_nan_TRI <- length(pseud_nan_hist_bootstrap[pseud_nan_hist_bootstrap>=pseud_nan_contemp_TRI])/10000 ## TWI pseud_nan <- df[ which(df$species=="Western chestnut mouse"), ] pseud_nan_contemp_TWI <- mean(pseud_nan$TWI[pseud_nan$time_period=="Contemporary"]) # Get bootstraps of historical data pseud_nan_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(pseud_nan_hist_bootstrap)){ pseud_nan_hist_bootstrap[i] <- mean(sample(pseud_nan$TWI[pseud_nan$time_period=="Historical"], length(pseud_nan$TWI[pseud_nan$time_period=="Contemporary"]), replace=FALSE)) } mean(pseud_nan_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data pseud_nan_TWI <- length(pseud_nan_hist_bootstrap[pseud_nan_hist_bootstrap>=pseud_nan_contemp_TWI])/10000 ## VegCover pseud_nan <- df[ which(df$species=="Western chestnut mouse"), ] pseud_nan_contemp_VegCover <- mean(pseud_nan$VegCover[pseud_nan$time_period=="Contemporary"]) # Get bootstraps of historical data pseud_nan_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(pseud_nan_hist_bootstrap)){ pseud_nan_hist_bootstrap[i] <- mean(sample(pseud_nan$VegCover[pseud_nan$time_period=="Historical"], length(pseud_nan$VegCover[pseud_nan$time_period=="Contemporary"]), replace=FALSE)) } mean(pseud_nan_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data pseud_nan_VegCover <- length(pseud_nan_hist_bootstrap[pseud_nan_hist_bootstrap>=pseud_nan_contemp_VegCover])/10000 # Get vector of results for each variable pseud_nan <- c(pseud_nan_Rainfall, pseud_nan_Elevation, pseud_nan_FireFreq, pseud_nan_MaxTemp, pseud_nan_MinTemp, pseud_nan_TRI, pseud_nan_TWI, pseud_nan_VegCover) ################### ### Pale field rats ## Rainfall rat_tun <- df[ which(df$species=="Pale field rat"), ] rat_tun_contemp_Rainfall <- mean(rat_tun$Rainfall[rat_tun$time_period=="Contemporary"]) # Get bootstraps of historical data rat_tun_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(rat_tun_hist_bootstrap)){ rat_tun_hist_bootstrap[i] <- mean(sample(rat_tun$Rainfall[rat_tun$time_period=="Historical"], length(rat_tun$Rainfall[rat_tun$time_period=="Contemporary"]), replace=FALSE)) } mean(rat_tun_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data rat_tun_Rainfall <- length(rat_tun_hist_bootstrap[rat_tun_hist_bootstrap>=rat_tun_contemp_Rainfall])/10000 ## Elevation rat_tun <- df[ which(df$species=="Pale field rat"), ] rat_tun_contemp_Elevation <- mean(rat_tun$Elevation[rat_tun$time_period=="Contemporary"]) # Get bootstraps of historical data rat_tun_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(rat_tun_hist_bootstrap)){ rat_tun_hist_bootstrap[i] <- mean(sample(rat_tun$Elevation[rat_tun$time_period=="Historical"], length(rat_tun$Elevation[rat_tun$time_period=="Contemporary"]), replace=FALSE)) } mean(rat_tun_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data rat_tun_Elevation <- length(rat_tun_hist_bootstrap[rat_tun_hist_bootstrap>=rat_tun_contemp_Elevation])/10000 ## FireFreq rat_tun <- df[ which(df$species=="Pale field rat"), ] rat_tun_contemp_FireFreq <- mean(rat_tun$FireFreq[rat_tun$time_period=="Contemporary"]) # Get bootstraps of historical data rat_tun_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(rat_tun_hist_bootstrap)){ rat_tun_hist_bootstrap[i] <- mean(sample(rat_tun$FireFreq[rat_tun$time_period=="Historical"], length(rat_tun$FireFreq[rat_tun$time_period=="Contemporary"]), replace=FALSE)) } mean(rat_tun_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data rat_tun_FireFreq <- length(rat_tun_hist_bootstrap[rat_tun_hist_bootstrap>=rat_tun_contemp_FireFreq])/10000 ## FireFreq rat_tun <- df[ which(df$species=="Pale field rat"), ] rat_tun_contemp_FireFreq <- mean(rat_tun$FireFreq[rat_tun$time_period=="Contemporary"]) # Get bootstraps of historical data rat_tun_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(rat_tun_hist_bootstrap)){ rat_tun_hist_bootstrap[i] <- mean(sample(rat_tun$FireFreq[rat_tun$time_period=="Historical"], length(rat_tun$FireFreq[rat_tun$time_period=="Contemporary"]), replace=FALSE)) } mean(rat_tun_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data rat_tun_FireFreq <- length(rat_tun_hist_bootstrap[rat_tun_hist_bootstrap>=rat_tun_contemp_FireFreq])/10000 ## MaxTemp rat_tun <- df[ which(df$species=="Pale field rat"), ] rat_tun_contemp_MaxTemp <- mean(rat_tun$MaxTemp[rat_tun$time_period=="Contemporary"]) # Get bootstraps of historical data rat_tun_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(rat_tun_hist_bootstrap)){ rat_tun_hist_bootstrap[i] <- mean(sample(rat_tun$MaxTemp[rat_tun$time_period=="Historical"], length(rat_tun$MaxTemp[rat_tun$time_period=="Contemporary"]), replace=FALSE)) } mean(rat_tun_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data rat_tun_MaxTemp <- length(rat_tun_hist_bootstrap[rat_tun_hist_bootstrap>=rat_tun_contemp_MaxTemp])/10000 ## MinTemp rat_tun <- df[ which(df$species=="Pale field rat"), ] rat_tun_contemp_MinTemp <- mean(rat_tun$MinTemp[rat_tun$time_period=="Contemporary"]) # Get bootstraps of historical data rat_tun_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(rat_tun_hist_bootstrap)){ rat_tun_hist_bootstrap[i] <- mean(sample(rat_tun$MinTemp[rat_tun$time_period=="Historical"], length(rat_tun$MinTemp[rat_tun$time_period=="Contemporary"]), replace=FALSE)) } mean(rat_tun_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data rat_tun_MinTemp <- length(rat_tun_hist_bootstrap[rat_tun_hist_bootstrap>=rat_tun_contemp_MinTemp])/10000 ## TRI rat_tun <- df[ which(df$species=="Pale field rat"), ] rat_tun_contemp_TRI <- mean(rat_tun$TRI[rat_tun$time_period=="Contemporary"]) # Get bootstraps of historical data rat_tun_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(rat_tun_hist_bootstrap)){ rat_tun_hist_bootstrap[i] <- mean(sample(rat_tun$TRI[rat_tun$time_period=="Historical"], length(rat_tun$TRI[rat_tun$time_period=="Contemporary"]), replace=FALSE)) } mean(rat_tun_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data rat_tun_TRI <- length(rat_tun_hist_bootstrap[rat_tun_hist_bootstrap>=rat_tun_contemp_TRI])/10000 ## TWI rat_tun <- df[ which(df$species=="Pale field rat"), ] rat_tun_contemp_TWI <- mean(rat_tun$TWI[rat_tun$time_period=="Contemporary"]) # Get bootstraps of historical data rat_tun_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(rat_tun_hist_bootstrap)){ rat_tun_hist_bootstrap[i] <- mean(sample(rat_tun$TWI[rat_tun$time_period=="Historical"], length(rat_tun$TWI[rat_tun$time_period=="Contemporary"]), replace=FALSE)) } mean(rat_tun_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data rat_tun_TWI <- length(rat_tun_hist_bootstrap[rat_tun_hist_bootstrap>=rat_tun_contemp_TWI])/10000 ## VegCover rat_tun <- df[ which(df$species=="Pale field rat"), ] rat_tun_contemp_VegCover <- mean(rat_tun$VegCover[rat_tun$time_period=="Contemporary"]) # Get bootstraps of historical data rat_tun_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(rat_tun_hist_bootstrap)){ rat_tun_hist_bootstrap[i] <- mean(sample(rat_tun$VegCover[rat_tun$time_period=="Historical"], length(rat_tun$VegCover[rat_tun$time_period=="Contemporary"]), replace=FALSE)) } mean(rat_tun_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data rat_tun_VegCover <- length(rat_tun_hist_bootstrap[rat_tun_hist_bootstrap>=rat_tun_contemp_VegCover])/10000 # Get vector of results for each variable rat_tun <- c(rat_tun_Rainfall, rat_tun_Elevation, rat_tun_FireFreq, rat_tun_MaxTemp, rat_tun_MinTemp, rat_tun_TRI, rat_tun_TWI, rat_tun_VegCover) ################### ### Pale field rats ## Rainfall rat_tun <- df[ which(df$species=="Pale field rat"), ] rat_tun_contemp_Rainfall <- mean(rat_tun$Rainfall[rat_tun$time_period=="Contemporary"]) # Get bootstraps of historical data rat_tun_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(rat_tun_hist_bootstrap)){ rat_tun_hist_bootstrap[i] <- mean(sample(rat_tun$Rainfall[rat_tun$time_period=="Historical"], length(rat_tun$Rainfall[rat_tun$time_period=="Contemporary"]), replace=FALSE)) } mean(rat_tun_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data rat_tun_Rainfall <- length(rat_tun_hist_bootstrap[rat_tun_hist_bootstrap>=rat_tun_contemp_Rainfall])/10000 ## Elevation rat_tun <- df[ which(df$species=="Pale field rat"), ] rat_tun_contemp_Elevation <- mean(rat_tun$Elevation[rat_tun$time_period=="Contemporary"]) # Get bootstraps of historical data rat_tun_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(rat_tun_hist_bootstrap)){ rat_tun_hist_bootstrap[i] <- mean(sample(rat_tun$Elevation[rat_tun$time_period=="Historical"], length(rat_tun$Elevation[rat_tun$time_period=="Contemporary"]), replace=FALSE)) } mean(rat_tun_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data rat_tun_Elevation <- length(rat_tun_hist_bootstrap[rat_tun_hist_bootstrap>=rat_tun_contemp_Elevation])/10000 ## FireFreq rat_tun <- df[ which(df$species=="Pale field rat"), ] rat_tun_contemp_FireFreq <- mean(rat_tun$FireFreq[rat_tun$time_period=="Contemporary"]) # Get bootstraps of historical data rat_tun_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(rat_tun_hist_bootstrap)){ rat_tun_hist_bootstrap[i] <- mean(sample(rat_tun$FireFreq[rat_tun$time_period=="Historical"], length(rat_tun$FireFreq[rat_tun$time_period=="Contemporary"]), replace=FALSE)) } mean(rat_tun_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data rat_tun_FireFreq <- length(rat_tun_hist_bootstrap[rat_tun_hist_bootstrap>=rat_tun_contemp_FireFreq])/10000 ## FireFreq rat_tun <- df[ which(df$species=="Pale field rat"), ] rat_tun_contemp_FireFreq <- mean(rat_tun$FireFreq[rat_tun$time_period=="Contemporary"]) # Get bootstraps of historical data rat_tun_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(rat_tun_hist_bootstrap)){ rat_tun_hist_bootstrap[i] <- mean(sample(rat_tun$FireFreq[rat_tun$time_period=="Historical"], length(rat_tun$FireFreq[rat_tun$time_period=="Contemporary"]), replace=FALSE)) } mean(rat_tun_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data rat_tun_FireFreq <- length(rat_tun_hist_bootstrap[rat_tun_hist_bootstrap>=rat_tun_contemp_FireFreq])/10000 ## MaxTemp rat_tun <- df[ which(df$species=="Pale field rat"), ] rat_tun_contemp_MaxTemp <- mean(rat_tun$MaxTemp[rat_tun$time_period=="Contemporary"]) # Get bootstraps of historical data rat_tun_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(rat_tun_hist_bootstrap)){ rat_tun_hist_bootstrap[i] <- mean(sample(rat_tun$MaxTemp[rat_tun$time_period=="Historical"], length(rat_tun$MaxTemp[rat_tun$time_period=="Contemporary"]), replace=FALSE)) } mean(rat_tun_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data rat_tun_MaxTemp <- length(rat_tun_hist_bootstrap[rat_tun_hist_bootstrap>=rat_tun_contemp_MaxTemp])/10000 ## MinTemp rat_tun <- df[ which(df$species=="Pale field rat"), ] rat_tun_contemp_MinTemp <- mean(rat_tun$MinTemp[rat_tun$time_period=="Contemporary"]) # Get bootstraps of historical data rat_tun_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(rat_tun_hist_bootstrap)){ rat_tun_hist_bootstrap[i] <- mean(sample(rat_tun$MinTemp[rat_tun$time_period=="Historical"], length(rat_tun$MinTemp[rat_tun$time_period=="Contemporary"]), replace=FALSE)) } mean(rat_tun_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data rat_tun_MinTemp <- length(rat_tun_hist_bootstrap[rat_tun_hist_bootstrap>=rat_tun_contemp_MinTemp])/10000 ## TRI rat_tun <- df[ which(df$species=="Pale field rat"), ] rat_tun_contemp_TRI <- mean(rat_tun$TRI[rat_tun$time_period=="Contemporary"]) # Get bootstraps of historical data rat_tun_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(rat_tun_hist_bootstrap)){ rat_tun_hist_bootstrap[i] <- mean(sample(rat_tun$TRI[rat_tun$time_period=="Historical"], length(rat_tun$TRI[rat_tun$time_period=="Contemporary"]), replace=FALSE)) } mean(rat_tun_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data rat_tun_TRI <- length(rat_tun_hist_bootstrap[rat_tun_hist_bootstrap>=rat_tun_contemp_TRI])/10000 ## TWI rat_tun <- df[ which(df$species=="Pale field rat"), ] rat_tun_contemp_TWI <- mean(rat_tun$TWI[rat_tun$time_period=="Contemporary"]) # Get bootstraps of historical data rat_tun_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(rat_tun_hist_bootstrap)){ rat_tun_hist_bootstrap[i] <- mean(sample(rat_tun$TWI[rat_tun$time_period=="Historical"], length(rat_tun$TWI[rat_tun$time_period=="Contemporary"]), replace=FALSE)) } mean(rat_tun_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data rat_tun_TWI <- length(rat_tun_hist_bootstrap[rat_tun_hist_bootstrap>=rat_tun_contemp_TWI])/10000 ## VegCover rat_tun <- df[ which(df$species=="Pale field rat"), ] rat_tun_contemp_VegCover <- mean(rat_tun$VegCover[rat_tun$time_period=="Contemporary"]) # Get bootstraps of historical data rat_tun_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(rat_tun_hist_bootstrap)){ rat_tun_hist_bootstrap[i] <- mean(sample(rat_tun$VegCover[rat_tun$time_period=="Historical"], length(rat_tun$VegCover[rat_tun$time_period=="Contemporary"]), replace=FALSE)) } mean(rat_tun_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data rat_tun_VegCover <- length(rat_tun_hist_bootstrap[rat_tun_hist_bootstrap>=rat_tun_contemp_VegCover])/10000 # Get vector of results for each variable rat_tun <- c(rat_tun_Rainfall, rat_tun_Elevation, rat_tun_FireFreq, rat_tun_MaxTemp, rat_tun_MinTemp, rat_tun_TRI, rat_tun_TWI, rat_tun_VegCover) ################### ### Common brushtail possums ## Rainfall trich_vul <- df[ which(df$species=="Common brushtail possum"), ] trich_vul_contemp_Rainfall <- mean(trich_vul$Rainfall[trich_vul$time_period=="Contemporary"]) # Get bootstraps of historical data trich_vul_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(trich_vul_hist_bootstrap)){ trich_vul_hist_bootstrap[i] <- mean(sample(trich_vul$Rainfall[trich_vul$time_period=="Historical"], length(trich_vul$Rainfall[trich_vul$time_period=="Contemporary"]), replace=FALSE)) } mean(trich_vul_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data trich_vul_Rainfall <- length(trich_vul_hist_bootstrap[trich_vul_hist_bootstrap>=trich_vul_contemp_Rainfall])/10000 ## Elevation trich_vul <- df[ which(df$species=="Common brushtail possum"), ] trich_vul_contemp_Elevation <- mean(trich_vul$Elevation[trich_vul$time_period=="Contemporary"]) # Get bootstraps of historical data trich_vul_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(trich_vul_hist_bootstrap)){ trich_vul_hist_bootstrap[i] <- mean(sample(trich_vul$Elevation[trich_vul$time_period=="Historical"], length(trich_vul$Elevation[trich_vul$time_period=="Contemporary"]), replace=FALSE)) } mean(trich_vul_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data trich_vul_Elevation <- length(trich_vul_hist_bootstrap[trich_vul_hist_bootstrap>=trich_vul_contemp_Elevation])/10000 ## FireFreq trich_vul <- df[ which(df$species=="Common brushtail possum"), ] trich_vul_contemp_FireFreq <- mean(trich_vul$FireFreq[trich_vul$time_period=="Contemporary"]) # Get bootstraps of historical data trich_vul_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(trich_vul_hist_bootstrap)){ trich_vul_hist_bootstrap[i] <- mean(sample(trich_vul$FireFreq[trich_vul$time_period=="Historical"], length(trich_vul$FireFreq[trich_vul$time_period=="Contemporary"]), replace=FALSE)) } mean(trich_vul_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data trich_vul_FireFreq <- length(trich_vul_hist_bootstrap[trich_vul_hist_bootstrap>=trich_vul_contemp_FireFreq])/10000 ## FireFreq trich_vul <- df[ which(df$species=="Common brushtail possum"), ] trich_vul_contemp_FireFreq <- mean(trich_vul$FireFreq[trich_vul$time_period=="Contemporary"]) # Get bootstraps of historical data trich_vul_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(trich_vul_hist_bootstrap)){ trich_vul_hist_bootstrap[i] <- mean(sample(trich_vul$FireFreq[trich_vul$time_period=="Historical"], length(trich_vul$FireFreq[trich_vul$time_period=="Contemporary"]), replace=FALSE)) } mean(trich_vul_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data trich_vul_FireFreq <- length(trich_vul_hist_bootstrap[trich_vul_hist_bootstrap>=trich_vul_contemp_FireFreq])/10000 ## MaxTemp trich_vul <- df[ which(df$species=="Common brushtail possum"), ] trich_vul_contemp_MaxTemp <- mean(trich_vul$MaxTemp[trich_vul$time_period=="Contemporary"]) # Get bootstraps of historical data trich_vul_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(trich_vul_hist_bootstrap)){ trich_vul_hist_bootstrap[i] <- mean(sample(trich_vul$MaxTemp[trich_vul$time_period=="Historical"], length(trich_vul$MaxTemp[trich_vul$time_period=="Contemporary"]), replace=FALSE)) } mean(trich_vul_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data trich_vul_MaxTemp <- length(trich_vul_hist_bootstrap[trich_vul_hist_bootstrap>=trich_vul_contemp_MaxTemp])/10000 ## MinTemp trich_vul <- df[ which(df$species=="Common brushtail possum"), ] trich_vul_contemp_MinTemp <- mean(trich_vul$MinTemp[trich_vul$time_period=="Contemporary"]) # Get bootstraps of historical data trich_vul_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(trich_vul_hist_bootstrap)){ trich_vul_hist_bootstrap[i] <- mean(sample(trich_vul$MinTemp[trich_vul$time_period=="Historical"], length(trich_vul$MinTemp[trich_vul$time_period=="Contemporary"]), replace=FALSE)) } mean(trich_vul_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data trich_vul_MinTemp <- length(trich_vul_hist_bootstrap[trich_vul_hist_bootstrap>=trich_vul_contemp_MinTemp])/10000 ## TRI trich_vul <- df[ which(df$species=="Common brushtail possum"), ] trich_vul_contemp_TRI <- mean(trich_vul$TRI[trich_vul$time_period=="Contemporary"]) # Get bootstraps of historical data trich_vul_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(trich_vul_hist_bootstrap)){ trich_vul_hist_bootstrap[i] <- mean(sample(trich_vul$TRI[trich_vul$time_period=="Historical"], length(trich_vul$TRI[trich_vul$time_period=="Contemporary"]), replace=FALSE)) } mean(trich_vul_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data trich_vul_TRI <- length(trich_vul_hist_bootstrap[trich_vul_hist_bootstrap>=trich_vul_contemp_TRI])/10000 ## TWI trich_vul <- df[ which(df$species=="Common brushtail possum"), ] trich_vul_contemp_TWI <- mean(trich_vul$TWI[trich_vul$time_period=="Contemporary"]) # Get bootstraps of historical data trich_vul_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(trich_vul_hist_bootstrap)){ trich_vul_hist_bootstrap[i] <- mean(sample(trich_vul$TWI[trich_vul$time_period=="Historical"], length(trich_vul$TWI[trich_vul$time_period=="Contemporary"]), replace=FALSE)) } mean(trich_vul_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data trich_vul_TWI <- length(trich_vul_hist_bootstrap[trich_vul_hist_bootstrap>=trich_vul_contemp_TWI])/10000 ## VegCover trich_vul <- df[ which(df$species=="Common brushtail possum"), ] trich_vul_contemp_VegCover <- mean(trich_vul$VegCover[trich_vul$time_period=="Contemporary"]) # Get bootstraps of historical data trich_vul_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(trich_vul_hist_bootstrap)){ trich_vul_hist_bootstrap[i] <- mean(sample(trich_vul$VegCover[trich_vul$time_period=="Historical"], length(trich_vul$VegCover[trich_vul$time_period=="Contemporary"]), replace=FALSE)) } mean(trich_vul_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data trich_vul_VegCover <- length(trich_vul_hist_bootstrap[trich_vul_hist_bootstrap>=trich_vul_contemp_VegCover])/10000 # Get vector of results for each variable trich_vul <- c(trich_vul_Rainfall, trich_vul_Elevation, trich_vul_FireFreq, trich_vul_MaxTemp, trich_vul_MinTemp, trich_vul_TRI, trich_vul_TWI, trich_vul_VegCover) hist(trich_vul) # Put all into dataframe spp_comp <- as.data.frame(rbind(ante_bel,con_pen,NQ,nor_brown,mes_gould,pet_brev,pseud_nan,rat_tun,trich_vul)) rownames(spp_comp) <- c("Fawn antechinus","Brush-tailed rabbit-rat","Northern quoll","Northern brown bandicoot", "Black-footed tree-rat","Sugar glider","Western chestnut mouse","Pale field rat","Common brushtail possum") colnames(spp_comp) <- c("Rainfall", "Elevation", "FireFreq", "MaxTemp", "MinTemp", "TRI", "TWI", "VegCover") # Output to csv file write.csv(spp_comp,paste("sdms/output/pvals_hist_contemp_presences_",currentDate,".csv",sep=""),row.names=TRUE) ################################################################################################################# ###################################################################### #### Do the same thing but with standard deviation instead of the mean ## Get percentile of old values in new records for each combination of species and env variable df <- read.csv("sdms/output/sampled_pres_points_glms.csv") levels(df$species) colnames(df) ################### ### Northern quolls ## Rainfall nq <- df[ which(df$species=="Northern quoll"), ] nq_contemp_Rainfall <- sd(nq$Rainfall[nq$time_period=="Contemporary"]) # Get bootstraps of historical data nq_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(nq_hist_bootstrap)){ nq_hist_bootstrap[i] <- sd(sample(nq$Rainfall[nq$time_period=="Historical"], length(nq$Rainfall[nq$time_period=="Contemporary"]), replace=FALSE)) } mean(nq_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data nq_Rainfall <- length(nq_hist_bootstrap[nq_hist_bootstrap>=nq_contemp_Rainfall])/10000 ## Elevation nq <- df[ which(df$species=="Northern quoll"), ] nq_contemp_Elevation <- sd(nq$Elevation[nq$time_period=="Contemporary"]) # Get bootstraps of historical data nq_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(nq_hist_bootstrap)){ nq_hist_bootstrap[i] <- sd(sample(nq$Elevation[nq$time_period=="Historical"], length(nq$Elevation[nq$time_period=="Contemporary"]), replace=FALSE)) } mean(nq_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data nq_Elevation <- length(nq_hist_bootstrap[nq_hist_bootstrap>=nq_contemp_Elevation])/10000 ## FireFreq nq <- df[ which(df$species=="Northern quoll"), ] nq_contemp_FireFreq <- sd(nq$FireFreq[nq$time_period=="Contemporary"]) # Get bootstraps of historical data nq_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(nq_hist_bootstrap)){ nq_hist_bootstrap[i] <- sd(sample(nq$FireFreq[nq$time_period=="Historical"], length(nq$FireFreq[nq$time_period=="Contemporary"]), replace=FALSE)) } mean(nq_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data nq_FireFreq <- length(nq_hist_bootstrap[nq_hist_bootstrap>=nq_contemp_FireFreq])/10000 ## FireFreq nq <- df[ which(df$species=="Northern quoll"), ] nq_contemp_FireFreq <- sd(nq$FireFreq[nq$time_period=="Contemporary"]) # Get bootstraps of historical data nq_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(nq_hist_bootstrap)){ nq_hist_bootstrap[i] <- sd(sample(nq$FireFreq[nq$time_period=="Historical"], length(nq$FireFreq[nq$time_period=="Contemporary"]), replace=FALSE)) } mean(nq_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data nq_FireFreq <- length(nq_hist_bootstrap[nq_hist_bootstrap>=nq_contemp_FireFreq])/10000 ## MaxTemp nq <- df[ which(df$species=="Northern quoll"), ] nq_contemp_MaxTemp <- sd(nq$MaxTemp[nq$time_period=="Contemporary"]) # Get bootstraps of historical data nq_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(nq_hist_bootstrap)){ nq_hist_bootstrap[i] <- sd(sample(nq$MaxTemp[nq$time_period=="Historical"], length(nq$MaxTemp[nq$time_period=="Contemporary"]), replace=FALSE)) } mean(nq_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data nq_MaxTemp <- length(nq_hist_bootstrap[nq_hist_bootstrap>=nq_contemp_MaxTemp])/10000 ## MinTemp nq <- df[ which(df$species=="Northern quoll"), ] nq_contemp_MinTemp <- sd(nq$MinTemp[nq$time_period=="Contemporary"]) # Get bootstraps of historical data nq_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(nq_hist_bootstrap)){ nq_hist_bootstrap[i] <- sd(sample(nq$MinTemp[nq$time_period=="Historical"], length(nq$MinTemp[nq$time_period=="Contemporary"]), replace=FALSE)) } mean(nq_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data nq_MinTemp <- length(nq_hist_bootstrap[nq_hist_bootstrap>=nq_contemp_MinTemp])/10000 ## TRI nq <- df[ which(df$species=="Northern quoll"), ] nq_contemp_TRI <- sd(nq$TRI[nq$time_period=="Contemporary"]) # Get bootstraps of historical data nq_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(nq_hist_bootstrap)){ nq_hist_bootstrap[i] <- sd(sample(nq$TRI[nq$time_period=="Historical"], length(nq$TRI[nq$time_period=="Contemporary"]), replace=FALSE)) } mean(nq_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data nq_TRI <- length(nq_hist_bootstrap[nq_hist_bootstrap>=nq_contemp_TRI])/10000 ## TWI nq <- df[ which(df$species=="Northern quoll"), ] nq_contemp_TWI <- sd(nq$TWI[nq$time_period=="Contemporary"]) # Get bootstraps of historical data nq_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(nq_hist_bootstrap)){ nq_hist_bootstrap[i] <- sd(sample(nq$TWI[nq$time_period=="Historical"], length(nq$TWI[nq$time_period=="Contemporary"]), replace=FALSE)) } mean(nq_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data nq_TWI <- length(nq_hist_bootstrap[nq_hist_bootstrap>=nq_contemp_TWI])/10000 ## VegCover nq <- df[ which(df$species=="Northern quoll"), ] nq_contemp_VegCover <- sd(nq$VegCover[nq$time_period=="Contemporary"]) # Get bootstraps of historical data nq_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(nq_hist_bootstrap)){ nq_hist_bootstrap[i] <- sd(sample(nq$VegCover[nq$time_period=="Historical"], length(nq$VegCover[nq$time_period=="Contemporary"]), replace=FALSE)) } mean(nq_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data nq_VegCover <- length(nq_hist_bootstrap[nq_hist_bootstrap>=nq_contemp_VegCover])/10000 # Get vector of results for each variable NQ <- c(nq_Rainfall, nq_Elevation, nq_FireFreq, nq_MaxTemp, nq_MinTemp, nq_TRI, nq_TWI, nq_VegCover) ################### ### Fawn antechinuss ## Rainfall ante_bel <- df[ which(df$species=="Fawn antechinus"), ] ante_bel_contemp_Rainfall <- sd(ante_bel$Rainfall[ante_bel$time_period=="Contemporary"]) # Get bootstraps of historical data ante_bel_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(ante_bel_hist_bootstrap)){ ante_bel_hist_bootstrap[i] <- sd(sample(ante_bel$Rainfall[ante_bel$time_period=="Historical"], length(ante_bel$Rainfall[ante_bel$time_period=="Contemporary"]), replace=FALSE)) } mean(ante_bel_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data ante_bel_Rainfall <- length(ante_bel_hist_bootstrap[ante_bel_hist_bootstrap>=ante_bel_contemp_Rainfall])/10000 ## Elevation ante_bel <- df[ which(df$species=="Fawn antechinus"), ] ante_bel_contemp_Elevation <- sd(ante_bel$Elevation[ante_bel$time_period=="Contemporary"]) # Get bootstraps of historical data ante_bel_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(ante_bel_hist_bootstrap)){ ante_bel_hist_bootstrap[i] <- sd(sample(ante_bel$Elevation[ante_bel$time_period=="Historical"], length(ante_bel$Elevation[ante_bel$time_period=="Contemporary"]), replace=FALSE)) } mean(ante_bel_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data ante_bel_Elevation <- length(ante_bel_hist_bootstrap[ante_bel_hist_bootstrap>=ante_bel_contemp_Elevation])/10000 ## FireFreq ante_bel <- df[ which(df$species=="Fawn antechinus"), ] ante_bel_contemp_FireFreq <- sd(ante_bel$FireFreq[ante_bel$time_period=="Contemporary"]) # Get bootstraps of historical data ante_bel_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(ante_bel_hist_bootstrap)){ ante_bel_hist_bootstrap[i] <- sd(sample(ante_bel$FireFreq[ante_bel$time_period=="Historical"], length(ante_bel$FireFreq[ante_bel$time_period=="Contemporary"]), replace=FALSE)) } mean(ante_bel_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data ante_bel_FireFreq <- length(ante_bel_hist_bootstrap[ante_bel_hist_bootstrap>=ante_bel_contemp_FireFreq])/10000 ## FireFreq ante_bel <- df[ which(df$species=="Fawn antechinus"), ] ante_bel_contemp_FireFreq <- sd(ante_bel$FireFreq[ante_bel$time_period=="Contemporary"]) # Get bootstraps of historical data ante_bel_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(ante_bel_hist_bootstrap)){ ante_bel_hist_bootstrap[i] <- sd(sample(ante_bel$FireFreq[ante_bel$time_period=="Historical"], length(ante_bel$FireFreq[ante_bel$time_period=="Contemporary"]), replace=FALSE)) } mean(ante_bel_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data ante_bel_FireFreq <- length(ante_bel_hist_bootstrap[ante_bel_hist_bootstrap>=ante_bel_contemp_FireFreq])/10000 ## MaxTemp ante_bel <- df[ which(df$species=="Fawn antechinus"), ] ante_bel_contemp_MaxTemp <- sd(ante_bel$MaxTemp[ante_bel$time_period=="Contemporary"]) # Get bootstraps of historical data ante_bel_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(ante_bel_hist_bootstrap)){ ante_bel_hist_bootstrap[i] <- sd(sample(ante_bel$MaxTemp[ante_bel$time_period=="Historical"], length(ante_bel$MaxTemp[ante_bel$time_period=="Contemporary"]), replace=FALSE)) } mean(ante_bel_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data ante_bel_MaxTemp <- length(ante_bel_hist_bootstrap[ante_bel_hist_bootstrap>=ante_bel_contemp_MaxTemp])/10000 ## MinTemp ante_bel <- df[ which(df$species=="Fawn antechinus"), ] ante_bel_contemp_MinTemp <- sd(ante_bel$MinTemp[ante_bel$time_period=="Contemporary"]) # Get bootstraps of historical data ante_bel_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(ante_bel_hist_bootstrap)){ ante_bel_hist_bootstrap[i] <- sd(sample(ante_bel$MinTemp[ante_bel$time_period=="Historical"], length(ante_bel$MinTemp[ante_bel$time_period=="Contemporary"]), replace=FALSE)) } mean(ante_bel_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data ante_bel_MinTemp <- length(ante_bel_hist_bootstrap[ante_bel_hist_bootstrap>=ante_bel_contemp_MinTemp])/10000 ## TRI ante_bel <- df[ which(df$species=="Fawn antechinus"), ] ante_bel_contemp_TRI <- sd(ante_bel$TRI[ante_bel$time_period=="Contemporary"]) # Get bootstraps of historical data ante_bel_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(ante_bel_hist_bootstrap)){ ante_bel_hist_bootstrap[i] <- sd(sample(ante_bel$TRI[ante_bel$time_period=="Historical"], length(ante_bel$TRI[ante_bel$time_period=="Contemporary"]), replace=FALSE)) } mean(ante_bel_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data ante_bel_TRI <- length(ante_bel_hist_bootstrap[ante_bel_hist_bootstrap>=ante_bel_contemp_TRI])/10000 ## TWI ante_bel <- df[ which(df$species=="Fawn antechinus"), ] ante_bel_contemp_TWI <- sd(ante_bel$TWI[ante_bel$time_period=="Contemporary"]) # Get bootstraps of historical data ante_bel_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(ante_bel_hist_bootstrap)){ ante_bel_hist_bootstrap[i] <- sd(sample(ante_bel$TWI[ante_bel$time_period=="Historical"], length(ante_bel$TWI[ante_bel$time_period=="Contemporary"]), replace=FALSE)) } mean(ante_bel_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data ante_bel_TWI <- length(ante_bel_hist_bootstrap[ante_bel_hist_bootstrap>=ante_bel_contemp_TWI])/10000 ## VegCover ante_bel <- df[ which(df$species=="Fawn antechinus"), ] ante_bel_contemp_VegCover <- sd(ante_bel$VegCover[ante_bel$time_period=="Contemporary"]) # Get bootstraps of historical data ante_bel_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(ante_bel_hist_bootstrap)){ ante_bel_hist_bootstrap[i] <- sd(sample(ante_bel$VegCover[ante_bel$time_period=="Historical"], length(ante_bel$VegCover[ante_bel$time_period=="Contemporary"]), replace=FALSE)) } mean(ante_bel_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data ante_bel_VegCover <- length(ante_bel_hist_bootstrap[ante_bel_hist_bootstrap>=ante_bel_contemp_VegCover])/10000 # Get vector of results for each variable ante_bel <- c(ante_bel_Rainfall, ante_bel_Elevation, ante_bel_FireFreq, ante_bel_MaxTemp, ante_bel_MinTemp, ante_bel_TRI, ante_bel_TWI, ante_bel_VegCover) ################### ### Brush-tailed rabbit-rats ## Rainfall con_pen <- df[ which(df$species=="Brush-tailed rabbit-rat"), ] con_pen_contemp_Rainfall <- sd(con_pen$Rainfall[con_pen$time_period=="Contemporary"]) # Get bootstraps of historical data con_pen_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(con_pen_hist_bootstrap)){ con_pen_hist_bootstrap[i] <- sd(sample(con_pen$Rainfall[con_pen$time_period=="Historical"], length(con_pen$Rainfall[con_pen$time_period=="Contemporary"]), replace=FALSE)) } mean(con_pen_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data con_pen_Rainfall <- length(con_pen_hist_bootstrap[con_pen_hist_bootstrap>=con_pen_contemp_Rainfall])/10000 ## Elevation con_pen <- df[ which(df$species=="Brush-tailed rabbit-rat"), ] con_pen_contemp_Elevation <- sd(con_pen$Elevation[con_pen$time_period=="Contemporary"]) # Get bootstraps of historical data con_pen_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(con_pen_hist_bootstrap)){ con_pen_hist_bootstrap[i] <- sd(sample(con_pen$Elevation[con_pen$time_period=="Historical"], length(con_pen$Elevation[con_pen$time_period=="Contemporary"]), replace=FALSE)) } mean(con_pen_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data con_pen_Elevation <- length(con_pen_hist_bootstrap[con_pen_hist_bootstrap>=con_pen_contemp_Elevation])/10000 ## FireFreq con_pen <- df[ which(df$species=="Brush-tailed rabbit-rat"), ] con_pen_contemp_FireFreq <- sd(con_pen$FireFreq[con_pen$time_period=="Contemporary"]) # Get bootstraps of historical data con_pen_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(con_pen_hist_bootstrap)){ con_pen_hist_bootstrap[i] <- sd(sample(con_pen$FireFreq[con_pen$time_period=="Historical"], length(con_pen$FireFreq[con_pen$time_period=="Contemporary"]), replace=FALSE)) } mean(con_pen_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data con_pen_FireFreq <- length(con_pen_hist_bootstrap[con_pen_hist_bootstrap>=con_pen_contemp_FireFreq])/10000 ## FireFreq con_pen <- df[ which(df$species=="Brush-tailed rabbit-rat"), ] con_pen_contemp_FireFreq <- sd(con_pen$FireFreq[con_pen$time_period=="Contemporary"]) # Get bootstraps of historical data con_pen_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(con_pen_hist_bootstrap)){ con_pen_hist_bootstrap[i] <- sd(sample(con_pen$FireFreq[con_pen$time_period=="Historical"], length(con_pen$FireFreq[con_pen$time_period=="Contemporary"]), replace=FALSE)) } mean(con_pen_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data con_pen_FireFreq <- length(con_pen_hist_bootstrap[con_pen_hist_bootstrap>=con_pen_contemp_FireFreq])/10000 ## MaxTemp con_pen <- df[ which(df$species=="Brush-tailed rabbit-rat"), ] con_pen_contemp_MaxTemp <- sd(con_pen$MaxTemp[con_pen$time_period=="Contemporary"]) # Get bootstraps of historical data con_pen_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(con_pen_hist_bootstrap)){ con_pen_hist_bootstrap[i] <- sd(sample(con_pen$MaxTemp[con_pen$time_period=="Historical"], length(con_pen$MaxTemp[con_pen$time_period=="Contemporary"]), replace=FALSE)) } mean(con_pen_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data con_pen_MaxTemp <- length(con_pen_hist_bootstrap[con_pen_hist_bootstrap>=con_pen_contemp_MaxTemp])/10000 ## MinTemp con_pen <- df[ which(df$species=="Brush-tailed rabbit-rat"), ] con_pen_contemp_MinTemp <- sd(con_pen$MinTemp[con_pen$time_period=="Contemporary"]) # Get bootstraps of historical data con_pen_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(con_pen_hist_bootstrap)){ con_pen_hist_bootstrap[i] <- sd(sample(con_pen$MinTemp[con_pen$time_period=="Historical"], length(con_pen$MinTemp[con_pen$time_period=="Contemporary"]), replace=FALSE)) } mean(con_pen_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data con_pen_MinTemp <- length(con_pen_hist_bootstrap[con_pen_hist_bootstrap>=con_pen_contemp_MinTemp])/10000 ## TRI con_pen <- df[ which(df$species=="Brush-tailed rabbit-rat"), ] con_pen_contemp_TRI <- sd(con_pen$TRI[con_pen$time_period=="Contemporary"]) # Get bootstraps of historical data con_pen_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(con_pen_hist_bootstrap)){ con_pen_hist_bootstrap[i] <- sd(sample(con_pen$TRI[con_pen$time_period=="Historical"], length(con_pen$TRI[con_pen$time_period=="Contemporary"]), replace=FALSE)) } mean(con_pen_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data con_pen_TRI <- length(con_pen_hist_bootstrap[con_pen_hist_bootstrap>=con_pen_contemp_TRI])/10000 ## TWI con_pen <- df[ which(df$species=="Brush-tailed rabbit-rat"), ] con_pen_contemp_TWI <- sd(con_pen$TWI[con_pen$time_period=="Contemporary"]) # Get bootstraps of historical data con_pen_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(con_pen_hist_bootstrap)){ con_pen_hist_bootstrap[i] <- sd(sample(con_pen$TWI[con_pen$time_period=="Historical"], length(con_pen$TWI[con_pen$time_period=="Contemporary"]), replace=FALSE)) } mean(con_pen_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data con_pen_TWI <- length(con_pen_hist_bootstrap[con_pen_hist_bootstrap>=con_pen_contemp_TWI])/10000 ## VegCover con_pen <- df[ which(df$species=="Brush-tailed rabbit-rat"), ] con_pen_contemp_VegCover <- sd(con_pen$VegCover[con_pen$time_period=="Contemporary"]) # Get bootstraps of historical data con_pen_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(con_pen_hist_bootstrap)){ con_pen_hist_bootstrap[i] <- sd(sample(con_pen$VegCover[con_pen$time_period=="Historical"], length(con_pen$VegCover[con_pen$time_period=="Contemporary"]), replace=FALSE)) } mean(con_pen_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data con_pen_VegCover <- length(con_pen_hist_bootstrap[con_pen_hist_bootstrap>=con_pen_contemp_VegCover])/10000 # Get vector of results for each variable con_pen <- c(con_pen_Rainfall, con_pen_Elevation, con_pen_FireFreq, con_pen_MaxTemp, con_pen_MinTemp, con_pen_TRI, con_pen_TWI, con_pen_VegCover) ################### ### Northern brown bandicoots ## Rainfall nor_brown <- df[ which(df$species=="Northern brown bandicoot"), ] nor_brown_contemp_Rainfall <- sd(nor_brown$Rainfall[nor_brown$time_period=="Contemporary"]) # Get bootstraps of historical data nor_brown_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(nor_brown_hist_bootstrap)){ nor_brown_hist_bootstrap[i] <- sd(sample(nor_brown$Rainfall[nor_brown$time_period=="Historical"], length(nor_brown$Rainfall[nor_brown$time_period=="Contemporary"]), replace=FALSE)) } mean(nor_brown_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data nor_brown_Rainfall <- length(nor_brown_hist_bootstrap[nor_brown_hist_bootstrap>=nor_brown_contemp_Rainfall])/10000 ## Elevation nor_brown <- df[ which(df$species=="Northern brown bandicoot"), ] nor_brown_contemp_Elevation <- sd(nor_brown$Elevation[nor_brown$time_period=="Contemporary"]) # Get bootstraps of historical data nor_brown_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(nor_brown_hist_bootstrap)){ nor_brown_hist_bootstrap[i] <- sd(sample(nor_brown$Elevation[nor_brown$time_period=="Historical"], length(nor_brown$Elevation[nor_brown$time_period=="Contemporary"]), replace=FALSE)) } mean(nor_brown_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data nor_brown_Elevation <- length(nor_brown_hist_bootstrap[nor_brown_hist_bootstrap>=nor_brown_contemp_Elevation])/10000 ## FireFreq nor_brown <- df[ which(df$species=="Northern brown bandicoot"), ] nor_brown_contemp_FireFreq <- sd(nor_brown$FireFreq[nor_brown$time_period=="Contemporary"]) # Get bootstraps of historical data nor_brown_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(nor_brown_hist_bootstrap)){ nor_brown_hist_bootstrap[i] <- sd(sample(nor_brown$FireFreq[nor_brown$time_period=="Historical"], length(nor_brown$FireFreq[nor_brown$time_period=="Contemporary"]), replace=FALSE)) } mean(nor_brown_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data nor_brown_FireFreq <- length(nor_brown_hist_bootstrap[nor_brown_hist_bootstrap>=nor_brown_contemp_FireFreq])/10000 ## FireFreq nor_brown <- df[ which(df$species=="Northern brown bandicoot"), ] nor_brown_contemp_FireFreq <- sd(nor_brown$FireFreq[nor_brown$time_period=="Contemporary"]) # Get bootstraps of historical data nor_brown_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(nor_brown_hist_bootstrap)){ nor_brown_hist_bootstrap[i] <- sd(sample(nor_brown$FireFreq[nor_brown$time_period=="Historical"], length(nor_brown$FireFreq[nor_brown$time_period=="Contemporary"]), replace=FALSE)) } mean(nor_brown_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data nor_brown_FireFreq <- length(nor_brown_hist_bootstrap[nor_brown_hist_bootstrap>=nor_brown_contemp_FireFreq])/10000 ## MaxTemp nor_brown <- df[ which(df$species=="Northern brown bandicoot"), ] nor_brown_contemp_MaxTemp <- sd(nor_brown$MaxTemp[nor_brown$time_period=="Contemporary"]) # Get bootstraps of historical data nor_brown_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(nor_brown_hist_bootstrap)){ nor_brown_hist_bootstrap[i] <- sd(sample(nor_brown$MaxTemp[nor_brown$time_period=="Historical"], length(nor_brown$MaxTemp[nor_brown$time_period=="Contemporary"]), replace=FALSE)) } mean(nor_brown_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data nor_brown_MaxTemp <- length(nor_brown_hist_bootstrap[nor_brown_hist_bootstrap>=nor_brown_contemp_MaxTemp])/10000 ## MinTemp nor_brown <- df[ which(df$species=="Northern brown bandicoot"), ] nor_brown_contemp_MinTemp <- sd(nor_brown$MinTemp[nor_brown$time_period=="Contemporary"]) # Get bootstraps of historical data nor_brown_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(nor_brown_hist_bootstrap)){ nor_brown_hist_bootstrap[i] <- sd(sample(nor_brown$MinTemp[nor_brown$time_period=="Historical"], length(nor_brown$MinTemp[nor_brown$time_period=="Contemporary"]), replace=FALSE)) } mean(nor_brown_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data nor_brown_MinTemp <- length(nor_brown_hist_bootstrap[nor_brown_hist_bootstrap>=nor_brown_contemp_MinTemp])/10000 ## TRI nor_brown <- df[ which(df$species=="Northern brown bandicoot"), ] nor_brown_contemp_TRI <- sd(nor_brown$TRI[nor_brown$time_period=="Contemporary"]) # Get bootstraps of historical data nor_brown_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(nor_brown_hist_bootstrap)){ nor_brown_hist_bootstrap[i] <- sd(sample(nor_brown$TRI[nor_brown$time_period=="Historical"], length(nor_brown$TRI[nor_brown$time_period=="Contemporary"]), replace=FALSE)) } mean(nor_brown_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data nor_brown_TRI <- length(nor_brown_hist_bootstrap[nor_brown_hist_bootstrap>=nor_brown_contemp_TRI])/10000 ## TWI nor_brown <- df[ which(df$species=="Northern brown bandicoot"), ] nor_brown_contemp_TWI <- sd(nor_brown$TWI[nor_brown$time_period=="Contemporary"]) # Get bootstraps of historical data nor_brown_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(nor_brown_hist_bootstrap)){ nor_brown_hist_bootstrap[i] <- sd(sample(nor_brown$TWI[nor_brown$time_period=="Historical"], length(nor_brown$TWI[nor_brown$time_period=="Contemporary"]), replace=FALSE)) } mean(nor_brown_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data nor_brown_TWI <- length(nor_brown_hist_bootstrap[nor_brown_hist_bootstrap>=nor_brown_contemp_TWI])/10000 ## VegCover nor_brown <- df[ which(df$species=="Northern brown bandicoot"), ] nor_brown_contemp_VegCover <- sd(nor_brown$VegCover[nor_brown$time_period=="Contemporary"]) # Get bootstraps of historical data nor_brown_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(nor_brown_hist_bootstrap)){ nor_brown_hist_bootstrap[i] <- sd(sample(nor_brown$VegCover[nor_brown$time_period=="Historical"], length(nor_brown$VegCover[nor_brown$time_period=="Contemporary"]), replace=FALSE)) } mean(nor_brown_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data nor_brown_VegCover <- length(nor_brown_hist_bootstrap[nor_brown_hist_bootstrap>=nor_brown_contemp_VegCover])/10000 # Get vector of results for each variable nor_brown <- c(nor_brown_Rainfall, nor_brown_Elevation, nor_brown_FireFreq, nor_brown_MaxTemp, nor_brown_MinTemp, nor_brown_TRI, nor_brown_TWI, nor_brown_VegCover) ################### ### Black-footed tree-rats ## Rainfall mes_gould <- df[ which(df$species=="Black-footed tree-rat"), ] mes_gould_contemp_Rainfall <- sd(mes_gould$Rainfall[mes_gould$time_period=="Contemporary"]) # Get bootstraps of historical data mes_gould_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(mes_gould_hist_bootstrap)){ mes_gould_hist_bootstrap[i] <- sd(sample(mes_gould$Rainfall[mes_gould$time_period=="Historical"], length(mes_gould$Rainfall[mes_gould$time_period=="Contemporary"]), replace=FALSE)) } mean(mes_gould_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data mes_gould_Rainfall <- length(mes_gould_hist_bootstrap[mes_gould_hist_bootstrap>=mes_gould_contemp_Rainfall])/10000 ## Elevation mes_gould <- df[ which(df$species=="Black-footed tree-rat"), ] mes_gould_contemp_Elevation <- sd(mes_gould$Elevation[mes_gould$time_period=="Contemporary"]) # Get bootstraps of historical data mes_gould_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(mes_gould_hist_bootstrap)){ mes_gould_hist_bootstrap[i] <- sd(sample(mes_gould$Elevation[mes_gould$time_period=="Historical"], length(mes_gould$Elevation[mes_gould$time_period=="Contemporary"]), replace=FALSE)) } mean(mes_gould_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data mes_gould_Elevation <- length(mes_gould_hist_bootstrap[mes_gould_hist_bootstrap>=mes_gould_contemp_Elevation])/10000 ## FireFreq mes_gould <- df[ which(df$species=="Black-footed tree-rat"), ] mes_gould_contemp_FireFreq <- sd(mes_gould$FireFreq[mes_gould$time_period=="Contemporary"]) # Get bootstraps of historical data mes_gould_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(mes_gould_hist_bootstrap)){ mes_gould_hist_bootstrap[i] <- sd(sample(mes_gould$FireFreq[mes_gould$time_period=="Historical"], length(mes_gould$FireFreq[mes_gould$time_period=="Contemporary"]), replace=FALSE)) } mean(mes_gould_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data mes_gould_FireFreq <- length(mes_gould_hist_bootstrap[mes_gould_hist_bootstrap>=mes_gould_contemp_FireFreq])/10000 ## FireFreq mes_gould <- df[ which(df$species=="Black-footed tree-rat"), ] mes_gould_contemp_FireFreq <- sd(mes_gould$FireFreq[mes_gould$time_period=="Contemporary"]) # Get bootstraps of historical data mes_gould_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(mes_gould_hist_bootstrap)){ mes_gould_hist_bootstrap[i] <- sd(sample(mes_gould$FireFreq[mes_gould$time_period=="Historical"], length(mes_gould$FireFreq[mes_gould$time_period=="Contemporary"]), replace=FALSE)) } mean(mes_gould_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data mes_gould_FireFreq <- length(mes_gould_hist_bootstrap[mes_gould_hist_bootstrap>=mes_gould_contemp_FireFreq])/10000 ## MaxTemp mes_gould <- df[ which(df$species=="Black-footed tree-rat"), ] mes_gould_contemp_MaxTemp <- sd(mes_gould$MaxTemp[mes_gould$time_period=="Contemporary"]) # Get bootstraps of historical data mes_gould_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(mes_gould_hist_bootstrap)){ mes_gould_hist_bootstrap[i] <- sd(sample(mes_gould$MaxTemp[mes_gould$time_period=="Historical"], length(mes_gould$MaxTemp[mes_gould$time_period=="Contemporary"]), replace=FALSE)) } mean(mes_gould_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data mes_gould_MaxTemp <- length(mes_gould_hist_bootstrap[mes_gould_hist_bootstrap>=mes_gould_contemp_MaxTemp])/10000 ## MinTemp mes_gould <- df[ which(df$species=="Black-footed tree-rat"), ] mes_gould_contemp_MinTemp <- sd(mes_gould$MinTemp[mes_gould$time_period=="Contemporary"]) # Get bootstraps of historical data mes_gould_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(mes_gould_hist_bootstrap)){ mes_gould_hist_bootstrap[i] <- sd(sample(mes_gould$MinTemp[mes_gould$time_period=="Historical"], length(mes_gould$MinTemp[mes_gould$time_period=="Contemporary"]), replace=FALSE)) } mean(mes_gould_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data mes_gould_MinTemp <- length(mes_gould_hist_bootstrap[mes_gould_hist_bootstrap>=mes_gould_contemp_MinTemp])/10000 ## TRI mes_gould <- df[ which(df$species=="Black-footed tree-rat"), ] mes_gould_contemp_TRI <- sd(mes_gould$TRI[mes_gould$time_period=="Contemporary"]) # Get bootstraps of historical data mes_gould_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(mes_gould_hist_bootstrap)){ mes_gould_hist_bootstrap[i] <- sd(sample(mes_gould$TRI[mes_gould$time_period=="Historical"], length(mes_gould$TRI[mes_gould$time_period=="Contemporary"]), replace=FALSE)) } mean(mes_gould_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data mes_gould_TRI <- length(mes_gould_hist_bootstrap[mes_gould_hist_bootstrap>=mes_gould_contemp_TRI])/10000 ## TWI mes_gould <- df[ which(df$species=="Black-footed tree-rat"), ] mes_gould_contemp_TWI <- sd(mes_gould$TWI[mes_gould$time_period=="Contemporary"]) # Get bootstraps of historical data mes_gould_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(mes_gould_hist_bootstrap)){ mes_gould_hist_bootstrap[i] <- sd(sample(mes_gould$TWI[mes_gould$time_period=="Historical"], length(mes_gould$TWI[mes_gould$time_period=="Contemporary"]), replace=FALSE)) } mean(mes_gould_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data mes_gould_TWI <- length(mes_gould_hist_bootstrap[mes_gould_hist_bootstrap>=mes_gould_contemp_TWI])/10000 ## VegCover mes_gould <- df[ which(df$species=="Black-footed tree-rat"), ] mes_gould_contemp_VegCover <- sd(mes_gould$VegCover[mes_gould$time_period=="Contemporary"]) # Get bootstraps of historical data mes_gould_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(mes_gould_hist_bootstrap)){ mes_gould_hist_bootstrap[i] <- sd(sample(mes_gould$VegCover[mes_gould$time_period=="Historical"], length(mes_gould$VegCover[mes_gould$time_period=="Contemporary"]), replace=FALSE)) } mean(mes_gould_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data mes_gould_VegCover <- length(mes_gould_hist_bootstrap[mes_gould_hist_bootstrap>=mes_gould_contemp_VegCover])/10000 # Get vector of results for each variable mes_gould <- c(mes_gould_Rainfall, mes_gould_Elevation, mes_gould_FireFreq, mes_gould_MaxTemp, mes_gould_MinTemp, mes_gould_TRI, mes_gould_TWI, mes_gould_VegCover) ################### ### Sugar gliders ## Rainfall pet_brev <- df[ which(df$species=="Sugar glider"), ] pet_brev_contemp_Rainfall <- sd(pet_brev$Rainfall[pet_brev$time_period=="Contemporary"]) # Get bootstraps of historical data pet_brev_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(pet_brev_hist_bootstrap)){ pet_brev_hist_bootstrap[i] <- sd(sample(pet_brev$Rainfall[pet_brev$time_period=="Historical"], length(pet_brev$Rainfall[pet_brev$time_period=="Contemporary"]), replace=FALSE)) } mean(pet_brev_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data pet_brev_Rainfall <- length(pet_brev_hist_bootstrap[pet_brev_hist_bootstrap>=pet_brev_contemp_Rainfall])/10000 ## Elevation pet_brev <- df[ which(df$species=="Sugar glider"), ] pet_brev_contemp_Elevation <- sd(pet_brev$Elevation[pet_brev$time_period=="Contemporary"]) # Get bootstraps of historical data pet_brev_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(pet_brev_hist_bootstrap)){ pet_brev_hist_bootstrap[i] <- sd(sample(pet_brev$Elevation[pet_brev$time_period=="Historical"], length(pet_brev$Elevation[pet_brev$time_period=="Contemporary"]), replace=FALSE)) } mean(pet_brev_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data pet_brev_Elevation <- length(pet_brev_hist_bootstrap[pet_brev_hist_bootstrap>=pet_brev_contemp_Elevation])/10000 ## FireFreq pet_brev <- df[ which(df$species=="Sugar glider"), ] pet_brev_contemp_FireFreq <- sd(pet_brev$FireFreq[pet_brev$time_period=="Contemporary"]) # Get bootstraps of historical data pet_brev_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(pet_brev_hist_bootstrap)){ pet_brev_hist_bootstrap[i] <- sd(sample(pet_brev$FireFreq[pet_brev$time_period=="Historical"], length(pet_brev$FireFreq[pet_brev$time_period=="Contemporary"]), replace=FALSE)) } mean(pet_brev_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data pet_brev_FireFreq <- length(pet_brev_hist_bootstrap[pet_brev_hist_bootstrap>=pet_brev_contemp_FireFreq])/10000 ## FireFreq pet_brev <- df[ which(df$species=="Sugar glider"), ] pet_brev_contemp_FireFreq <- sd(pet_brev$FireFreq[pet_brev$time_period=="Contemporary"]) # Get bootstraps of historical data pet_brev_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(pet_brev_hist_bootstrap)){ pet_brev_hist_bootstrap[i] <- sd(sample(pet_brev$FireFreq[pet_brev$time_period=="Historical"], length(pet_brev$FireFreq[pet_brev$time_period=="Contemporary"]), replace=FALSE)) } mean(pet_brev_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data pet_brev_FireFreq <- length(pet_brev_hist_bootstrap[pet_brev_hist_bootstrap>=pet_brev_contemp_FireFreq])/10000 ## MaxTemp pet_brev <- df[ which(df$species=="Sugar glider"), ] pet_brev_contemp_MaxTemp <- sd(pet_brev$MaxTemp[pet_brev$time_period=="Contemporary"]) # Get bootstraps of historical data pet_brev_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(pet_brev_hist_bootstrap)){ pet_brev_hist_bootstrap[i] <- sd(sample(pet_brev$MaxTemp[pet_brev$time_period=="Historical"], length(pet_brev$MaxTemp[pet_brev$time_period=="Contemporary"]), replace=FALSE)) } mean(pet_brev_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data pet_brev_MaxTemp <- length(pet_brev_hist_bootstrap[pet_brev_hist_bootstrap>=pet_brev_contemp_MaxTemp])/10000 ## MinTemp pet_brev <- df[ which(df$species=="Sugar glider"), ] pet_brev_contemp_MinTemp <- sd(pet_brev$MinTemp[pet_brev$time_period=="Contemporary"]) # Get bootstraps of historical data pet_brev_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(pet_brev_hist_bootstrap)){ pet_brev_hist_bootstrap[i] <- sd(sample(pet_brev$MinTemp[pet_brev$time_period=="Historical"], length(pet_brev$MinTemp[pet_brev$time_period=="Contemporary"]), replace=FALSE)) } mean(pet_brev_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data pet_brev_MinTemp <- length(pet_brev_hist_bootstrap[pet_brev_hist_bootstrap>=pet_brev_contemp_MinTemp])/10000 ## TRI pet_brev <- df[ which(df$species=="Sugar glider"), ] pet_brev_contemp_TRI <- sd(pet_brev$TRI[pet_brev$time_period=="Contemporary"]) # Get bootstraps of historical data pet_brev_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(pet_brev_hist_bootstrap)){ pet_brev_hist_bootstrap[i] <- sd(sample(pet_brev$TRI[pet_brev$time_period=="Historical"], length(pet_brev$TRI[pet_brev$time_period=="Contemporary"]), replace=FALSE)) } mean(pet_brev_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data pet_brev_TRI <- length(pet_brev_hist_bootstrap[pet_brev_hist_bootstrap>=pet_brev_contemp_TRI])/10000 ## TWI pet_brev <- df[ which(df$species=="Sugar glider"), ] pet_brev_contemp_TWI <- sd(pet_brev$TWI[pet_brev$time_period=="Contemporary"]) # Get bootstraps of historical data pet_brev_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(pet_brev_hist_bootstrap)){ pet_brev_hist_bootstrap[i] <- sd(sample(pet_brev$TWI[pet_brev$time_period=="Historical"], length(pet_brev$TWI[pet_brev$time_period=="Contemporary"]), replace=FALSE)) } mean(pet_brev_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data pet_brev_TWI <- length(pet_brev_hist_bootstrap[pet_brev_hist_bootstrap>=pet_brev_contemp_TWI])/10000 ## VegCover pet_brev <- df[ which(df$species=="Sugar glider"), ] pet_brev_contemp_VegCover <- sd(pet_brev$VegCover[pet_brev$time_period=="Contemporary"]) # Get bootstraps of historical data pet_brev_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(pet_brev_hist_bootstrap)){ pet_brev_hist_bootstrap[i] <- sd(sample(pet_brev$VegCover[pet_brev$time_period=="Historical"], length(pet_brev$VegCover[pet_brev$time_period=="Contemporary"]), replace=FALSE)) } mean(pet_brev_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data pet_brev_VegCover <- length(pet_brev_hist_bootstrap[pet_brev_hist_bootstrap>=pet_brev_contemp_VegCover])/10000 # Get vector of results for each variable pet_brev <- c(pet_brev_Rainfall, pet_brev_Elevation, pet_brev_FireFreq, pet_brev_MaxTemp, pet_brev_MinTemp, pet_brev_TRI, pet_brev_TWI, pet_brev_VegCover) ################### ### Western chestnut mouses ## Rainfall pseud_nan <- df[ which(df$species=="Western chestnut mouse"), ] pseud_nan_contemp_Rainfall <- sd(pseud_nan$Rainfall[pseud_nan$time_period=="Contemporary"]) # Get bootstraps of historical data pseud_nan_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(pseud_nan_hist_bootstrap)){ pseud_nan_hist_bootstrap[i] <- sd(sample(pseud_nan$Rainfall[pseud_nan$time_period=="Historical"], length(pseud_nan$Rainfall[pseud_nan$time_period=="Contemporary"]), replace=FALSE)) } mean(pseud_nan_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data pseud_nan_Rainfall <- length(pseud_nan_hist_bootstrap[pseud_nan_hist_bootstrap>=pseud_nan_contemp_Rainfall])/10000 ## Elevation pseud_nan <- df[ which(df$species=="Western chestnut mouse"), ] pseud_nan_contemp_Elevation <- sd(pseud_nan$Elevation[pseud_nan$time_period=="Contemporary"]) # Get bootstraps of historical data pseud_nan_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(pseud_nan_hist_bootstrap)){ pseud_nan_hist_bootstrap[i] <- sd(sample(pseud_nan$Elevation[pseud_nan$time_period=="Historical"], length(pseud_nan$Elevation[pseud_nan$time_period=="Contemporary"]), replace=FALSE)) } mean(pseud_nan_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data pseud_nan_Elevation <- length(pseud_nan_hist_bootstrap[pseud_nan_hist_bootstrap>=pseud_nan_contemp_Elevation])/10000 ## FireFreq pseud_nan <- df[ which(df$species=="Western chestnut mouse"), ] pseud_nan_contemp_FireFreq <- sd(pseud_nan$FireFreq[pseud_nan$time_period=="Contemporary"]) # Get bootstraps of historical data pseud_nan_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(pseud_nan_hist_bootstrap)){ pseud_nan_hist_bootstrap[i] <- sd(sample(pseud_nan$FireFreq[pseud_nan$time_period=="Historical"], length(pseud_nan$FireFreq[pseud_nan$time_period=="Contemporary"]), replace=FALSE)) } mean(pseud_nan_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data pseud_nan_FireFreq <- length(pseud_nan_hist_bootstrap[pseud_nan_hist_bootstrap>=pseud_nan_contemp_FireFreq])/10000 ## FireFreq pseud_nan <- df[ which(df$species=="Western chestnut mouse"), ] pseud_nan_contemp_FireFreq <- sd(pseud_nan$FireFreq[pseud_nan$time_period=="Contemporary"]) # Get bootstraps of historical data pseud_nan_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(pseud_nan_hist_bootstrap)){ pseud_nan_hist_bootstrap[i] <- sd(sample(pseud_nan$FireFreq[pseud_nan$time_period=="Historical"], length(pseud_nan$FireFreq[pseud_nan$time_period=="Contemporary"]), replace=FALSE)) } mean(pseud_nan_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data pseud_nan_FireFreq <- length(pseud_nan_hist_bootstrap[pseud_nan_hist_bootstrap>=pseud_nan_contemp_FireFreq])/10000 ## MaxTemp pseud_nan <- df[ which(df$species=="Western chestnut mouse"), ] pseud_nan_contemp_MaxTemp <- sd(pseud_nan$MaxTemp[pseud_nan$time_period=="Contemporary"]) # Get bootstraps of historical data pseud_nan_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(pseud_nan_hist_bootstrap)){ pseud_nan_hist_bootstrap[i] <- sd(sample(pseud_nan$MaxTemp[pseud_nan$time_period=="Historical"], length(pseud_nan$MaxTemp[pseud_nan$time_period=="Contemporary"]), replace=FALSE)) } mean(pseud_nan_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data pseud_nan_MaxTemp <- length(pseud_nan_hist_bootstrap[pseud_nan_hist_bootstrap>=pseud_nan_contemp_MaxTemp])/10000 ## MinTemp pseud_nan <- df[ which(df$species=="Western chestnut mouse"), ] pseud_nan_contemp_MinTemp <- sd(pseud_nan$MinTemp[pseud_nan$time_period=="Contemporary"]) # Get bootstraps of historical data pseud_nan_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(pseud_nan_hist_bootstrap)){ pseud_nan_hist_bootstrap[i] <- sd(sample(pseud_nan$MinTemp[pseud_nan$time_period=="Historical"], length(pseud_nan$MinTemp[pseud_nan$time_period=="Contemporary"]), replace=FALSE)) } mean(pseud_nan_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data pseud_nan_MinTemp <- length(pseud_nan_hist_bootstrap[pseud_nan_hist_bootstrap>=pseud_nan_contemp_MinTemp])/10000 ## TRI pseud_nan <- df[ which(df$species=="Western chestnut mouse"), ] pseud_nan_contemp_TRI <- sd(pseud_nan$TRI[pseud_nan$time_period=="Contemporary"]) # Get bootstraps of historical data pseud_nan_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(pseud_nan_hist_bootstrap)){ pseud_nan_hist_bootstrap[i] <- sd(sample(pseud_nan$TRI[pseud_nan$time_period=="Historical"], length(pseud_nan$TRI[pseud_nan$time_period=="Contemporary"]), replace=FALSE)) } mean(pseud_nan_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data pseud_nan_TRI <- length(pseud_nan_hist_bootstrap[pseud_nan_hist_bootstrap>=pseud_nan_contemp_TRI])/10000 ## TWI pseud_nan <- df[ which(df$species=="Western chestnut mouse"), ] pseud_nan_contemp_TWI <- sd(pseud_nan$TWI[pseud_nan$time_period=="Contemporary"]) # Get bootstraps of historical data pseud_nan_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(pseud_nan_hist_bootstrap)){ pseud_nan_hist_bootstrap[i] <- sd(sample(pseud_nan$TWI[pseud_nan$time_period=="Historical"], length(pseud_nan$TWI[pseud_nan$time_period=="Contemporary"]), replace=FALSE)) } mean(pseud_nan_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data pseud_nan_TWI <- length(pseud_nan_hist_bootstrap[pseud_nan_hist_bootstrap>=pseud_nan_contemp_TWI])/10000 ## VegCover pseud_nan <- df[ which(df$species=="Western chestnut mouse"), ] pseud_nan_contemp_VegCover <- sd(pseud_nan$VegCover[pseud_nan$time_period=="Contemporary"]) # Get bootstraps of historical data pseud_nan_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(pseud_nan_hist_bootstrap)){ pseud_nan_hist_bootstrap[i] <- sd(sample(pseud_nan$VegCover[pseud_nan$time_period=="Historical"], length(pseud_nan$VegCover[pseud_nan$time_period=="Contemporary"]), replace=FALSE)) } mean(pseud_nan_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data pseud_nan_VegCover <- length(pseud_nan_hist_bootstrap[pseud_nan_hist_bootstrap>=pseud_nan_contemp_VegCover])/10000 # Get vector of results for each variable pseud_nan <- c(pseud_nan_Rainfall, pseud_nan_Elevation, pseud_nan_FireFreq, pseud_nan_MaxTemp, pseud_nan_MinTemp, pseud_nan_TRI, pseud_nan_TWI, pseud_nan_VegCover) ################### ### Pale field rats ## Rainfall rat_tun <- df[ which(df$species=="Pale field rat"), ] rat_tun_contemp_Rainfall <- sd(rat_tun$Rainfall[rat_tun$time_period=="Contemporary"]) # Get bootstraps of historical data rat_tun_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(rat_tun_hist_bootstrap)){ rat_tun_hist_bootstrap[i] <- sd(sample(rat_tun$Rainfall[rat_tun$time_period=="Historical"], length(rat_tun$Rainfall[rat_tun$time_period=="Contemporary"]), replace=FALSE)) } mean(rat_tun_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data rat_tun_Rainfall <- length(rat_tun_hist_bootstrap[rat_tun_hist_bootstrap>=rat_tun_contemp_Rainfall])/10000 ## Elevation rat_tun <- df[ which(df$species=="Pale field rat"), ] rat_tun_contemp_Elevation <- sd(rat_tun$Elevation[rat_tun$time_period=="Contemporary"]) # Get bootstraps of historical data rat_tun_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(rat_tun_hist_bootstrap)){ rat_tun_hist_bootstrap[i] <- sd(sample(rat_tun$Elevation[rat_tun$time_period=="Historical"], length(rat_tun$Elevation[rat_tun$time_period=="Contemporary"]), replace=FALSE)) } mean(rat_tun_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data rat_tun_Elevation <- length(rat_tun_hist_bootstrap[rat_tun_hist_bootstrap>=rat_tun_contemp_Elevation])/10000 ## FireFreq rat_tun <- df[ which(df$species=="Pale field rat"), ] rat_tun_contemp_FireFreq <- sd(rat_tun$FireFreq[rat_tun$time_period=="Contemporary"]) # Get bootstraps of historical data rat_tun_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(rat_tun_hist_bootstrap)){ rat_tun_hist_bootstrap[i] <- sd(sample(rat_tun$FireFreq[rat_tun$time_period=="Historical"], length(rat_tun$FireFreq[rat_tun$time_period=="Contemporary"]), replace=FALSE)) } mean(rat_tun_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data rat_tun_FireFreq <- length(rat_tun_hist_bootstrap[rat_tun_hist_bootstrap>=rat_tun_contemp_FireFreq])/10000 ## FireFreq rat_tun <- df[ which(df$species=="Pale field rat"), ] rat_tun_contemp_FireFreq <- sd(rat_tun$FireFreq[rat_tun$time_period=="Contemporary"]) # Get bootstraps of historical data rat_tun_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(rat_tun_hist_bootstrap)){ rat_tun_hist_bootstrap[i] <- sd(sample(rat_tun$FireFreq[rat_tun$time_period=="Historical"], length(rat_tun$FireFreq[rat_tun$time_period=="Contemporary"]), replace=FALSE)) } mean(rat_tun_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data rat_tun_FireFreq <- length(rat_tun_hist_bootstrap[rat_tun_hist_bootstrap>=rat_tun_contemp_FireFreq])/10000 ## MaxTemp rat_tun <- df[ which(df$species=="Pale field rat"), ] rat_tun_contemp_MaxTemp <- sd(rat_tun$MaxTemp[rat_tun$time_period=="Contemporary"]) # Get bootstraps of historical data rat_tun_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(rat_tun_hist_bootstrap)){ rat_tun_hist_bootstrap[i] <- sd(sample(rat_tun$MaxTemp[rat_tun$time_period=="Historical"], length(rat_tun$MaxTemp[rat_tun$time_period=="Contemporary"]), replace=FALSE)) } mean(rat_tun_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data rat_tun_MaxTemp <- length(rat_tun_hist_bootstrap[rat_tun_hist_bootstrap>=rat_tun_contemp_MaxTemp])/10000 ## MinTemp rat_tun <- df[ which(df$species=="Pale field rat"), ] rat_tun_contemp_MinTemp <- sd(rat_tun$MinTemp[rat_tun$time_period=="Contemporary"]) # Get bootstraps of historical data rat_tun_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(rat_tun_hist_bootstrap)){ rat_tun_hist_bootstrap[i] <- sd(sample(rat_tun$MinTemp[rat_tun$time_period=="Historical"], length(rat_tun$MinTemp[rat_tun$time_period=="Contemporary"]), replace=FALSE)) } mean(rat_tun_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data rat_tun_MinTemp <- length(rat_tun_hist_bootstrap[rat_tun_hist_bootstrap>=rat_tun_contemp_MinTemp])/10000 ## TRI rat_tun <- df[ which(df$species=="Pale field rat"), ] rat_tun_contemp_TRI <- sd(rat_tun$TRI[rat_tun$time_period=="Contemporary"]) # Get bootstraps of historical data rat_tun_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(rat_tun_hist_bootstrap)){ rat_tun_hist_bootstrap[i] <- sd(sample(rat_tun$TRI[rat_tun$time_period=="Historical"], length(rat_tun$TRI[rat_tun$time_period=="Contemporary"]), replace=FALSE)) } mean(rat_tun_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data rat_tun_TRI <- length(rat_tun_hist_bootstrap[rat_tun_hist_bootstrap>=rat_tun_contemp_TRI])/10000 ## TWI rat_tun <- df[ which(df$species=="Pale field rat"), ] rat_tun_contemp_TWI <- sd(rat_tun$TWI[rat_tun$time_period=="Contemporary"]) # Get bootstraps of historical data rat_tun_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(rat_tun_hist_bootstrap)){ rat_tun_hist_bootstrap[i] <- sd(sample(rat_tun$TWI[rat_tun$time_period=="Historical"], length(rat_tun$TWI[rat_tun$time_period=="Contemporary"]), replace=FALSE)) } mean(rat_tun_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data rat_tun_TWI <- length(rat_tun_hist_bootstrap[rat_tun_hist_bootstrap>=rat_tun_contemp_TWI])/10000 ## VegCover rat_tun <- df[ which(df$species=="Pale field rat"), ] rat_tun_contemp_VegCover <- sd(rat_tun$VegCover[rat_tun$time_period=="Contemporary"]) # Get bootstraps of historical data rat_tun_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(rat_tun_hist_bootstrap)){ rat_tun_hist_bootstrap[i] <- sd(sample(rat_tun$VegCover[rat_tun$time_period=="Historical"], length(rat_tun$VegCover[rat_tun$time_period=="Contemporary"]), replace=FALSE)) } mean(rat_tun_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data rat_tun_VegCover <- length(rat_tun_hist_bootstrap[rat_tun_hist_bootstrap>=rat_tun_contemp_VegCover])/10000 # Get vector of results for each variable rat_tun <- c(rat_tun_Rainfall, rat_tun_Elevation, rat_tun_FireFreq, rat_tun_MaxTemp, rat_tun_MinTemp, rat_tun_TRI, rat_tun_TWI, rat_tun_VegCover) ################### ### Pale field rats ## Rainfall rat_tun <- df[ which(df$species=="Pale field rat"), ] rat_tun_contemp_Rainfall <- sd(rat_tun$Rainfall[rat_tun$time_period=="Contemporary"]) # Get bootstraps of historical data rat_tun_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(rat_tun_hist_bootstrap)){ rat_tun_hist_bootstrap[i] <- sd(sample(rat_tun$Rainfall[rat_tun$time_period=="Historical"], length(rat_tun$Rainfall[rat_tun$time_period=="Contemporary"]), replace=FALSE)) } mean(rat_tun_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data rat_tun_Rainfall <- length(rat_tun_hist_bootstrap[rat_tun_hist_bootstrap>=rat_tun_contemp_Rainfall])/10000 ## Elevation rat_tun <- df[ which(df$species=="Pale field rat"), ] rat_tun_contemp_Elevation <- sd(rat_tun$Elevation[rat_tun$time_period=="Contemporary"]) # Get bootstraps of historical data rat_tun_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(rat_tun_hist_bootstrap)){ rat_tun_hist_bootstrap[i] <- sd(sample(rat_tun$Elevation[rat_tun$time_period=="Historical"], length(rat_tun$Elevation[rat_tun$time_period=="Contemporary"]), replace=FALSE)) } mean(rat_tun_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data rat_tun_Elevation <- length(rat_tun_hist_bootstrap[rat_tun_hist_bootstrap>=rat_tun_contemp_Elevation])/10000 ## FireFreq rat_tun <- df[ which(df$species=="Pale field rat"), ] rat_tun_contemp_FireFreq <- sd(rat_tun$FireFreq[rat_tun$time_period=="Contemporary"]) # Get bootstraps of historical data rat_tun_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(rat_tun_hist_bootstrap)){ rat_tun_hist_bootstrap[i] <- sd(sample(rat_tun$FireFreq[rat_tun$time_period=="Historical"], length(rat_tun$FireFreq[rat_tun$time_period=="Contemporary"]), replace=FALSE)) } mean(rat_tun_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data rat_tun_FireFreq <- length(rat_tun_hist_bootstrap[rat_tun_hist_bootstrap>=rat_tun_contemp_FireFreq])/10000 ## FireFreq rat_tun <- df[ which(df$species=="Pale field rat"), ] rat_tun_contemp_FireFreq <- sd(rat_tun$FireFreq[rat_tun$time_period=="Contemporary"]) # Get bootstraps of historical data rat_tun_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(rat_tun_hist_bootstrap)){ rat_tun_hist_bootstrap[i] <- sd(sample(rat_tun$FireFreq[rat_tun$time_period=="Historical"], length(rat_tun$FireFreq[rat_tun$time_period=="Contemporary"]), replace=FALSE)) } mean(rat_tun_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data rat_tun_FireFreq <- length(rat_tun_hist_bootstrap[rat_tun_hist_bootstrap>=rat_tun_contemp_FireFreq])/10000 ## MaxTemp rat_tun <- df[ which(df$species=="Pale field rat"), ] rat_tun_contemp_MaxTemp <- sd(rat_tun$MaxTemp[rat_tun$time_period=="Contemporary"]) # Get bootstraps of historical data rat_tun_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(rat_tun_hist_bootstrap)){ rat_tun_hist_bootstrap[i] <- sd(sample(rat_tun$MaxTemp[rat_tun$time_period=="Historical"], length(rat_tun$MaxTemp[rat_tun$time_period=="Contemporary"]), replace=FALSE)) } mean(rat_tun_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data rat_tun_MaxTemp <- length(rat_tun_hist_bootstrap[rat_tun_hist_bootstrap>=rat_tun_contemp_MaxTemp])/10000 ## MinTemp rat_tun <- df[ which(df$species=="Pale field rat"), ] rat_tun_contemp_MinTemp <- sd(rat_tun$MinTemp[rat_tun$time_period=="Contemporary"]) # Get bootstraps of historical data rat_tun_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(rat_tun_hist_bootstrap)){ rat_tun_hist_bootstrap[i] <- sd(sample(rat_tun$MinTemp[rat_tun$time_period=="Historical"], length(rat_tun$MinTemp[rat_tun$time_period=="Contemporary"]), replace=FALSE)) } mean(rat_tun_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data rat_tun_MinTemp <- length(rat_tun_hist_bootstrap[rat_tun_hist_bootstrap>=rat_tun_contemp_MinTemp])/10000 ## TRI rat_tun <- df[ which(df$species=="Pale field rat"), ] rat_tun_contemp_TRI <- sd(rat_tun$TRI[rat_tun$time_period=="Contemporary"]) # Get bootstraps of historical data rat_tun_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(rat_tun_hist_bootstrap)){ rat_tun_hist_bootstrap[i] <- sd(sample(rat_tun$TRI[rat_tun$time_period=="Historical"], length(rat_tun$TRI[rat_tun$time_period=="Contemporary"]), replace=FALSE)) } mean(rat_tun_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data rat_tun_TRI <- length(rat_tun_hist_bootstrap[rat_tun_hist_bootstrap>=rat_tun_contemp_TRI])/10000 ## TWI rat_tun <- df[ which(df$species=="Pale field rat"), ] rat_tun_contemp_TWI <- sd(rat_tun$TWI[rat_tun$time_period=="Contemporary"]) # Get bootstraps of historical data rat_tun_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(rat_tun_hist_bootstrap)){ rat_tun_hist_bootstrap[i] <- sd(sample(rat_tun$TWI[rat_tun$time_period=="Historical"], length(rat_tun$TWI[rat_tun$time_period=="Contemporary"]), replace=FALSE)) } mean(rat_tun_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data rat_tun_TWI <- length(rat_tun_hist_bootstrap[rat_tun_hist_bootstrap>=rat_tun_contemp_TWI])/10000 ## VegCover rat_tun <- df[ which(df$species=="Pale field rat"), ] rat_tun_contemp_VegCover <- sd(rat_tun$VegCover[rat_tun$time_period=="Contemporary"]) # Get bootstraps of historical data rat_tun_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(rat_tun_hist_bootstrap)){ rat_tun_hist_bootstrap[i] <- sd(sample(rat_tun$VegCover[rat_tun$time_period=="Historical"], length(rat_tun$VegCover[rat_tun$time_period=="Contemporary"]), replace=FALSE)) } mean(rat_tun_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data rat_tun_VegCover <- length(rat_tun_hist_bootstrap[rat_tun_hist_bootstrap>=rat_tun_contemp_VegCover])/10000 # Get vector of results for each variable rat_tun <- c(rat_tun_Rainfall, rat_tun_Elevation, rat_tun_FireFreq, rat_tun_MaxTemp, rat_tun_MinTemp, rat_tun_TRI, rat_tun_TWI, rat_tun_VegCover) ################### ### Common brushtail possums ## Rainfall trich_vul <- df[ which(df$species=="Common brushtail possum"), ] trich_vul_contemp_Rainfall <- sd(trich_vul$Rainfall[trich_vul$time_period=="Contemporary"]) # Get bootstraps of historical data trich_vul_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(trich_vul_hist_bootstrap)){ trich_vul_hist_bootstrap[i] <- sd(sample(trich_vul$Rainfall[trich_vul$time_period=="Historical"], length(trich_vul$Rainfall[trich_vul$time_period=="Contemporary"]), replace=FALSE)) } mean(trich_vul_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data trich_vul_Rainfall <- length(trich_vul_hist_bootstrap[trich_vul_hist_bootstrap>=trich_vul_contemp_Rainfall])/10000 ## Elevation trich_vul <- df[ which(df$species=="Common brushtail possum"), ] trich_vul_contemp_Elevation <- sd(trich_vul$Elevation[trich_vul$time_period=="Contemporary"]) # Get bootstraps of historical data trich_vul_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(trich_vul_hist_bootstrap)){ trich_vul_hist_bootstrap[i] <- sd(sample(trich_vul$Elevation[trich_vul$time_period=="Historical"], length(trich_vul$Elevation[trich_vul$time_period=="Contemporary"]), replace=FALSE)) } mean(trich_vul_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data trich_vul_Elevation <- length(trich_vul_hist_bootstrap[trich_vul_hist_bootstrap>=trich_vul_contemp_Elevation])/10000 ## FireFreq trich_vul <- df[ which(df$species=="Common brushtail possum"), ] trich_vul_contemp_FireFreq <- sd(trich_vul$FireFreq[trich_vul$time_period=="Contemporary"]) # Get bootstraps of historical data trich_vul_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(trich_vul_hist_bootstrap)){ trich_vul_hist_bootstrap[i] <- sd(sample(trich_vul$FireFreq[trich_vul$time_period=="Historical"], length(trich_vul$FireFreq[trich_vul$time_period=="Contemporary"]), replace=FALSE)) } mean(trich_vul_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data trich_vul_FireFreq <- length(trich_vul_hist_bootstrap[trich_vul_hist_bootstrap>=trich_vul_contemp_FireFreq])/10000 ## FireFreq trich_vul <- df[ which(df$species=="Common brushtail possum"), ] trich_vul_contemp_FireFreq <- sd(trich_vul$FireFreq[trich_vul$time_period=="Contemporary"]) # Get bootstraps of historical data trich_vul_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(trich_vul_hist_bootstrap)){ trich_vul_hist_bootstrap[i] <- sd(sample(trich_vul$FireFreq[trich_vul$time_period=="Historical"], length(trich_vul$FireFreq[trich_vul$time_period=="Contemporary"]), replace=FALSE)) } mean(trich_vul_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data trich_vul_FireFreq <- length(trich_vul_hist_bootstrap[trich_vul_hist_bootstrap>=trich_vul_contemp_FireFreq])/10000 ## MaxTemp trich_vul <- df[ which(df$species=="Common brushtail possum"), ] trich_vul_contemp_MaxTemp <- sd(trich_vul$MaxTemp[trich_vul$time_period=="Contemporary"]) # Get bootstraps of historical data trich_vul_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(trich_vul_hist_bootstrap)){ trich_vul_hist_bootstrap[i] <- sd(sample(trich_vul$MaxTemp[trich_vul$time_period=="Historical"], length(trich_vul$MaxTemp[trich_vul$time_period=="Contemporary"]), replace=FALSE)) } mean(trich_vul_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data trich_vul_MaxTemp <- length(trich_vul_hist_bootstrap[trich_vul_hist_bootstrap>=trich_vul_contemp_MaxTemp])/10000 ## MinTemp trich_vul <- df[ which(df$species=="Common brushtail possum"), ] trich_vul_contemp_MinTemp <- sd(trich_vul$MinTemp[trich_vul$time_period=="Contemporary"]) # Get bootstraps of historical data trich_vul_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(trich_vul_hist_bootstrap)){ trich_vul_hist_bootstrap[i] <- sd(sample(trich_vul$MinTemp[trich_vul$time_period=="Historical"], length(trich_vul$MinTemp[trich_vul$time_period=="Contemporary"]), replace=FALSE)) } mean(trich_vul_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data trich_vul_MinTemp <- length(trich_vul_hist_bootstrap[trich_vul_hist_bootstrap>=trich_vul_contemp_MinTemp])/10000 ## TRI trich_vul <- df[ which(df$species=="Common brushtail possum"), ] trich_vul_contemp_TRI <- sd(trich_vul$TRI[trich_vul$time_period=="Contemporary"]) # Get bootstraps of historical data trich_vul_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(trich_vul_hist_bootstrap)){ trich_vul_hist_bootstrap[i] <- sd(sample(trich_vul$TRI[trich_vul$time_period=="Historical"], length(trich_vul$TRI[trich_vul$time_period=="Contemporary"]), replace=FALSE)) } mean(trich_vul_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data trich_vul_TRI <- length(trich_vul_hist_bootstrap[trich_vul_hist_bootstrap>=trich_vul_contemp_TRI])/10000 ## TWI trich_vul <- df[ which(df$species=="Common brushtail possum"), ] trich_vul_contemp_TWI <- sd(trich_vul$TWI[trich_vul$time_period=="Contemporary"]) # Get bootstraps of historical data trich_vul_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(trich_vul_hist_bootstrap)){ trich_vul_hist_bootstrap[i] <- sd(sample(trich_vul$TWI[trich_vul$time_period=="Historical"], length(trich_vul$TWI[trich_vul$time_period=="Contemporary"]), replace=FALSE)) } mean(trich_vul_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data trich_vul_TWI <- length(trich_vul_hist_bootstrap[trich_vul_hist_bootstrap>=trich_vul_contemp_TWI])/10000 ## VegCover trich_vul <- df[ which(df$species=="Common brushtail possum"), ] trich_vul_contemp_VegCover <- sd(trich_vul$VegCover[trich_vul$time_period=="Contemporary"]) # Get bootstraps of historical data trich_vul_hist_bootstrap <- as.numeric(rep(NA,10000)) for(i in 1:length(trich_vul_hist_bootstrap)){ trich_vul_hist_bootstrap[i] <- sd(sample(trich_vul$VegCover[trich_vul$time_period=="Historical"], length(trich_vul$VegCover[trich_vul$time_period=="Contemporary"]), replace=FALSE)) } mean(trich_vul_hist_bootstrap) # Find proportion of historical bootstraps that are greater than or equal to the mean of contemporary data trich_vul_VegCover <- length(trich_vul_hist_bootstrap[trich_vul_hist_bootstrap>=trich_vul_contemp_VegCover])/10000 # Get vector of results for each variable trich_vul <- c(trich_vul_Rainfall, trich_vul_Elevation, trich_vul_FireFreq, trich_vul_MaxTemp, trich_vul_MinTemp, trich_vul_TRI, trich_vul_TWI, trich_vul_VegCover) # Put all into dataframe spp_comp <- as.data.frame(rbind(ante_bel,con_pen,NQ,nor_brown,mes_gould,pet_brev,pseud_nan,rat_tun,trich_vul)) rownames(spp_comp) <- c("Fawn antechinus","Brush-tailed rabbit-rat","Northern quoll","Northern brown bandicoot", "Black-footed tree-rat","Sugar glider","Western chestnut mouse","Pale field rat","Common brushtail possum") colnames(spp_comp) <- c("Rainfall", "Elevation", "FireFreq", "MaxTemp", "MinTemp", "TRI", "TWI", "VegCover") # Output to csv file write.csv(spp_comp,paste("sdms/output/pvals_STDEV_hist_contemp_presences_",currentDate,".csv",sep=""),row.names=TRUE)