## Varying r in Bedding host parasitoid model ## preliminaries Nt<- 1000 Pt<- 20 alpha<-0.002 r<-3 c<-1 K<-2000 Beddington<-function(fNt,fPt,fr,falpha,fK,fc){ NtPlus1<-fNt*exp((fr*(1-(fNt/fK)))-(falpha*fPt)) PtPlus1<-fc*fNt*(1-(exp(-falpha*fPt))) answer<-c(NtPlus1,PtPlus1) answer } hosts<-Nt #starting these two vectors with the initial host and parasitoid populations parasitoids<-Pt number_of_generations<-1000 for(i in 1: number_of_generations){ answer<-Beddington(Nt,Pt,r,alpha,K,c) hosts<-c(hosts,answer[1]) parasitoids<-c(parasitoids,answer[2]) Nt<-answer[1] Pt<-answer[2] } # end of i loop plot(1:length(hosts), hosts, ylim=c(0,max(hosts)), col= "green", pch=20, xlab="Generations", ylab="Population size",main="Parasitoid-Host Population Dynamics") points(1:length(hosts), parasitoids,col="red", pch=20) points (number_of_generations/4.5, max(hosts)*1.07, col= "green", pch=20, xpd=NA) text (number_of_generations/3.5, max(hosts)*1.07, "Hosts", xpd=NA) points (number_of_generations/2, max(hosts)*1.07, col= "red", pch=20, xpd=NA) text (number_of_generations/1.65, max(hosts)*1.07, "Parasitoids", xpd=NA) Part 1 # in our current model increasing r to 3.472 is about the limit # incresing alpha canlead to chaotic behaviur Part 2 # here alpha is set to 0.003 alpha<-0.003 par(mfrow=c(2,2)) # top left plot(1:length(hosts), hosts, ylim=c(0,max(hosts)), col= "green", pch=20, xlab="Generations", ylab="Population size",main="Parasitoid-Host Population Dynamics") points(1:length(hosts), parasitoids,col="red", pch=20) points (number_of_generations/4.5, max(hosts)*1.07, col= "green", pch=20, xpd=NA) text (number_of_generations/3.5, max(hosts)*1.07, "Hosts", xpd=NA) points (number_of_generations/2, max(hosts)*1.07, col= "red", pch=20, xpd=NA) text (number_of_generations/1.65, max(hosts)*1.07, "Parasitoids", xpd=NA) # top right plot(hosts,parasitoids,pch=20,xlab="Host population size",ylab="Parasitoid population size",main="Parasitoid-Host Phase Plot", cex=0.5) # bottom left plot(hosts,parasitoids,pch=20,xlab="Host population size",ylab="Parasitoid population size", main="Parasitoid-Host Phase Plot", cex=0.5) lines(hosts,parasitoids) # bottom # bottom left plot(hosts/parasitoids,log(hosts),pch=20,xlab="Host population size",ylab="Host:parasitoid ratio", main="Parasitoid-Host Ratio Plot", cex=0.5)