FLSR {FLCore} | R Documentation

## Method FLSR

### Description

Creates a new FLSR object.

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

### Generic function

FLSR(model,...)

### Methods

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.

### Author(s)

The FLR Team

### See Also

FLComp, FLModel, FLSR-class

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

[Package FLCore version 2.2 Index]