1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 Appendix: Details concerning simulations including annotated R code. Summary: Simulations are all based on a simple process model in which colonization is solely dependent on the number of occupied cells it touches (including diagonal neighbors) and extinction depends only on habitat quality. In all instances, the landscape wraps in all directions. In other words, a pixel in the first column includes pixels in the last columns as its neighbors and vice-versa. We conducted 100 simulations across four landscapes under four scenarios: 1) high colonization (0.8 probability of colonization if all neighbors are occupied and decreasing by 0.1 for each unoccupied neighbor) at equilibrium, 2) low colonization (0.4 probability of colonization if all neighbors are occupied) at equilibrium, 3) high colonization at disequilibrium, and 4) low colonization at disequilibrium. In all cases, extinction was 0.1 in low quality habitat and 0.8 in high quality. We also choose one set of simulations and plotted occupancy as a function of the number of good neighbors (landscape covariate) or occupied patches (autologistic) for figure 4 Annotated R code: #Simulations to create figure 3 # define update function which updates occupancies one time step based on input occupancy, p, # as well as extinction rate, E, and colonization rate, G, when all neighbors are occupied. Note that there # are no edges in these simulations…patches on one side are neighbors to patches on the opposite side. update<-function(p,E,G){ d<-dim(p)[1] neigh<-p[c(2:d,1),]+p[c(d,1:(d-1)),]+ p[,c(2:d,1)]+p[,c(d,1:(d-1))]+ p[c(2:d,1),c(2:d,1)]+ p[c(d,1:(d-1)),c(d,1:(d-1))]+ p[c(d,1:(d-1)),c(2:d,1)]+ p[c(2:d,1),c(d,1:(d-1))] out<-matrix(rbinom((d*d),1,p*(1-E)+(1-p)*(G*neigh/8)),nrow=d,ncol=d) return(out)} #define loop function which steps forward a number of time steps, Nloop, based on initial occupancy, # init.psi, and extinction, e, and colonization, g, as in update function. loop<-function(Nloop,init.psi,e,g=0.6){ occ<-init.psi for (j in 1:Nloop){occ<-update(occ,E=e,G=g)} return(occ)} #set random number seed set.seed(1) #create arrays to save simulated equilibrium occupancies and associated habitat quality for equilibrium # (eq) and disequilibrium (diseq) simulations. First dimension is based on the number of patches in each # simulations, second is based on the number of simulations, third dimension is based on the four # different landscapes, and in the case of simsave arrays fourth dimension is for low and high # colonization rates. 1 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 simsave.eq<-array(NA,dim=c(1600,100,4,2)) hqsave<-array(NA,dim=c(1600,100,4)) simsave.diseq<-array(NA,dim=c(1600,100,4,2)) #Simulate! See annotations within loop. for (k in 1:100){ ## First Landscape - 20% Random- Equilibrium simulations # create matrix, hq, with worse, 0, and better, 1, habitat hq<-matrix(sample(c(rep(0,1280),rep(1,320)),1600,replace=FALSE),nrow=40,ncol=40) #convert hq to extinction rate eps<-.8-.7*hq #guess at equilibrium rate assuming colonization of 50% of maximum eqO<-.2/(.2+eps) #simulate initial occupancy IO<-matrix(rbinom(1600,1,eqO),nrow=40,ncol=40) #simulate 100 time steps to reach dynamic equilibrium (more than enough) temp<-loop(100,IO,eps,.4) #save simulations and habitat info simsave.eq[,k,1,1]<-as.vector(temp) hqsave [,k,1]<-as.vector(hq) #repeat with higher colonization rate and save eqO<-.4/(.4+eps) IO<-matrix(rbinom(1600,1,eqO),nrow=40,ncol=40) temp<-loop(100,IO,eps,.8) simsave.eq[,k,1,2]<-as.vector(temp) ## First Landscape - 20% Random- Disequilibrium simulations (only difference is 12 time steps # instead of 100 and initiall occupancy is chosen randomly to cover 2.5% of patches) IO<-matrix(sample(c(rep(0,1560),rep(1,40)),1600,replace=FALSE),nrow=40,ncol=40) temp<-loop(12,IO,eps,.4) simsave.diseq[,k,1,1]<-as.vector(temp) temp<-loop(12,IO,eps,.8) simsave.diseq[,k,1,2]<-as.vector(temp) ## Second Landscape - 50% Random- Equilibrium simulations hq<-matrix(sample(c(rep(0,800),rep(1,800)),1600,replace=FALSE),nrow=40,ncol=40) eps<-.8-.7*hq eqO<-.2/(.2+eps) IO<-matrix(rbinom(1600,1,eqO),nrow=40,ncol=40) temp<-loop(100,IO,eps,.4) simsave.eq[,k,2,1]<-as.vector(temp) hqsave [,k,2]<-as.vector(hq) 2 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 eqO<-.4/(.4+eps) IO<-matrix(rbinom(1600,1,eqO),nrow=40,ncol=40) temp<-loop(100,IO,eps,.8) simsave.eq[,k,2,2]<-as.vector(temp) ## Second Landscape - 50% Random- Disequilibrium simulations IO<-matrix(sample(c(rep(0,1560),rep(1,40)),1600,replace=FALSE),nrow=40,ncol=40) temp<-loop(12,IO,eps,.4) simsave.diseq[,k,2,1]<-as.vector(temp) temp<-loop(12,IO,eps,.8) simsave.diseq[,k,2,2]<-as.vector(temp) ## Third Landscape - 80% Random- Equilibrium simulations hq<-matrix(sample(c(rep(0,320),rep(1,1280)),1600,replace=FALSE),nrow=40,ncol=40) eps<-.8-.7*hq eqO<-.2/(.2+eps) IO<-matrix(rbinom(1600,1,eqO),nrow=40,ncol=40) temp<-loop(100,IO,eps,.4) simsave.eq[,k,3,1]<-as.vector(temp) hqsave [,k,3]<-as.vector(hq) eqO<-.4/(.4+eps) IO<-matrix(rbinom(1600,1,eqO),nrow=40,ncol=40) temp<-loop(100,IO,eps,.8) simsave.eq[,k,3,2]<-as.vector(temp) ## Third Landscape - 80% Random- Disequilibrium simulations IO<-matrix(sample(c(rep(0,1560),rep(1,40)),1600,replace=FALSE),nrow=40,ncol=40) temp<-loop(12,IO,eps,.4) simsave.diseq[,k,3,1]<-as.vector(temp) temp<-loop(12,IO,eps,.8) simsave.diseq[,k,3,2]<-as.vector(temp) ## Fourth Landscape – 50% Block- Equilibrium simulations hq<-matrix(c(rep(1,800),rep(0,800)),nrow=40,ncol=40) eps<-.8-.7*hq eqO<-.2/(.2+eps) IO<-matrix(rbinom(1600,1,eqO),nrow=40,ncol=40) temp<-loop(100,IO,eps,.4) simsave.eq[,k,4,1]<-as.vector(temp) hqsave [,k,4]<-as.vector(hq) eqO<-.4/(.4+eps) IO<-matrix(rbinom(1600,1,eqO),nrow=40,ncol=40) temp<-loop(100,IO,eps,.8) simsave.eq[,k,4,2]<-as.vector(temp) ## Fourth Landscape – 50% Block- Disequilibrium simulations IO<-matrix(sample(c(rep(0,1560),rep(1,40)),1600,replace=FALSE),nrow=40,ncol=40) temp<-loop(12,IO,eps,.4) 3 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 simsave.diseq[,k,4,1]<-as.vector(temp) temp<-loop(12,IO,eps,.8) simsave.diseq[,k,4,2]<-as.vector(temp) } #summarize results for each landscape and simulation by habitat quality occupancy occbyhab.eq<-array(NA,dim=c(2,100,4,2)) occbyhab.diseq<-array(NA,dim=c(2,100,4,2)) for (i in 1:100){ for (j in 1:4){ occbyhab.eq[1,i,j,1]<-mean(subset(simsave.eq[,i,j,1],hqsave[,i,j]==0)) occbyhab.eq[2,i,j,1]<-mean(subset(simsave.eq[,i,j,1],hqsave[,i,j]==1)) occbyhab.eq[1,i,j,2]<-mean(subset(simsave.eq[,i,j,2],hqsave[,i,j]==0)) occbyhab.eq[2,i,j,2]<-mean(subset(simsave.eq[,i,j,2],hqsave[,i,j]==1)) occbyhab.diseq[1,i,j,1]<-mean(subset(simsave.diseq[,i,j,1],hqsave[,i,j]==0)) occbyhab.diseq[2,i,j,1]<-mean(subset(simsave.diseq[,i,j,1],hqsave[,i,j]==1)) occbyhab.diseq[1,i,j,2]<-mean(subset(simsave.diseq[,i,j,2],hqsave[,i,j]==0)) occbyhab.diseq[2,i,j,2]<-mean(subset(simsave.diseq[,i,j,2],hqsave[,i,j]==1)) }} #For figure 4 analysis summarize habitat.1<-function(H){ (H[c(2:40,1),]+H[c(40,1:(40-1)),]+H[,c(2:40,1)]+H[,c(40,1:(40-1))]+H[c(2:40,1),c(2:40,1)]+ H[c(40,1:(40-1)),c(40,1:(40-1))]+H[c(40,1:(40-1)),c(2:40,1)]+H[c(2:40,1),c(40,1:(40-1))])/8} nonpar<-array(NA,dim=c(18,100,4,4)) par(mfrow=c(1,2)) for (k in 1:100){ for (j in 1:4){ t1<-simsave.eq[,k,j,1] t2<-hqsave[,k,j] t3<-as.vector(habitat.1(matrix(hqsave[,k,j],nrow=40))) t4<-as.vector(habitat.1(matrix(simsave.eq[,k,j,1],nrow=40))) for (i in 1:9){ t5<-subset(t1,t2==0&t3==((i-1)/8)) nonpar[i,k,j,1]<-ifelse(length(t5)>9,mean(t5),NA) t5<-subset(t1,t2==1&t3==((i-1)/8)) nonpar[(i+9),k,j,1]<-ifelse(length(t5)>9,mean(t5),NA) t5<-subset(t1,t2==0&t4==((i-1)/8)) nonpar[i,k,j,2]<-ifelse(length(t5)>9,mean(t5),NA) t5<-subset(t1,t2==1&t4==((i-1)/8)) nonpar[(i+9),k,j,2]<-ifelse(length(t5)>9,mean(t5),NA) } }} 4