#This script will not work alone. Global parameters for temperature and copepodid attachment rate are in S2, S3 and S4 (only run one at a time). Calculations are for daily rates #Install the packages require(triangle) require(popbio) require(matrixStats) #Parameters and sample sizes are here #Parameters SampleSize = 1 #Sample Size for each stage- set at 1 in the paper, larger sample sizes will increase the 'within-population' variation and reduce confidence intervals on outputs #Developmental Parameters EggB1 = 41.98 EggB1SE = 2.85 EggB2 = 0.338 EggB2SE = 0.01200 EggV = 2 NaupliiB1 = 24.79 NaupliiB1SE = 1.43 NaupliiB2 = 0.525 NaupliiB2SE = 0.017 NaupliiV = 0 ChB1 = 74.7 ChB1SE = 33.64 FChB2 = 0.246 FChB2SE = 0.007 FChV = 0.793 PreadB1 = 67.47 PreadB1SE = 20.36 FPreadB2 = 0.177 FPreadB2SE = 0.006 FPreadV = 0.30333 #Survival Parameters, (create a distribution of survival estimates using the triangle function) EggPercentNonviable = rtriangle(SampleSize, .04, .25, .10) EggSurv = (0.96797) NaupliiSurv = (0.83000) FChalimusSurvMode =(0.992) FChalimusSurvUpper = (0.997) FChalimusSurvLower = (0.98) FChalimusSurvVect = rtriangle(SampleSize, FChalimusSurvLower, FChalimusSurvUpper, FChalimusSurvMode) FPreadSurvMode = (0.965) FPreadSurvUpper = (0.98) FPreadSurvLower = (0.953) FPreadSurvVect = rtriangle (SampleSize, FPreadSurvLower, FPreadSurvUpper, FPreadSurvMode) FAdultSurvMode = (0.965) FAdultSurvUpper= (0.997) FAdultSurvLower= (0.904) FAdultSurvVect = rtriangle(SampleSize, FAdultSurvLower, FAdultSurvUpper, FAdultSurvMode) #Fecundity PropEggsFemale=0.5 TimeHatching = 1 FirstEggstringSize =152 FirstEggstringSizeSD = 31 RandFirstEggstringSize=rnorm(SampleSize, mean=FirstEggstringSize, sd=FirstEggstringSizeSD) #sample Eggstring sizes from a normal distribution TimeToSubsequentEggstring = max(-1.2*Temp + 19.64, 1) #Equation 7 SubsequentEggstringSize = 296 SubsequentEggstringSizeSD = 100 RandSubsequentEggstringSize=rnorm(SampleSize, mean=SubsequentEggstringSize, sd=SubsequentEggstringSizeSD) #sample Eggstring sizes from a normal distribution #Copepodids #CopAttach =0.1 CopDevel =4.6 CopSurv=(CopAttach)^(1/(CopDevel)) #Equation Six #Calculate Developmental Times. For each life stage the time until development is calculated using a belahradek equation (equation 4) and adding it to the minimum development time (equation 5) RandEggB1= rnorm(SampleSize, mean=EggB1, sd=EggB1SE) RandEggB2= rnorm(SampleSize, mean=EggB2, sd=EggB2SE) EggTimes=vector(mode="numeric",length=0) for(i in 1:length(RandEggB1)){ EggTime=((RandEggB1[[i]]/(Temp-10+(RandEggB1[[i]]*RandEggB2[[i]])))^2)+EggV; EggTimes=cbind(EggTimes, EggTime)} #Nauplii RandNaupliiB1= rnorm(SampleSize, mean=NaupliiB1, sd=NaupliiB1SE) RandNaupliiB2= rnorm(SampleSize, mean=NaupliiB2, sd=NaupliiB2SE) NaupliiTimes=vector(mode="numeric",length=0) for(i in 1:length(RandNaupliiB1)){ NaupliiTime=((RandNaupliiB1[[i]]/(Temp-10+(RandNaupliiB1[[i]]*RandNaupliiB2[[i]])))^2)+NaupliiV; NaupliiTimes=cbind(NaupliiTimes, NaupliiTime)} #Female Chalimus RandFChB1= rnorm(SampleSize, mean=ChB1, sd=ChB1SE) RandFChB2= rnorm(SampleSize, mean=FChB2, sd=FChB2SE) FChTimes=vector(mode="numeric",length=0) for(i in 1:length(RandFChB1)){ FChTime=((RandFChB1[[i]]/(Temp-10+(RandFChB1[[i]]*RandFChB2[[i]])))^2)+FChV; FChTimes=cbind(FChTimes, FChTime)} #Female Preadults RandFPreadB1= rnorm(SampleSize, mean=PreadB1, sd=PreadB1SE) RandFPreadB2= rnorm(SampleSize, mean=FPreadB2, sd=FPreadB2SE) FPreadTimes=vector(mode="numeric",length=0) for(i in 1:length(RandFPreadB1)){ FPreadTime=((RandFPreadB1[[i]]/(Temp-10+(RandFPreadB1[[i]]*RandFPreadB2[[i]])))^2)+FPreadV; FPreadTimes=cbind(FPreadTimes, FPreadTime)} #Matrices from Vectors of Values #Transition #G G1 =(1/median(EggTimes))*EggSurv #Equation 2 G2 = (1/(CopDevel+median(NaupliiTimes)))*CopSurv*NaupliiSurv #Equation 2 G3 =(1/(median(FChTimes)))*mean(FChalimusSurvVect) #Equation 2 G4 =(1/(median(FPreadTimes)))*mean(FPreadSurvVect) #Equation 2 G5 = 1/TimeHatching*mean(FAdultSurvVect) #Equation 8 G6 =(1/(median(TimeToSubsequentEggstring)+median(EggTimes)-TimeHatching))*mean(FAdultSurvVect) #Equation 9 G7 = 1/TimeHatching*mean(FAdultSurvVect) #Equation 8 #P P1 = EggSurv*(1-G1) #equation 1 P2 = CopSurv*NaupliiSurv*(1-G2) #equation 1 P3 = mean(FChalimusSurvVect)*(1-G3) #equation 1 P4 = mean(FPreadSurvVect)*(1-G4) #equation 1 P5 = mean(FAdultSurvVect)*(1-G5) #equation 1 P6 = mean(FAdultSurvVect)*(1-G6) #equation 1 P7 = mean(FAdultSurvVect)*(1-G7) #equation 1 # Fecundity FirstClutchSizes=vector(mode="numeric",length=0) SubsequentClutchSizes=vector(mode="numeric",length=0) for(i in 1:length(RandFirstEggstringSize)){ FirstClutchSize=((1-EggPercentNonviable[[i]])*RandFirstEggstringSize[[i]])*2/(TimeHatching) #multiply by 2 for 2 eggstrings FirstClutchSizes=cbind(FirstClutchSizes, FirstClutchSize)} F1 = mean(FirstClutchSizes)/2 #equation 3, divided by 2 for females only for(i in 1:length(RandSubsequentEggstringSize)){ SubsequentClutchSize=((1-EggPercentNonviable[[i]])*RandSubsequentEggstringSize[[i]])*2/(TimeHatching) #multiply by 2 for 2 eggstrings SubsequentClutchSizes=cbind(SubsequentClutchSizes, SubsequentClutchSize)} F2 = mean(SubsequentClutchSizes)/2 #equation 3, divided by 2 for females only