FLModel: Class FLModel

FLModelR Documentation

Class FLModel

Description

A virtual class for statistical models

Usage

FLModel(model, ...)

Details

The FLModel class provides a virtual class that developers of various statistical models can use to implement classes that allow those models to be tested, fitted and presented.

Slots in this class attempt to map all the usual outputs for a modelling exercise, together with the standard inputs. Input data are stored in slots created by a specified class based on FLModel. See for example FLSR for a class used for stock-recruitment models.

The initial slot contains a function used to obtain initial values for the numerical solver. It can also contain two attributes, upper and lower that limit the sarch area for each parameter.

Various fitting algorithms, similar to those present in the basic R packages, are currently available for FLModel, including fmle, nls-FLCore and glm.

Slots

name

Name of the object, character.

desc

Description of the object, character.

range

Range, numeric.

distribution

Associated error probability dfistribution, factor.

fitted

Estimated values, FLQuant.

residuals

Residuals obtained from the model fit, FLQuant.

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, as an object of class FLPar, function.

params

Estimated parameter values, FLPar.

logLik

Value of the log-likelihood, logLik.

vcov

Variance-covariance matrix, array.

hessian

Hessian matrix obtained from the parameter fitting, array.

details

extra information on the model fit procedure, list.

Author(s)

The FLR Team

See Also

AIC, BIC, fmle, nls, FLComp

Examples


# Normally, FLModel objects won't be created if "class" is not set
  summary(FLModel(length~width*alpha))

# Objects of FLModel-based classes use their own constructor,
# which internally calls FLModel
  fsr <- FLModel(rec~ssb*a, class='FLSR')
  is(fsr)
  summary(fsr)

# An example constructor method for an FLModel-based class
  # Create class FLGrowth with a single new slot, 'mass'
    setClass('FLGrowth', representation('FLModel', mass='FLArray'))

  # Define a creator method based on FLModel
		 setGeneric("FLGrowth", function(object, ...) standardGeneric("FLGrowth"))
    setMethod('FLGrowth', signature(object='ANY'),
      function(object, ...) return(FLModel(object, ..., class='FLGrowth')))
    setMethod('FLGrowth', signature(object='missing'),
      function(...) return(FLModel(formula(NULL), ..., class='FLGrowth')))

  # Define an accessor method
    setMethod('mass', signature(object='FLGrowth'),
      function(object) return(slot(object, 'mass')))


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