project-sl70.r

text/r-latex project-sl70.r — 0 KB

File contents

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

years=1:5


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)