Skip to contents

Sets global conditions and makes a preliminary data summary.

Usage

bycatchSetup(
  modelTry = c("Delta-Lognormal", "Delta-Gamma", "TMBnbinom1", "TMBnbinom2",
    "TMBtweedie"),
  obsdat,
  logdat,
  yearVar,
  obsEffort,
  logEffort,
  logUnsampledEffort = NULL,
  includeObsCatch = FALSE,
  matchColumn = NA,
  factorNames,
  randomEffects = NULL,
  randomEffects2 = NULL,
  EstimateIndex,
  EstimateBycatch,
  logNum,
  sampleUnit,
  complexModel,
  simpleModel,
  indexModel,
  designMethods = "None",
  designVars = "Year",
  designPooling = FALSE,
  poolTypes = NULL,
  pooledVar = NULL,
  adjacentNum = NULL,
  minStrataUnit = 1,
  baseDir = getwd(),
  runName,
  runDescription,
  common,
  sp,
  obsCatch,
  catchUnit,
  catchType
)

Arguments

modelTry

Specify which observation error models to try. Options are: "Binomial", "Normal","Lognormal", "Delta-Lognormal", and "Delta-Gamma", for models using the lm and glm functions, "NegBin" for Negative binomial using glm.nb in the MASS library, "Tweedie" for Tweedie GLM from the cpglm function in the cplm library, and "TMBbinomial","TMBnormal", "TMBlognormal", "TMBdelta-Lognormal","TMBdelta-Gamma", "TMBnbinom1", "TMBnbinom2", and "TMBtweedie" for the corresponding models from the glmmTMB library. Binomial or TMBbinomial will be run automatically as part of the delta models if any of them are selected. @param obsdat Observer data set

obsdat

Observer data set

logdat

Logbook data set

yearVar

Character. The name of the year variable in obsdat and logdat. Both input files must contain the same variable name for year.

obsEffort

Character. The name of the effort variable in obsdat. This variable must have the same effort units as logEffort

logEffort

Character. The name of the effort variable in logdat. Optional and only used when estimating bycatch. This variable must have the same effort units as obsEffort

logUnsampledEffort

Character. The name of the unsampled effort variable in in logdat. Optional and used to specify a column for effort that is not sampled, in trips with observers. This can be zero in all cases if observers sample 100% of effort in sampled trips. Only used when includeObsCatch is TRUE

includeObsCatch

Logical. Set to TRUE if (1) the observed sample units can be matched to the logbook sample units and (2) you want to calculate total bycatch as the observed bycatch plus the predicted unobserved bycatch. This doesn't work with aggregated logbook effort.

matchColumn

Character. If includeObsCatch is TRUE, give the name of the column that matches sample units between the observer and logbook data. Otherwise, this can be NA

factorNames

Character vector. Specify which variables should be interpreted as categorical, ensuring imposes factor format on these variables. Variables not in this list will retain their original format. These variables must have identical names and factor levels in obsdat and logdat

randomEffects

Character vector. Random effects that should be included in all non-delta and binomial models, as a character vector in (e.g. "Year:area" to include Year:area as a random effect). Null if none. Note that random effects will be included in all models. The code will not evaluate whether they should be included.

randomEffects2

Character vector. Random effects that should be included in the positive catch component of delta models, as a character vector in (e.g. "Year:area" to include Year:area as a random effect). Null if none. Note that random effects will be included in all models. The code will not evaluate whether they should be included.

EstimateIndex

Logical. What would you like to estimate? You may calculate either an annual abundance index, or total bycatch, or both.

EstimateBycatch

Logical. What would you like to estimate? You may calculate either an annual abundance index, or total bycatch, or both. If you want total bycatch, you must provide logbook data or some other source of total effort to logdat.

logNum

Character vector. The name of the column in logdat that gives the number of sample units (e.g., trips or sets). If the logbook data is not aggregated (i.e. each row is a sample unit) set value to NA

sampleUnit

Character. What is the sample unit in logdat? e.g. sets or trips.

complexModel

Specify as stats::formula. Specify the most complex and simplest model to be considered. The code will find compare all intermediate models using information criteria. Include only fixed effects.

simpleModel

Specify as stats::formula. This model includes all variables tha must be in the final bycatch estimation model

indexModel

Specify as stats::formula. Use indexModel to specify which strata to keep separate in calculating abundance indices.

designMethods

Character vector of methods to use for design based estimation. Current options are Ratio and Delta (for a delta-lognormal estimator).

designVars

Specify strata that must be included in design based estimates, in order across which data should be pooled

designPooling

TRUE if design-based estimates should be pooled for strata with missing data

poolTypes

Type of pooling for each variable in designVars, as a character vector in the same order. Options are "all", "pooledVar" and (currently for year only) "adjacent"

pooledVar

Variables to pool over for any variable with pooledVar in the previous line, as a character vector in the same order as designVars. Use NA for variables with other pooling methods. This can be used to pool (for example) months into seasons when pooling is needed.

adjacentNum

Number of adjacent years to include for adjacent pooling, as a numberical vector in the same order as designVars. NA for anything other than year.

minStrataUnit

The smallest sample size in the strata defined by designVars that is acceptable, in sample units (e.g. trips)

baseDir

Character. A directory to save output. Defaults to current working directory.

runName

Characer. Give a name to the run, which will be used to set up a directory for the outputs

runDescription

Character. Brief summary of the run, which will be used to set up a directory for the outputs

common

Character vector. Provide a common name for the species used in bycatch and index estimation. Can be a vector of names to do multiple species at the same time.

sp

Character vector. Provide a scientific name for the species used in bycatch and index estimation. Can be a vector of names to do multiple species at the same time

obsCatch

Character vector. The name of the column(s) in obsdat that contain catch. If it is a vector, order of variable names must follow the same order as names provided in common and sp

catchUnit

Character vector. Give units of catch (e.g., number) to go in plot labels. Must be a vector of the same length as sp

catchType

Character vector. Give type of catch (e.g., dead discards) to go in plot labels. Must be a vector of the same length as sp

Examples

if (FALSE) {
library(BycatchEstimator)
setupObj<-bycatchSetup(
modelTry = c("Delta-Lognormal","Delta-Gamma","TMBnbinom1","TMBnbinom2","TMBtweedie"),
obsdat = obsdatExample,
logdat = logdatExample,
yearVar = "Year",
obsEffort = "sampled.sets",
logEffort = "sets",
logUnsampledEffort = NULL,
includeObsCatch  = FALSE,
matchColumn = NA,
factorNames = c("Year","season"),
randomEffects = NULL,
randomEffects2 = NULL,
EstimateIndex = TRUE,
EstimateBycatch = TRUE,
logNum = NA,
sampleUnit = "trips",
complexModel = formula(y~(Year+season)^2),
simpleModel = formula(y~Year),
indexModel = formula(y~Year),
designMethods = c("Ratio", "Delta"),
designVars = c("Year","season"),
designPooling = TRUE,
poolTypes=c("adjacent","all","all"),
pooledVar=c(NA,NA,NA),
adjacentNum=c(1,NA,NA),
minStrataUnit = 1,
baseDir = getwd(),
runName = "SimulatedExample",
runDescription = "Example with simulated data",
common = "Simulated species",
sp = "Genus species",
obsCatch = "Catch",
catchUnit = "number",
catchType = "dead discard"
)}