FLSR-class: Class FLSR

Description Slots Extends Constructor Constructor details Methods Author(s) See Also Examples

Description

Class for stock-recruitment models, based on FLModel. Two extra FLQuant slots are used for input data: rec for the recruitment series, and ssb for Spawning Stock Biomass or any other index of reproductive potential.

All the main methods for this class are inherited from FLModel, although the plot method is specific to FLSR, and methods exist to access the specific FLQuant slots, rec and ssb.

A series of commonly-used stock-recruitment models are already available, including the correspodning 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. FLQuant.

fitted

Estimated values for rec. FLQuant.

residuals

Residuals obtained from the model fit. FLQuant.

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.

Extends

FLModel FLComp

Constructor

The FLSR(object) constructor method allows simple creation of new FLSR with the methods described below.

signature(model=missing) :

Creates an empty FLSR object.

signature(model=character) :

Creates an FLSR from an already existing stock-recruitment model function named model. This function must contain at least a formula for the model and additionaly it can contain a likelihood function for the model and a function to calculate initial parameters. See SRModels for details in avaiblable stock-recruitment functions.

signature(model=function) :

Creates an FLSR object using information given in the function. This function can be an empty function in which case an empty FLSR will be returned or a function that returns a named list with a formula for model and additionaly functions for logl and initial slots.

signature(model=formula) :

Creates an FLSR object with the given formula in model slot.

Constructor details

Any of the slots of the FLSR class can be used as argument in (...), in which case the corresponding slot is filled with the given argument.

If no 'FLQuant' slots are supplied in the call to the constructor 'FLSR()', an 'FLSR' object with dimension '(1,1,1,1,1,1)' in the 'FLQuant' slots is returned. Otherwise if one of the arguments in (...) is an 'FLQuant', an 'FLSR' object which slots have the same dimension as the 'FLQuant' argument is returned. If two ore more 'FLQuant' slots are supplied in the call to the function, they must have the same dimension.

Methods

All methods are inherited from FLModel, except for

plot(graphics) :

Plot an FLSR object

signature(x=FLSR,y=missing)

Author(s)

The FLR Team

See Also

FLModel, FLComp

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
    # 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)

FLCore documentation built on May 2, 2019, 5:46 p.m.