Easy computation of reference points
flr / flref Goto Github PK
View Code? Open in Web Editor NEWEasy computation of reference points
Easy computation of reference points
I was running a bootstrap SR on my stock object and some of the runs resulted in reference points that were higher than fcrash and which gave negative yield and recruitment. Presumably the correct behaviour in this case should be zero yield and recruitment.
Here is some code to illustrate the issue:
library(stockassessment)
library(FLCore)
library(FLfse)
library(FLRef)
SAMfit <- fitfromweb('whg.7b-ce-k_WGCSE22_RevRec_2023')
stk <- SAM2FLStock(SAMfit,catch_estimate = T)
`
# one of the iterations in my bootstrap that gives strange results
i <- c(19L, 10L, 6L, 24L, 14L, 2L, 13L, 18L, 22L, 14L, 6L, 1L, 19L,
19L, 8L, 6L, 23L, 12L, 6L, 8L, 7L, 11L, 17L, 4L)
y <- as.FLSR(stk,model='ricker')
rec(y) <- rec(y)[, i]
ssb(y) <- ssb(y)[, i]
sr <- srrTMB(y, spr0 = mean(spr0y(stk)))
brps <- computeFbrps(stock = stk, sr = sr, proxy = 'sprx', f0.1 = TRUE)
brps@refpts
# fmax and spr.30 are higher than fcrash and give negative yield and recr
I think the steepness of the SR is so low that the entire SR curve is below the replacement line:
# following https://www.fao.org/3/v8400e/V8400E02.htm - plot replacement line (fig 6)
fi <- an(fbar(brps))
## SPR vector corresponding to these F's
spri <- an(spr(brps))
## reference points
rpi <- refpts(brps)
par(mfrow = c(1, 2))
## SPR
plot(fi, spri, type = "l", bty = "l", xlab = "Fbar", ylab = "SPR", ylim = c(0, max(spri)))
## SR
pars <- params(brps)
curve(pars["a"] * x * (exp(-pars["b"] * x)),
from = 0, to = 1e5, bty = "l",
xlab = "SSB", ylab = "Recruitment", xaxs = "i", yaxs = "i",
main = "No point of intersection with replacement line")
abline(c(0, 1/spri[idx]), col = "blue")
Should we move it to https://github.com/flr and set it to be available at https://flr.r-universe.dev/packages?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.