Structures representing a component of a GADGET likelihood file.

gadget_likelihood_component(type, weight = 0, name = type,
    likelihoodfile = 'likelihood', ...)

Arguments

type

Type of group to create. One of penalty, understocking, catchstatistics, catchdistribution, stockdistribution.

name

A descriptive name for the component

weight

A numeric weighting

likelihoodfile

The likelihood file this component should end up in

...

Extra parameters for the group. See details.

Details

In addition, penalty understands:

data

A data.frame with 2 columns, "switch" and "power"

catchstatistics understands:

data_function

The function Gadget should use, by default guesses based on the function that generated data

data

A data.frame probably generated by mfdb_sample_meanlength_stddev

area

An list of areas, taken from attr(data, "area") if not supplied

age

An list of ages, taken from attr(data, "age") if not supplied

fleetnames

List of fleet names

stocknames

List of stock names

catchdistribution understands:

data_function

The function Gadget should use, by default uses sumofsquares

data_function_params

Extra parameters to supply to gadget, based on the function

aggregationlevel

TRUE or FALSE, defaults to FALSE

overconsumption

TRUE or FALSE, defaults to FALSE

epsilon

Numeric, defaults to 10

data

A data.frame probably generated by mfdb_sample_meanlength_stddev

area

An list of areas, taken from attr(data, "area") if not supplied

age

An list of ages, taken from attr(data, "age") if not supplied

length

An list of lengths, taken from attr(data, "length") if not supplied

fleetnames

List of fleet names

stocknames

List of stock names

stockdistribution understands:

data_function

The function Gadget should use, by default uses sumofsquares

overconsumption

TRUE or FALSE, defaults to FALSE

epsilon

Numeric, defaults to 10

data

A data.frame probably generated by mfdb_sample_meanlength_stddev

area

An list of areas, taken from attr(data, "area") if not supplied

age

An list of ages, taken from attr(data, "age") if not supplied

length

An list of lengths, taken from attr(data, "length") if not supplied

fleetnames

List of fleet names

stocknames

List of stock names

surveydistribution understands:

data

A data.frame probably generated by mfdb_sample_meanlength_stddev

area

An list of areas, taken from attr(data, "area") if not supplied

length

An list of lengths, taken from attr(data, "length") if not supplied

age

An list of ages, taken from attr(data, "age") if not supplied

stocknames

List of stock names

fittype, slope, intercept

Fit options, see GADGET manual

parameters

A vector of length 2

suitability

A single suitability function

epsilon

Numeric, defaults to 10

likelihoodtype

String, see GADGET manual

surveyindices understands:

sitype

What data the component is based on, see GADGET manual

biomass

0 or 1, defaults to 0

data

A data.frame probably generated by mfdb_sample_meanlength_stddev

area

An list of areas, taken from attr(data, "area") if not supplied

age

An list of ages, taken from attr(data, "age") if not supplied

length

An list of lengths, taken from attr(data, "length") if not supplied

fleetnames

List of fleet names

stocknames

List of stock names

surveynames

List of acoustic survey names

fittype, slope, intercept

Fit options, see GADGET manual

stomachcontent understands:

data_function

Function GADGET will use

epsilon

To be used when calculated probability is low

prey_labels

Either a vector of stock names to be used for all preys, or a list to match preys, see below

prey_digestion_coefficients

Optional. Either a vector of coefficients fo be used for all preys, or a list to match preys, see below

predator_names

Vector of predator stock names

data

A data.frame probably generated by mfdb_sample_meanlength_stddev

Both prey_labels and prey_digestion_coefficients allow you to match parts of prey labels and use repetition. For instance, list("cod.mat" = "mature_cod", "cod" = "cod", "other") will give "cod.mat" the label "mature_cod", "cod.imm" the label "cod", and anything else will get "other". You can also use regular expression syntax, for example "cod[0-9]".

migrationpenalty understands:

stockname

Stock name

powercoeffs

2 power coefficients

Value

A gadget_likelihood_component object that can then be written to a likelihood file with gadget_dir_write

Examples

# Create a penalty component
component <- gadget_likelihood_component("penalty",
        name = "bounds",
        weight = "0.5",
        data = data.frame(
            switch = c("default"),
            power = c(2),
            stringsAsFactors = FALSE))
component
#> $name
#> [1] "bounds"
#> 
#> $weight
#> [1] "0.5"
#> 
#> $type
#> [1] "penalty"
#> 
#> $datafile
#> ; Generated by mfdb 7.2.99
#> ; -- data --
#> ; switch	power
#> default	2
#> 
#> attr(,"likelihoodfile")
#> [1] "likelihood"
#> attr(,"class")
#> [1] "gadget_penalty_component"    "gadget_likelihood_component"

# Create an understocking component
component <- gadget_likelihood_component("understocking", name ="understock")
component
#> $name
#> [1] "understock"
#> 
#> $weight
#> [1] 0
#> 
#> $type
#> [1] "understocking"
#> 
#> attr(,"likelihoodfile")
#> [1] "likelihood"
#> attr(,"class")
#> [1] "gadget_understocking_component" "gadget_likelihood_component"   

# Any example could be added to a file with the following:-
gd <- gadget_directory(tempfile())
gadget_dir_write(gd, component)