flr/FLXSA

Error in SSB calculation

Opened this issue · 12 comments

Hi!
I am currently trying to apply the XSA to one of ICES redfish stocks. I thought I followed the tutorial, however now the XSA values for SSB look rather unreasonable. So far I have uploaded my data, converted it to an FLStock object and defined the range, m, m.spwn and maturity at age. Afterwards I computed landings, discards and catch.

After running the XSA with a survey index and the default xsa.control, calculations for F and recruits seem reasonable, while SSB is given from 3.8 million to Inf.
I checked the input/output for stock.n, mat, and mean weight, seeing as these parameters are needed for the calculation, but they seem ok. The only parameter that is not calculated is ’stock’. I am not sure exactly why that is, or if it even is relevant for the calculation of SSB.

I’d be very grateful for any help on the matter!

Of course!

Reb.zip

Thanks. Took a quick look and I think the issue is with the data, not simply a software error. Will check next week, when back at work.

I was afraid of that.. Thanks again, your help is very much appreciated! I will also go back and check my input data again.

It is only catch.n and index that matter, apart from m. Then mat and .spwn only apply in the calculation of ssb. The index and catch jumps appear pretty large, with not that much of a cohort effect. I there any other process that could be affecting the index abundances?

Hi Iago, very sorry for the delayed response! Unfortunately we are not able tell what causes these fluctuations in the index. Could be due to parts of the stock migrating out into the Irminger sea, but this pattern has also been observed in other stocks. The missing cohort effect might also be linked to our age-length conversion, seeing as definitive age readings are quite difficult for this species. However the NAFO has successfully used an XSA for one of their redfish stocks, despite similar fluctuations. In case you are interested, I'll attach their report.

NAFO2002.pdf

I have also tried calculating SSB outside of R using the same input as for the XSA and this returned very different numbers. I am still not sure why the model returns such high numbers for certain years only (1986/94,2010/15).

I think computationally the main problem is that there are years with zero catches in the terminal age. So the VPA is unable to construct terminal Ns as F=0. f you try, for the sake of testing, to run it from 2010 and with a new plusgroup set at age 30, it works

lpg <- setPlusGroup(window(FLStock_Reb, start=2010), 30)

rpg <- FLXSA(lpg, Index_reb[[1]][ac(3:30),])

plot(lpg + rpg)

I would suggest trying an SCA method, like FLa4a, that should be able to accommodate changes in selectivity because of those movements, for example. Any SCA method should not fail because of the catch data issue.

Right, that actually makes a lot of sense, I will definitely look into the FLa4a! For now I have adjusted my input with a new plusgroup at age 30. However now I am getting the following error when trying to run the XSA:

Error in h(simpleError(msg, call)) :
error in evaluating the argument 'X' in selecting a method for function 'lapply': trying to get slot "index" from an object of a basic class ("character") with no slots

Sorry for all the trouble and thanks again for your help!

Plusgroup at age 30 might not be enough, you see I had to cut down on years of data used. 1994, for example, has catch data for 2 ages only.

That error appears to reflect your call is not passing an FLIndices (Index_reb) or FLIndex (Index_reb[[1]]) to FLXSA, but rather a character variable. Are you using the call up here?

Yes, I am trying to find more reliable data for these years. Unfortunately we don't have any age structures for catches in the 90s, so these numbers were taken from the survey. Obviously not a great fit, but I am trying to fix that.

I really don't see what I do differently. The structure of my input really looks the same as before.
Reb.zip

Hi Iago,

So sorry to have to bother you again. I spent the past few days working on the XSA, trying to run the model with different inputs. You suggested the high SSB values to be connected to zero catches in the terminal age. For the sake of testing I ran the model with new plus groups and also replaced zero catches with low estimates. However it did not translate to the model output, as it still returned incredibly high values for 1986, 2015. For these years, the input did not require any alterations and the output looks reasonable in terms of stock numbers at age. Maturity and weight at age are the same for all years and the harvest rate in those years is not exceptionally low, which I would expect if SSB showed such a marked increase. To me it seems as if there was an internal inconsistency in the calculation of SSB.

I have attached the model output below. It would be greatly appreciated if you could check if I missed something or if you come to the same conclusion. Thank you again for your help!

Karo

Output_Reb.zip

SSB is calculated post-hoc from stock.n, mat, stock.wt and corrected for F and M if necessary, as shown here:

https://github.com/flr/FLCore/blob/master/R/FLStock.R#L333

During the XSA adjustment only catch.n, m and the indices are used in the calculations, and the output is formed by the stock.n and harvest estimates.

So I am afraid I fail to see where the bug might be, and has more to do with the ability of the method itself to make sense of these data. Do you see anything in particular that could be wrong in the code?