project-sl80.r

text/r-latex project-sl80.r — 742 B

File contents

# Forward project an age-structured population
# Have initial values for projections in Nhist etc
# Historical value was 0.35 (in initproj.r)
#
# Single projection case
#
recrCV<-0.4
N0<-Nhist
Fmort<-1.5
Z<-Fmort*sa+M
Ytraj<-c()
Straj<-c()

years=1:30


for(y in years){
  C<-(Fmort*sa/Z)*(1-exp(-Z))*N0
  S<-sum(wa*pa*N0)
  #R<-(alpha*S/(1+S/K))*exp(rnorm(1)*recrCV) # Recr with variation
  R<-(alpha*S/(1+S/K))                  # Recr without variation
  N1<-N0*exp(-Z)
  N0<-c(R,N1[1:(length(N1)-1)])
  Ytraj<-c(Ytraj,sum(wa*C))
  Straj<-c(Straj,S)
}
# Typical commands
# source("project.r")
par(mfrow=c(1,2))
plot(years,Ytraj,type='b')
plot(years,Straj,type='b')
# change commands and re-source
# source("project.r")
# lines(years,Ytraj)