FLSR | R Documentation |
Class for stock-recruitment models.
FLSR(model, ...)
## S4 method for signature 'ANY'
FLSR(model, ...)
## S4 method for signature 'missing'
FLSR(model, ...)
A series of commonly-used stock-recruitment models are already available,
including the corresponding likelihood functions and calculation of initial
values. See SRModels
for more details and the exact
formulation implemented for each of them.
Name of the object (character
).
Description of the object (character
).
Range (numeric
).
Recruitment series (FLQuant
).
Index of reproductive potential, e.g. SSB or egg oor egg production (FLQuant
).
Estimated values for rec (FLQuant
).
Residuals obtained from the model fit (FLArray
).
Covariates for SR model (FLQuants
).
Model formula (formula
).
Function returning the gradient of the likelihood (function
).
Log-likelihood function (function
).
Function returning initial parameter values for the optimizer (function
).
Estimated parameter values (FLPar
).
Value of the log-likelihood (logLik
).
Variance-covariance matrix (array
).
Extra information on the model fit procedure (list
).
Is the error on a log scale (logical
).
(factor
).
Resulting Hessian matrix from the fit (array
).
The FLR Team
FLModel, FLComp
# Create an empty FLSR object.
sr1 <- FLSR()
# Create an FLSR object using the existing SR models.
sr2 <- FLSR(model = 'ricker')
sr2@model
sr2@initial
sr2@logl
sr3 <- FLSR(model = 'bevholt')
sr3@model
sr3@initial
sr3@logl
# Create an FLSR using a function.
mysr1 <- function(){
model <- rec ~ a*ssb^b
return(list(model = model))}
sr4 <- FLSR(model = mysr1)
# Create an FLSR using a function and check that it works.
mysr2 <- function(){
formula <- rec ~ a+ssb*b
logl <- function(a, b, sigma, rec, ssb) sum(dnorm(rec,
a + ssb*b, sqrt(sigma), TRUE))
initial <- structure(function(rec, ssb) {
a <- mean(rec)
b <- 1
sigma <- sqrt(var(rec))
return(list(a=a, b=b, sigma=sigma))},
lower = c(0, 1e-04, 1e-04), upper = rep(Inf, 3))
return(list(model = formula, initial = initial, logl = logl))
}
ssb <- FLQuant(runif(10, 10000, 100000))
rec <- 10000 + 2*ssb + rnorm(10,0,1)
sr5 <- FLSR(model = mysr2, ssb = ssb, rec = rec)
sr5.mle <- fmle(sr5)
sr5.nls <- nls(sr5)
# NS Herring stock-recruitment dataset
data(nsher)
# already fitted with a Ricker SR model
summary(nsher)
plot(nsher)
# change model
model(nsher) <- bevholt()
# fit through MLE
nsher <- fmle(nsher)
plot(nsher)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.