PrepareRecaEstimate: Prepare data for Reca.

View source: R/StoxAnalysisFunctions.R

PrepareRecaEstimateR Documentation

Prepare data for Reca.

Description

Performs data checks and data conversions, and stores some data-related parameters in preparation for running ParameterizeRecaModels.

Usage

PrepareRecaEstimate(
  StoxBioticData,
  StoxLandingData,
  FixedEffects = character(),
  RandomEffects = character(),
  UseCarEffect = FALSE,
  CarEffect = character(),
  CarNeighbours,
  UseAgingError = FALSE,
  AgeErrorMatrix,
  UseStockSplitting = FALSE,
  UseStockSplittingError = FALSE,
  StockSplittingParameters,
  CellEffect = c("Off", "All"),
  MinAge = integer(),
  MaxAge = integer(),
  MaxLength = numeric(),
  LengthResolution = numeric(),
  HatchDay = integer()
)

Arguments

StoxBioticData

StoxBioticData data with samples from fisheries and approriate columns appended for specifying cells. See details.

StoxLandingData

StoxLandingData data with landings from fisheries and approriate columns appended for specifying cells. See details.

FixedEffects

optional, vector identifying column names that should be treated as fixed effects. See details

RandomEffects

optional, vector identifying column names that should be treated as random effects. See details

UseCarEffect

if TRUE, CAR-effect (conditional autoregressive effect) will be used.

CarEffect

optional, character identifying the column name that should be treated as CAR-effect. Mandatory if 'UseCarEffect' is TRUE.

CarNeighbours

CarNeighbours, mandatory if 'carEffect' is given. Identifies which values of the carEffect are to be considered as neighbours.

UseAgingError

If TRUE, aging, error parameters will be incorporated in the models.

AgeErrorMatrix

AgeErrorMatrix, optional, specifies the probabilities of misreading ages. mandatory if UseAgingError is TRUE.

UseStockSplitting

If TRUE, models will be condigured to provide estimates for each of two stocks based on otholitt-typing. See StockSplittingParameters.

UseStockSplittingError

If TRUE, the model for error in stock classification (otolithtypes) will be applied.

StockSplittingParameters

Parameters for stock splitting. Mandatory if 'UseStockSplitting' is TRUE. May be obtained with DefineStockSplittingParameters.

CellEffect

Configures the cell effect. Defaults to Off. If 'All', an interaction term will be added with all covariates that in the cell (whether they are fixed or random effects). Any CAR-effect is always included in the cell effect.

MinAge

optional, must match dimensions of any 'AgeErrorMatrix'. If not provided it will be derived from data.

MaxAge

optional, must match dimensions of any 'AgeErrorMatrix'. If not provided it will be derived from data.

MaxLength

optional, maximal fish length in data in cm. If not provided it will be derived from data.

LengthResolution

optional, resolution for length measurements in cm. If not provided modal value from data is used.

HatchDay

defaults to Defaults to 1. encoding the day of the year when fish is consider to transition from one age to the next. 1 represents Jan 1st.

Details

Parameters are obtained for 'cells' using ParameterizeRecaModels and and applied to landings-data when predicting total catch-at-age using RunRecaModels.

Cells

Reca conceptually decomposes a fishery into cells. Parameters are estimated for each cell, and later total catch at age is predicted for each cell. Cells must therefore be defined for both the census of landings, and for the samples.

'Cells' are defined by all effects / covariates that are specified for both 'StoxLandingData' and 'StoxBioticData' (all effects are specified by one of the arguments: 'FixedEffects', 'RandomEffects', and 'CarEffect'). Any variable that are to be included in the cell definition must always be observed (not containing NAs) and be coded coherently (the same coding system) in both 'StoxBioticData' and 'StoxLandingData'.

Covariates

Only effects that are part of the cell definition may be specified as 'Fixed effect' or 'CAR effect'. For fixed effect all values / levels of the effect must be sampled. For CAR effect, the cell or neighbouring cells (as defined by 'CarNeighbours') must be sampled

Any variable in samples 'StoxBioticData' may be included as a random effect as long as it is always observed (not containing NAs).

A random effect identifying haul / landing is always included in Reca. Do not add haul-identifiers as covariates.

Stock splitting

The option UseStockSplitting requires that a Variable 'otolithtype' is added to the table 'Individual' in StoxBioticData. This is developed for splitting coastal cod from atlantic cod, and that is reflected in the Reca documentation, but this is abstracted in StoX, so that other stocks may be encoded to fit the analysis. For some cases it may even be extended to other domains defined for individual fish.

Value

RecaData Data prepared for running Reca.

See Also

ReportFdaSampling for inspecting the data availability for potential cell definitions. ParameterizeRecaModels, and RunRecaModels for parameterising and running the Reca-analysis. DefineStratumPolygon, AddStratumStoxBiotic, and AddStratumStoxLanding for making 'Stratum' part of the cell definition, and #' DefineCarNeighbours, for maing 'Stratum' available as a CAR-effect DefinePeriod, AddPeriodStoxBiotic, and AddPeriodStoxLanding for making 'Period' part of the cell definition. #' DefineTranslation, AddGearGroupStoxBiotic, and AddGearGroupStoxLanding for making 'GearGroup' part of the cell definition. DefineAgeErrorMatrix for making an age-error matrix available for the Reca-analysis. DefineStockSplittingParameters for configuring stock-splitting parameters, and AddToStoxBiotic for adding otolith-type to samples for stock-splitting analysis.


StoXProject/RstoxFDA documentation built on Dec. 17, 2024, 10:58 a.m.