Forums

Back

SSB calculation with external wtatage

Iago Mosqueira, modified 3 Years ago.

SSB calculation with external wtatage

Youngling Posts: 24 Join Date: 8/12/16 Recent Posts

Hello,

I am finding a small difference in a model using wtatage.ss for weights and maturity*fecundity. Report.sso returns an SSB estimate in 1991 of 4300 t, but the calculation from natage and maturity gives 4282. Not major, but I am curious to what could be the reason.

Please find attached the output files (gz compressed but should load fine in R) and the code I am using. Any idea of the reason for this difference?

Thanks

 

Iago

IT
Ian Taylor, modified 3 Years ago.

RE: SSB calculation with esternal wtatage

Youngling Posts: 117 Join Date: 12/8/14 Recent Posts

Hi Iago,

I'm not seeing anything obvious that you're missing. The wtatage.ss_new file values under Fleet = -2 combined with the numbers at age at the start of the year SHOULD match the Spawning Biomass values for a model like this without multiple seasons or other complexity.

I was able to get a much closer match for a different model (off by 0.0001% instead of your 0.4%) using the same calculations shown in your R script, suggesting that there's something unusual about this particular model.

Could you share the 5 model input files to help us debug, either by attaching her to the VLab forum or emailing them to me directly?

-Ian

Iago Mosqueira, modified 3 Years ago.

RE: SSB calculation with esternal wtatage

Youngling Posts: 24 Join Date: 8/12/16 Recent Posts

With another model that also uses watatage I get a perfect match, so yes, it could be something in this one.

Iago Mosqueira, modified 3 Years ago.

RE: SSB calculation with esternal wtatage

Youngling Posts: 24 Join Date: 8/12/16 Recent Posts

Hi,

 

Forgot to send the wtatage.ss_new file, which is what ss3om uses to load mat and wts.

 

Iago

KD
Kathryn Doering, modified 3 Years ago.

RE: SSB calculation with esternal wtatage

Youngling Posts: 57 Join Date: 2/19/19 Recent Posts

Hi Iago,

 

Thanks for replying, this one fell off the SS team's radar - sorry about that. If you don't get a useful reply within a few days, feel free to post again on this thread to remind us again.

 

Thanks,

Kathryn

Iago Mosqueira, modified 3 Years ago.

RE: SSB calculation with esternal wtatage

Youngling Posts: 24 Join Date: 8/12/16 Recent Posts

I might be doing some wrong, but this is the quick checkup I coded

 

Iago

 

library(r4ss)
library(data.table)

# LOAD files
fev <- SS_output("vendace")
waan <- data.table(r4ss::SS_readwtatage('vendace/wtatage.ss_new'))

# EXTRACT data.tables
natage <- data.table(fev$natage)
derq <- data.table(fev$derived_quants)

# N
stkn <- natage[Yr == 2019 & `Beg/Mid` == "B", 13:25]

# WT
wt <- unlist(waan[Yr == 2019 & Fleet == 0, 7:19])

# MAT
mat <- unlist(waan[Yr == 2019 & Fleet == -2, 7:19]) / wt

# SSB
sum(stkn * mat * wt)

# Returns 8216

# Derived quantities
derq[Label == "SSB_2019",]

# Label Value StdDev (Val-1.0)/Stddev CumNorm

# 1: SSB_2019 8128 1064 NA NA

IT
Ian Taylor, modified 3 Years ago.

RE: SSB calculation with external wtatage

Youngling Posts: 117 Join Date: 12/8/14 Recent Posts

Hi Iago,

I don't see anything wrong with your calculations, so I think this is a real issue. I've volunteered to track it down but didn't get to it yet and will be on leave next week around the U.S. Thanksgiving holiday. Hopefully the small differences won't cause you problems in the short term and have faith that it hasn't been forgotten.

-Ian

Iago Mosqueira, modified 3 Years ago.

HiRE: SSB calculation with external wtatage

Youngling Posts: 24 Join Date: 8/12/16 Recent Posts

Hi,

No hurry at all. This model from Max Cardinale is just one of the tests I have in the ss3om package

Cheers,

 

Iago

Richard Methot, modified 2 Years ago.

RE: SSB calculation with external wtatage

Youngling Posts: 219 Join Date: 11/24/14 Recent Posts

This mismatch occurs because the external calculation erroneously uses the age 0 fish.
In this vendance example, the age 0 fish have tiny, but non-zero fecundity.
In the internal calc of SSB at beginning of the year, the age 0 fish do not yet exist, so are not included in the SSB.
In this annual model configuration, recruitment of age 0 fish then occurs immediately after the SSB is calculated.
These age 0 fish are in the N-at-age table output for the beginning of the year.
So, the external calculation is different and incorrect  due to inclusion of the age 0 fish in the SSB.

Iago Mosqueira, modified 2 Years ago.

RE: SSB calculation with external wtatage

Youngling Posts: 24 Join Date: 8/12/16 Recent Posts

Many thanks. Setting maturity at 0 for age 0 for the SSB calculation makes it work, except for the first year, 1991, where the difference still remains (4261 vs. 4299). Anything special about the first year that could cause this?

Richard Methot, modified 2 Years ago.

RE: SSB calculation with external wtatage

Youngling Posts: 219 Join Date: 11/24/14 Recent Posts

Hi Iago. Thanks for looking at this so closely. I will look into the year 1 discrepancy and report back here.

Richard Methot, modified 2 Years ago.

RE: SSB calculation with external wtatage

Youngling Posts: 219 Join Date: 11/24/14 Recent Posts

Iago,

I was not able to reproduce any discrepancy using 3.30.18 and with all the age 0 fecundities set to 0.0.  

I get:

  Internal external
SSB_Virgin 23636.2 23636.2
SSB_Initial 4300.8 4300.8
SSB_1991 4261.4 4261.4
SSB_1992 5030.9 5030.9
SSB_1993 2996.5 2996.5
Iago Mosqueira, modified 2 Years ago.

RE: SSB calculation with external wtatage

Youngling Posts: 24 Join Date: 8/12/16 Recent Posts

Right, I have redone the correction for ssb in FLR and it now matches SS's reported SSB. Many thanks