FLSR: Class FLSR

FLSRR Documentation

Class FLSR

Description

Class for stock-recruitment models.

Usage

FLSR(model, ...)

## S4 method for signature 'ANY'
FLSR(model, ...)

## S4 method for signature 'missing'
FLSR(model, ...)

Details

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.

Slots

name

Name of the object (character).

desc

Description of the object (character).

range

Range (numeric).

rec

Recruitment series (FLQuant).

ssb

Index of reproductive potential, e.g. SSB or egg oor egg production (FLQuant).

fitted

Estimated values for rec (FLQuant).

residuals

Residuals obtained from the model fit (FLArray).

covar

Covariates for SR model (FLQuants).

model

Model formula (formula).

gr

Function returning the gradient of the likelihood (function).

logl

Log-likelihood function (function).

initial

Function returning initial parameter values for the optimizer (function).

params

Estimated parameter values (FLPar).

logLik

Value of the log-likelihood (logLik).

vcov

Variance-covariance matrix (array).

details

Extra information on the model fit procedure (list).

logerror

Is the error on a log scale (logical).

distribution

(factor).

hessian

Resulting Hessian matrix from the fit (array).

Author(s)

The FLR Team

See Also

FLModel, FLComp

Examples


  # 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)


flr/FLCore documentation built on May 4, 2024, midnight