Open marchtaylor opened 7 years ago
If the FLSR object is being created from an FLStock, then the recruitment age is taken by default from the dimnames of stock.n, as in as.FLSR()
rec.age = dims(stock.n(object))$min
dims()
will convert the dimnames from character to numeric. This is then used to subset with the corresponding lag, by turning it again into a character.
rec <- object@stock.n[as.character(rec.age),]
ssb <- ssb(object)
Now, I am not sure how FLBEIA is then using this, but you could start by checking the FLSR objects being created and see if they are correct. I hope @dorleta or @AgurtzaneUrtizberea can answer that.
Thanks Iago. Yes, as I mentioned in the question, I did do this check with FLSR and found it to correctly model the lag. Here's an example:
# setup
library(FLCore)
library(FLash)
library(FLAssess)
data("ple4")
# coerce to stock with lowest age=2
ple4sm <- trim(ple4, age=2:range(ple4)["max"])
# create SRR and fit
ple4smsrr <- as.FLSR(ple4sm)
model(ple4smsrr) <- "ricker"
ple4smsrr <- fmle(ple4smsrr)
plot(ple4smsrr)
# compare years considered for ssb and rec
head(cbind(
ssb=colnames(ssb(ple4smsrr)),
rec=colnames(rec(ple4smsrr))
))
# projection
ctrl_target <- data.frame(
year = range(ple4sm)["maxyear"]+1,
rel.year = range(ple4sm)["maxyear"],
quantity = "f",
val = 1
)
ctrl_obj <- fwdControl(ctrl_target)
ple4sm <- stf(ple4sm, 1)
range(ple4)
range(ple4sm)
ple4sm <- fwd(ple4sm, ctrl = ctrl_obj, sr = ple4smsrr)
# compare projected recruitment
a <- params(ple4smsrr)["a"]
b <- params(ple4smsrr)["b"]
S <- ssb(ple4sm)[,ac(2007)]
c(a*S*exp(-b*S), rec(ple4sm)[,ac(2009)])
Hi Marc,
In FLBEIA the recruitment is simulated using the class FLSRsim. This class has an slot ‘timelag’ that is used to specify the time lag between spawning and recruitment and the season when the season spawn takes places. Timelag is a matrix with dimension [2; number_of_seasons]. For each season, the element in the first row indicates the age at recruitment and the element in the second row indicates the season at which the recruitment is spawn.
Hope this helps,
Best regards,
Dorleta
De: marchtaylor [mailto:notifications@github.com] Enviado el: jueves, 09 de febrero de 2017 13:55 Para: flr/FLBEIA CC: Dorleta Garcia; Mention Asunto: Re: [flr/FLBEIA] Defining lags in stock recruitment relationship (#13)
Thanks Iago. Yes, as I mentioned in the question, I did do this check with FLSR and found it to correctly model the lag. Here's an example:
library(FLCore)
library(FLash)
library(FLAssess)
data("ple4")
ple4sm <- trim(ple4, age=2:range(ple4)["max"])
ple4smsrr <- as.FLSR(ple4sm)
model(ple4smsrr) <- "ricker"
ple4smsrr <- fmle(ple4smsrr)
plot(ple4smsrr)
head(cbind(
ssb=colnames(ssb(ple4smsrr)),
rec=colnames(rec(ple4smsrr))
))
ctrl_target <- data.frame(
year = range(ple4sm)["maxyear"]+1,
rel.year = range(ple4sm)["maxyear"],
quantity = "f",
val = 1
)
ctrl_obj <- fwdControl(ctrl_target)
ple4sm <- stf(ple4sm, 1)
range(ple4)
range(ple4sm)
ple4sm <- fwd(ple4sm, ctrl = ctrl_obj, sr = ple4smsrr)
a <- params(ple4smsrr)["a"]
b <- params(ple4smsrr)["b"]
S <- ssb(ple4sm)[,ac(2007)]
c(aSexp(-b*S), rec(ple4sm)[,ac(2009)])
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/flr/FLBEIA/issues/13#issuecomment-278632610, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AEz9MmBN7JigXpOKI7I4g1_DPdOwmbYaks5rawyagaJpZM4L7uY8.
Hi Dorleta - Thanks for this information!
I was wondering how FLBEIA treats lags in the stock recruitment relationship (SRR).
In FLR, the fitting of SRRs (via FLSR and fmle) and subsequent projection (via fwd) both take into consideration the age of the lowest class when determining a lag.
I am using 2 stocks for which the lower age class is not age 1; haddock uses age=0 and saithe uses age=3. In my first FLBEIA simulation, I only defined one historical year (2015) and three projection years (2016-2018) - So, I would expect to have a problem predicting the recruitment of saithe in 2016, since I did not provide a SSB for time minus 3 years (e.g. 2013). To the contrary, I see no discontinuities in the saithe projection of recruitment. Eventually I will include more historical years in order to get this lagged recruitment correct, but, in the meantime, I would like to know why the run was actually successful.
Hopefully someone can point me in the right direction to correctly condition the SRRs in my model.
Thanks in advance for any advice.