gadget_likelihood_component.Rd
Structures representing a component of a GADGET likelihood file.
gadget_likelihood_component(type, weight = 0, name = type,
likelihoodfile = 'likelihood', ...)
Type of group to create. One of penalty, understocking, catchstatistics, catchdistribution, stockdistribution.
A descriptive name for the component
A numeric weighting
The likelihood file this component should end up in
Extra parameters for the group. See details.
In addition, penalty
understands:
A data.frame
with 2 columns, "switch" and "power"
catchstatistics
understands:
The function Gadget should use, by default guesses based on the function that generated data
A data.frame
probably generated by mfdb_sample_meanlength_stddev
An list
of areas, taken from attr(data, "area")
if not supplied
An list
of ages, taken from attr(data, "age")
if not supplied
List of fleet names
List of stock names
catchdistribution
understands:
The function Gadget should use, by default uses sumofsquares
Extra parameters to supply to gadget, based on the function
TRUE or FALSE, defaults to FALSE
TRUE or FALSE, defaults to FALSE
Numeric, defaults to 10
A data.frame
probably generated by mfdb_sample_meanlength_stddev
An list
of areas, taken from attr(data, "area")
if not supplied
An list
of ages, taken from attr(data, "age")
if not supplied
An list
of lengths, taken from attr(data, "length")
if not supplied
List of fleet names
List of stock names
stockdistribution
understands:
The function Gadget should use, by default uses sumofsquares
TRUE or FALSE, defaults to FALSE
Numeric, defaults to 10
A data.frame
probably generated by mfdb_sample_meanlength_stddev
An list
of areas, taken from attr(data, "area")
if not supplied
An list
of ages, taken from attr(data, "age")
if not supplied
An list
of lengths, taken from attr(data, "length")
if not supplied
List of fleet names
List of stock names
surveydistribution
understands:
A data.frame
probably generated by mfdb_sample_meanlength_stddev
An list
of areas, taken from attr(data, "area")
if not supplied
An list
of lengths, taken from attr(data, "length")
if not supplied
An list
of ages, taken from attr(data, "age")
if not supplied
List of stock names
Fit options, see GADGET manual
A vector of length 2
A single suitability function
Numeric, defaults to 10
String, see GADGET manual
surveyindices
understands:
What data the component is based on, see GADGET manual
0 or 1, defaults to 0
A data.frame
probably generated by mfdb_sample_meanlength_stddev
An list
of areas, taken from attr(data, "area")
if not supplied
An list
of ages, taken from attr(data, "age")
if not supplied
An list
of lengths, taken from attr(data, "length")
if not supplied
List of fleet names
List of stock names
List of acoustic survey names
Fit options, see GADGET manual
stomachcontent
understands:
Function GADGET will use
To be used when calculated probability is low
Either a vector of stock names to be used for all preys, or a list to match preys, see below
Optional. Either a vector of coefficients fo be used for all preys, or a list to match preys, see below
Vector of predator stock names
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:
Stock name
2 power coefficients
A gadget_likelihood_component object that can then be written to a likelihood
file with gadget_dir_write
# 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.3.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)