S4 class that organizes the various data inputs for the MSA model. MSAdata simply inherits the slots from 6 component classes:
Dmodel, Dstock, Dfishery, Dsurvey DCKMR, and Dtag, where the D- prefix denotes an object for data inputs (or model configuration).
DmodelClass Dmodel containing parameters for model structure (number of years, ages, etc.)
DstockClass Dstock containing stock parameters (growth, natural mortality, etc.)
DfisheryClass Dfishery containing fishery data (catch, size and stock composition, etc.)
DsurveyClass Dsurvey containing survey data (indices of abundance)
DCKMRClass DCKMR containing genetic close-kin data
DtagClass Dtag containing tagging data
DlabelClass Dlabel containing names for various dimensions. Used for plotting.
MiscList for miscellaneous inputs as needed
nyInteger, number of years
nmInteger, number of seasons
naInteger, number of ages. The first age class is zero and the last age class (plus group is age na - 1).
nlInteger, number of length bins. Set to zero if lengths are not modeled.
nrInteger, number of spatial regions
nsInteger, number of stocks
lbinVector of lower boundary of length bins. Length nl + 1
lmidVector of midpoint of length bins. Length nl
FmaxNumeric, maximum allowable instantaneous fishing mortality rate (units of per season). Defaults to 3.
y_phiInteger, the year from which to obtain values of natural mortality and fecundity for the unfished stock-recruit replacement line (phi). Relevant if natural mortality or fecundity are time-varying. Defaults to 1.
scale_sVector, length ns. Multiplicative scaling factor that informs relative stock size to aid parameter estimation. Larger values implies larger stocks. Default set to 1. See make_parameters().
nyinitInteger, number of years of spool-up to calculate equilibrium unfished and starting conditions for the population model to account for seasonal and spatial dynamics. The numerical spool-up is not needed when both nm = 1 and nr = 1, i.e., nyinit = 1. Otherwise, set to 2 * na by default.
conditionCharacter, either to specify the model estimates fishing mortality as a parameter ("F", default) or equal to the catch ("catch").
nitFInteger, number of iterations to solve Baranov catch equation from observed catch if condition = "catch". Defaults to 5.
y_Fmult_fInteger vector by fleet, the year in which to directly estimate F. Choose a year/season/region combination when the catch is average relative to the time series. Only used if condition = "F".
m_Fmult_fInteger vector by fleet, the season in which to directly estimate F. Choose a year/season/region combination when the catch is average relative to the time series. Only used if condition = "F".
r_Fmult_fInteger vector by fleet, the region in which to directly estimate F. Choose a year/season/region combination when the catch is average relative to the time series. Only used if condition = "F".
pbc_rdev_ysNumeric matrix, for the fraction of lognormal bias correction (-0.5 * sd_r^2) applied to the recruitment estimates in the model. Typically between 0-1, with default of 1.
pbc_initrdev_asNumeric matrix, for the fraction of lognormal bias correction (-0.5 * sd_r^2) applied to the initial abundance vector in the model. Typically between 0-1, with default of 1.
priorCharacter vector to be evaluated in the model to return the log prior for a parameter. See example in documentation for prior.
nyretInteger, number of recent years of data to remove from the likelihood for retrospective analysis (positive numbers). Default is zero.
m_spawnInteger, season of spawning. Defaults to 1. The progeny will enter the age structure in the same season.
m_advanceageInteger, season in which to advance age classes (corresponding to calendar year) to the next age class. Defaults to 1.
len_ymasLength-at-age. Only needed if Dmodel@nl > 0 to fit length composition (you may want to calculate the growth at the middle of the time step). calc_growth() may be a helpful function.
sdlen_ymasStandard deviation in length-at-age
LAK_ymalsLength-at-age probability array. If empty, values will be calculated by check_data() with calc_LAK().
mat_yasProportion mature by age class. Ignored if maturity ogive is estimated, e.g., when fitting to close-kin genetic data.
swt_ymasStock weight-at-age (at beginning of time step). See calc_growth() example.
fec_yasFecundity, i.e., spawning output, of mature animals. Default uses stock weight at age.
M_yasNatural mortality. Instantaneous units per year. Ignored if M is estimated.
SRR_sCharacter vector of stock-recruit relationship by stock. See SRR argument in calc_recruitment() for options.
delta_sFraction of season that elapses when spawning occurs, e.g., midseason spawning occurs when delta_s = 0.5. Default is zero.
presence_rsLogical matrix indicating presence/absence of stock s in region r. Used to constrain movement matrix.
Default is TRUE for all stocks and regions.
natal_rsThe fraction of the mature stock s in region r that spawns at
time of spawning. See example. Default is 1 for all stocks and regions.
nfInteger, number of fleets
Cobs_ymfrTotal fishery catch
Csd_ymfrLognormal standard deviation of the fishery catch. Only used if Dmodel@condition = "F". Default of 0.01.
fwt_ymafsFishery weight at age. Set to 1 when fleet catch is in units of abundance. Set to stock weight at age by default (values at beginning of time step).
CAAobs_ymafrFishery catch at age composition
CALobs_ymlfrFishery catch at length composition
fcomp_likeCharacter, likelihood for the fishery composition data. See type argument of like_comp() for options
CAAN_ymfrSample size of the catch at age vector by season if using the multinomial or Dirichlet-multinomial likelihoods
CALN_ymfrSample size of the catch at length vector by season if using the multinomial or Dirichlet-multinomial likelihoods
CAAtheta_fCatch at age dispersion parameter if using the Dirichlet-multinomial likelihood. Default set to 1.
CALtheta_fCatch at length dispersion parameter if using the Dirichlet-multinomial likelihood. Default set to 1.
sel_block_yfIndex of dummy fleets to model time blocks of selectivity
sel_fCharacter vector of the functional form for selectivity. Choose between: "logistic_length", "dome_length", "logistic_age", "dome_age", "SB", "B"
Cinit_mfrEquilibrium seasonal catch prior to the first year. One way to initialize the abundance at the start of the first year in the model. Default of zero.
SC_ymafrsStock composition data.
SC_aaBoolean matrix that aggregates age classes for the stock composition data. See example.
SC_ffBoolean matrix that aggregates fleets for the stock composition data. See example.
SC_likeCharacter, likelihood for the stock composition data. See type argument of like_comp() for options
SCN_ymafrSample size of the stock composition vector if using the multinomial or Dirichlet-multinomial likelihoods
SCtheta_fStock composition dispersion parameter if using the Dirichlet-multinomial likelihood. Default set to 1.
SCstdev_ymafrsStock composition standard deviation if using the lognormal likelihood. Default set to 0.1.
niInteger, number of indices of abundance. Zero is possible.
Iobs_ymiObserved indices
Isd_ymiLognormal standard deviation of the observed indices
unit_iCharacter vector, units of the index. Set to "B" to use stock weight at age (default) or "N" for abundance (numbers).
IAAobs_ymaiArray, survey age composition
IALobs_ymliArray, survey length composition
icomp_likeCharacter, likelihood for the composition data. See like_comp() for options
IAAN_ymiArray, sample size of the index age composition by season if using the multinomial or Dirichlet-multinomial likelihoods
IALN_ymiArray, sample size of the index length composition by season if using the multinomial or Dirichlet-multinomial likelihoods
IAAtheta_iNumeric vector, survey age composition dispersion parameter if using the Dirichlet-multinomial likelihood
IALtheta_iNumeric vector, index length composition dispersion parameter if using the Dirichlet-multinomial likelihood
samp_irsBoolean array that specifies the regions and stocks sampled by the index. samp[i, r, s] indicates whether index i operates in region r and catches stock s.
sel_iCharacter vector, functional forms for selectivity. See "type" argument in conv_selpar() for options.
delta_iNumeric vector, The elapsed fraction of time in the seasonal time step (between 0 - 1) when the index samples the population. Set to a negative number (-1) to sample over the duration of the timestep, i.e., (1 - exp(-Z))/Z.
POP_sA list by stock of data frames for parent-offspring pairs. Each row in the data frame corresponds to a "sampling unit" defined by the columns:
a | Capture year of parent |
t | Age at capture of parent |
y | Birth year of offspring |
n | Number of pairwise comparisons |
m | Number of POPs |
HSP_sA list by stock of data frames for half-sibling pairs. Each row in the data frame corresponds to a "sampling unit" defined by the columns:
yi | Birth year of older sibling |
yj | Birth year of younger sibling |
n | Number of pairwise comparisons |
m | Number of HSPs |
CKMR_likeCharacter, likelihood for the POP and HSP sampling units. See type argument in like_CKMR() for options.
tag_ymarrsArray. Number of tags that move between regions. Informs movement matrices of stocks between time steps.
tag_ymarsArray. Number of tags distributed among regions. Informs stock distribution (within time step).
tag_yyBoolean matrix that aggregates years for the tag data. Only used for the tag movement array tag_ymarrs.
tag_aaBoolean matrix that aggregates ages for the tag data.
tag_likeCharacter. Likelihood for the tagging data, either the vector of proportions by region of origin for tag_ymarrs, or
by region of stock distribution for tag_ymars. See type argument of like_comp() for options
tagN_ymarsArray. Sample size of the tag movement vectors if using the multinomial or Dirichlet-multinomial likelihoods.
tagN_ymasArray. Sample size of the tag distribution vectors if using the multinomial or Dirichlet-multinomial likelihoods.
tagtheta_sArray. Tag dispersion parameter (by stock) if using the Dirichlet-multinomial likelihoods. Default set to 1.
tagstdev_sArray. Tag standard deviation (by stock) if using the lognormal likelihood. Default set to 0.1.
yearVector of years. Length Dmodel@ny
seasonVector of season names. Length Dmodel@nm
ageVector of ages. Length Dmodel@na
regionVector of region names. Length Dmodel@nr
stockVector of stock names. Length Dmodel@ns
fleetVector of fleet names. Length Dfishery@nf
indexVector of index of abundance names. Length Dsurvey@ni
For convenience, most arrays and matrices have the associated dimensions in the variable name. For example, Cobs_ymfr represents
observed catch with the dimension following the underscore, following this template:
y | Year |
m | Season |
a | Age |
r | Region |
f | Fishery |
i | Index |
s | Stock |
MSAdata-class check_data() Dmodel-class Dstock-class Dfishery-class Dsurvey-class DCKMR-class Dtag-class
# Set natal_rs matrix so that the spawning output of stock 1 is
# calculated from mature animals present in regions 1, 2.
# Similarly for stock 2, spawning output from areas 2 and 3.
nr <- 4
ns <- 2
natal_rs <- matrix(0, nr, ns)
natal_rs[1:2, 1] <- natal_rs[2:3, 2] <- 1
# Aggregate stock composition for ages 1-4 and 5-10 across all fleets
na <- 10
na_SC <- 2
SC_aa <- matrix(0, na_SC, na) # Assumes dim(SC_ymafrs)[3] = na_SC
SC_aa[1, 1:4] <- SC_aa[2, 5:10] <- 1
nf <- 3
nf_SC <- 1
SC_ff <- matrix(1, nf_SC, nf) # Assumes dim(SC_ymafrs)[4] <- nf_SC
Run the code above in your browser using DataLab