Open sw-parker opened 11 months ago
Yeah. Sounds good. I am close to having the MetaPVA working in a vectorized way. I need to figure out how to speed up the multinomial process of moving fish between rivers.
The vectorization will be very helpful since the other main feedback/recommendation we received on this manuscript was that we needed to conduct a sensitivity analysis on parameters used in the PVA. They are particularly interested in how our results may change with respect to variations in recK (e.g., 2-5).
I can vectorize it, the issue is the runtime. I am not sure I am going to be able to speed it up. It turns out that the multinomial draw to cause the fish to move between tributaries is significantly slowing down the runtime. Increasing runtime about 5x
So here is an example of vectorized MetaPVA output. It shows extirpation for each river for a grid of hurricane frequency and severity of episodic adult mortality. It is contained in the file MetaCatastrophe.pptx .
Only bad thing is that with 200 simulations, it takes nearly an hour to run.
@sw-parker @billpine @DanGwinn
With Ben Staton's help, I was able to incorporate parallel processing and speed up the execution a bunch. Also, I have been running the model on the NOAA supercomputer to run much faster.
Still have to answer these questions:
what ages should disperse from one stock to another? what information should we retain for each simulation? I am currently returning the total abundance and total adult time series of each of the 7 populations. I am also returning the extirpation probability of each river.
Stephen also wants proportion of runs that decline from No to N@25years. I will probably compute the proportion of runs where the average adult abundance from N from years 20-25 have declined by 25% or more. Stephen, Let me know is that is not what you want.
Stephen, I will also compute the time series of average age and return that.
Stephen, here are some additional thoughts about what you wrote here:
Adding probabilities of losing X populations
I can add this in, I will compute the probability of losing each of 1-7 populations for each simulation.
Assessing which population(s) seems to face the highest risk of extirpation
I already output the extirpation probability of each population across whatever pair of variable we look at. So you can use that to answer this question.
(most importantly) providing some range-wide/species-level extinction risk probability would increase the utility of our paper.
This actually gets to the broader question that needs to be addressed. What combinations(s) of factors to you want to assess and report in the paper? Since I am getting close to having all the machinery in place, now you need to decide how to use that machinery.
I constructed the code to compute the probability of declining and the mean age timeseries.
The updated version of MetaPVA2.R seems much faster than what I was running a day or two ago, and it's not written to run in parallel. I was seeing runtimes over a minute then and 5-9 seconds now, which is confusing.
Were you having runtime issues with the MetaPVA2 script or just the MetaPVA_EpFreqVsEpAM script?
It is probably the control file is set to just a few simulations. Is it running to the end and outputting the figures?
This file (MetaPVA_EpFreqVsEpAM.R) is the one that is now running in parallel.
The program runtime is very dependent on the number of simulations. The main dimensions of the problem are number of years (nT 200) and number of simulations n.sim. The number of age classes (A 60) and number of populations (n.pops 7) are the other dimensions. The number of simulations should be fairly large to get final results (n.sim>500) but you can run the program with fewer simulations to troubleshoot the program or look for gross behavior.
When we get answers to the questions I posed above and we decide the simulation output we want to report, I can run the program with larger numbers of simulations on the NMFS supercomputer.
@sw-parker @billpine @DanGwinn
I added the functionality to examine the probability of particular numbers of stocks being extirpated:
0 stocks extirpated 1 or more stocks extirpated 2 or more stocks extirpated 3 or more stocks extirpated ... 6 or more stocks extirpated 7 stocks extirpated
Have a look at this file for results https://github.com/LewCoggins-NOAA/GulfSturgeon/blob/main/ExtirpationProbForParticularNumbersOfStocks.pptx
Given my examination of >500 of the ~1,000 GS detected in multiple rivers in the database, our adult length cutoff of 1350 TL mm (used in the Barker and multistate manuscripts) is an acceptable threshold for movement between rivers. Based on our length-at-age vector and an Linf of 2200 mm, this corresponds to age 7.
Therefore, let's apply our multinomial movement function to age 7+ fish.
OK. Should be able to make the only the older fish move pretty quickly.
Recalling your comment that the managers would like to see the impact of different values of RecK, what range of values should we examine? I was thinking we could make a surface plot that was essentially examining uncertainty in the two major life history drivers: RecK and Madult. For the Madult, because the mortality rate varies among rivers, we could use a multiplicative factor to examine a range of mortality rates. Say mortality for each river ranging between 0.5 to 1.5 x the value that you estimated.
So have RecK on one axis, Madult factor on the other axis, and then examine which ever of the performance measures as the Z-value.
Is that something that you would want to include in your manuscript?
The recK values I found in the literature are between 3.9 and 5. A range of 2 to 6 for recK and 0.5 to 1.5x for mortality sounds good to me.
Yes, I like it. I think this approach will provide the managers with the sensitivity analysis they've asked for.
Would there be one recK vs Madult factor plot or one for each river?
OK. I will see if I can set that up today.
We can examine whichever output metric you want. Either by river or the probability of a particular number of rivers becoming extirpated like the figure I sent you on Friday.
Update:
I added the code to allow minimum movement age. I also ran simulations with a range of RecK and a Range of Madult factors. I had some problems with using IBM recruitment so ultimately resorted to standard BH Stock Recruit.
Also the recruitment compensation did not show any difference until I increased mortality with catastrophes.
If @sw-parker and @billpine have time to meet tomorrow, that would be good. I am nearing the end of what I had in mind to contribute to this project and I do not know what else would be helpful.
Here are results to examine that capture most of what I have done. Results10-30-23.pptx https://github.com/LewCoggins-NOAA/GulfSturgeon/blob/main/Results10-30-23.pptx
@sw-parker @billpine
Use this code to compute a river specific relative vulnerability score.
tempvul=rep(0,n.pops) for(i in 1:7){tempvul[i]=(sum(matrix(extir[i,],numAM.FactorVals,numRecKVals))/110)}
note that the 110 value should be the product of the length of the two vectors of factors used when you run the MetaPVA function
vul=tempvul/max(tempvul);vul
@sw-parker @billpine
I just updated the Repro one more time to make sure that I had working versions of the two MetaPVA R programs. I also got rid of a few commented out lines and added a few more descriptive comments.
I suggest you use these versions to begin your further exploration/development.
After revisiting the comments from the project managers, a desirable deliverable that was missing from my dissertation was a synthesis of the PVA results to the species in terms of overall extinction risk. Adding probabilities of losing X populations, assessing which population(s) seems to face the highest risk of extirpation, and (most importantly) providing some range-wide/species-level extinction risk probability would increase the utility of our paper.