SurveyLFs.fn: Expands the lengths up to the total stratum area then sums...

View source: R/SurveyLFs.fn.R

SurveyLFs.fnR Documentation

Expands the lengths up to the total stratum area then sums over strata

Description

Expands the lengths up to the total stratum area then sums over strata

Usage

SurveyLFs.fn(
  dir = NULL,
  datL,
  datTows,
  strat.vars = c("Depth_m", "Latitude_dd"),
  strat.df = NULL,
  lgthBins = 1,
  SSout = TRUE,
  meanRatioMethod = TRUE,
  sex = 3,
  NAs2zero = T,
  sexRatioUnsexed = NA,
  maxSizeUnsexed = NA,
  sexRatioStage = 1,
  partition = 0,
  fleet = "Enter Fleet",
  agelow = "Enter",
  agehigh = "Enter",
  ageErr = "Enter",
  nSamps = "Enter Samps",
  month = "Enter Month",
  printfolder = "forSS",
  remove999 = TRUE,
  outputStage1 = FALSE,
  sum100 = TRUE,
  verbose = TRUE
)

Arguments

dir

A file path to an existing directory where you would like to create a folder to store the output from this function. The default is dir = NULL, which causes the function to not save any files. You can store the output directly in dir if you specify printfolder = "".

datL

A data frame of length-composition data returned from PullBio.fn().

datTows

A data frame of catch data returned from PullCatch.fn().

strat.vars

Variables in both datL and datTows that are used to define the stratas. Default is bottom depth (m) and latitudes (decimal degrees), i.e., c("Depth_m", "Latitude_dd").

strat.df

A data frame that defines the strata and provides the calculated areas for each strata returned from createStrataDF.fn().

lgthBins

An integer vector of length bins.

SSout

A logical with the default of TRUE. If TRUE, the output is returned in a format that can be directly pasted into an SS3 data file.

meanRatioMethod

A logical with the default of TRUE. If TRUE, then the mean ratio is implemented instead of the total ratio. Search the source code for the equations if more information is needed.

sex

(0, 1, 2, 3). The integer will be used to define the sex column of the returned input for Stock Synthesis and specifies how the composition are treated with respect to sex. See the Stock Synthesis manual for more information. In short, 0 is for unsexed, 1 is females, 2 is males, and 3 is males and females where the sex ratio of the samples is informative to the model. The default is 3.

NAs2zero

A logical specifying if NAs should be changed to zeros. The default is TRUE.

sexRatioUnsexed

A numerical value within ⁠[0.0, 1.0]⁠ that will be used as the sex ratio for measured individuals less than maxSizeUnsexed. If NA_real_, then the sex ratio for stage-1 expansion will not be conducted.

maxSizeUnsexed

A numerical value specifying the right side of the following bin ⁠[0, maxSizeUnsexed]⁠, where all fish measured in this bin are assigned a sex based on sexRatioUnsexed. Fish with a measurement larger than this value will be assigned a sex based on the calculated sex ratio in the data.

sexRatioStage

(1, 2). The stage of the expansion to apply the sex ratio. The default is 1.

partition, fleet, agelow, agehigh, ageErr, month

Each argument requires a single integer value that will be used to set the associated column of the returned input for Stock Synthesis. See the Stock Synthesis manual for more information.

nSamps

A named vector of input or effective sample sizes that will be used to set the effective sample size of the returned input for Stock Synthesis. A value must be supplied for every year of data in datL.

printfolder

A string that will be appended to dir, creating a folder where the length-composition output will be saved. If specified as "", the output will just be saved directly in dir. The default is "forSS".

remove999

A logical with the default of TRUE, which leads to the output having the 999 column combined with the first length bin.

outputStage1

A logical specifying if you would like the function to stop after the end of the first stage of the expansion process and return output that is not ready for Stock Synthesis. This can be helpful when wanting output that can be used as input for VAST.

sum100

A logical value specifying whether to rescale the compositions to sum to 100. The default is TRUE.

verbose

A logical that specifies if you want to print messages and warnings to the console. The default is TRUE.

Details

The original version was written by Allan Hicks 16 March 2009. This function has since been modified by Chantel Wetzel to work with the data warehouse data formatting, add additional options of when to apply the sex ratio, and correct some treatment of unsexed fish weighted by sample size and area.

Author(s)

Allan Hicks (16 March 2009) and Chantel Wetzel (maintainer)

See Also

  • StrataFactors.fn()

  • SexRatio.fn()


nwfsc-assess/nwfscSurvey documentation built on May 5, 2024, 5:21 a.m.