# Tag history generation for the JS model # January 22, 2013 # statistics to be fixed before generation n=10 #number of individuals in the population nsample=5 #number of sample times #creation of vectors entrypoint=numeric(length=n) b=numeric(length=nsample) #probability of birth/immigration (sum to 1) bstar=numeric(length=nsample) # fraction entering the population phi=numeric(length=(nsample-1)) #probability of survival p=numeric(length=nsample) #probability of capture first=numeric(length=n) #first entry time of individual i history=matrix(rep(0,n*nsample), nrow=n, ncol=nsample) freq=numeric(length=n) #frequency of each capture history. Normally this is equal to 1 but if lost on capture this is -1 #initialization of parameters b[1:nsample]=1/nsample for(i in 1:nsample){ bstar[i]=b[i]/sum(b[i:nsample]) } p[1:nsample]=0.9 phi[1:nsample-1]=0.8 loss_parm=0.1 freq[1:n]=0 for(i in 1:n){ # Determine when the individual enters the population (before entrypoint[i]) j=1 alive=0 while(alive==0){ if(runif(1,0,1)phi[l]){ alive=0 }#endif }#endif l=l+1 }#endwhile # Determine tagging history if(first[i]>0 & (first[i]phi[k-1]){ alive=0 }#endif # Is the animal captured and if so are they lost on capture? if(runif(1,0,1)