
Define alternative fishing choice
Source:R/create_alternative_choice.R
create_alternative_choice.RdRequired step. Creates a list identifying how alternative fishing choices should
be defined. Output is saved to the FishSET database. Run this function before
running models. dat must have a zone assignment column (see
assignment_column()). In certain cases a centroid table must be saved to
the FishSET Database, see occasion_var for details.
Usage
create_alternative_choice(
dat,
project,
alt_name = NULL,
zoneID,
occasion = "zonal centroid",
occasion_var = NULL,
alt_var = "zonal centroid",
min_haul = 0,
spatname = NULL,
spatID = NULL,
outsample = FALSE
)Arguments
- dat
Required, Primary data frame containing data on hauls or trips. Table in FishSET database should contain the string
MainDataTable.- project
Required, name of project.
- alt_name
String, Required. The name to be assigned to this alternative choice list within the FishSET database. If a list with this name already exists, the function will stop.
- zoneID
Variable in
datthat identifies the individual zones or areas.- occasion
String, determines the starting point when calculating the distance matrix. Options are
"zonal centroid","fishing centroid","port", or"lon-lat". Seeoccasion_varfor requirements.- occasion_var
Identifies an ID column or set of lon-lat variables needed to create the distance matrix. Possible options depend on the value of
occasion:- Centroid
When
occasion = zonal centroidthe possible options areNULL, the name of a zone ID variable, or a set coordinate variables (in Lon-Lat order).- NULL
This will merge centroid lon-lat data to the primary table using the column enter in
zoneID. A centroid table must be saved to the FishSET Database.- Zone ID
This option specifies the zone ID variable to merge the centroid table to. For example, a column containing the previous zonal area. A centroid table must be saved to the FishSET Database.
- Lon-Lat
A string vector of length two containing the longitude and latitude of an existing set centroid variables in
dat.
- Port
When
occasion = portthe possible options include the name of a port ID variable or a set of lon-lat variables describing the location of the port. A value ofNULLwill return an error.- Port ID
The name of a port ID variable in
datthat will be used to join the port table to the primary table. A port table is required (seeload_port()) which contains the port name and the longitude and latitude of each port.- Lon-Lat
A string vector of length two containing a port's longitude and latitude in
dat.
- Lon-Lat
When
occasion = lon-lat,occasion_varmust contain a string vector of length two containing the longitude and latitude of a vessel's location in thedat. For example, the current or previous haul location.
- alt_var
Determines the alternative choices used to calculate the distance matrix.
alt_varmay be the centroid of zonal assignment ("zonal centroid"),"fishing centroid", or the closest point in fishing zone ("nearest point"). The centroid options require that the appropriate centroid table has been saved to the project's FishSET Database. Seecreate_centroid()to create and save centroids. List existing centroid tables by runninglist_tables("project", type = "centroid").- min_haul
Required, numeric, minimum number of hauls. Zones with fewer hauls than the
min_haulvalue will not be included in model data.- spatname
Required when
alt_var = 'nearest point'.spatis a spatial data file containing information on fishery management or regulatory zones boundaries.sfobjects are recommended, butspobjects can be used as well. Seedat_to_sf()to convert a spatial table read from a csv file to ansfobject. To upload your spatial data to the FishSETFolder seeload_spatial().Ifspatshould come from the FishSET database, it should be the name of the original file name, in quotes. For example,"pollockNMFSZonesSpatTable". Usetables_database()orlist_tables("project", type = "spat")to view the names of spatial tables in the FishSET database.- spatID
Required when
alt_var = 'nearest point'. Variable inspatthat identifies the individual zones or areas.- outsample
Logical, indicating whether this is for primary data or out-of sample data.
Value
Function saves a list of alternative choice matrices to the FishSET
database as projectAlternativeChoice. The list includes
the alternative choice list from the user-defined choices. Multiple alternative
choice cases can be added to the list by specifying unique names. The list is
automatically saved to the FishSET database and is called in
format_model_data.
Details
Defines the alternative fishing choices. These choices are used to develop
the matrix of distances between observed and alternative fishing choices (where
they could have fished but did not). The distance matrix is calculated by the
format_model_data() function. occasion defines the observed fishing
location and alt_var the alternative fishing location. occasion_var
identifies an ID column or set of lon-lat variables needed to create the
distance matrix.
Parts of the alternative choice list are pulled by create_expectations(),
format_model_data(), and the model run fishset_fit())
functions. These output include choices of which variable to use for catch and
which zones to include in analyses based on a minimum number of hauls per trip
within a zone. Note that if the alternative choice list is modified, the
create_expectations() and format_model_data() functions
should also be updated before rerunning models.