eca.estimate.Rd
This function runs the C fitting program and writes results to binary files.
eca.estimate(AgeLength, WeightLength, Landings, GlobalParameters)
A list with elements connected to the age-length model, see Details
A list with elements connected to the weight-length model, see Details
A list with elements connected to landings, not used until prediction.
A list with input parameters that are given by the user, see Details
A list with elements
a list with Intercept and LogLikelihood for the age model with all the mcmc samples for the different parameters included, see below
a list with Intercept, Slope and LogLikelihood for the length-given-age model, with all the mcmc samples for the different parameters included, see below
a list with Intercept, Slope and LogLikelihood for the weight-given-length model, with all the mcmc samples for the different parameters included, see below.
The Intercept and Slope lists consist of:
cov: a list containing (depending on the selected model): constant - season - gearfactor - spatial - cell - catchSample: arrays of mcmc samples of the effects with dimensions #categories x #levels x #samples
tau: list containing (depending on the selected model): season - gearfactor - spatial - cell - catchSample - fish: vectors with mcmc samples of precision parameters for random effects
CAR: list with if spatial model spatial.ar: mcmc samples of the AR-coefficient
If a multiple stocks (coastal cod/Atlantic cod) analysis is run, the list consists of
a list for the age model as described above, except that the age category dimension is 2 times the number of age categories(ncat). The first ncat values correspond to the Atlantic cod and the last ncat values correspond to the coastal cod
a list for the length-given-age model as described above for Atlantic cod
a list for the length-given-age model as described above for coastal cod
a list for the weight-given-length model as described above for Atlantic cod
a list for the weight-given-length model as described above for coastal cod
The LogLikelihood is a vector with the log-likelihood value for the different models in each sample
AgeLength
DataMatrix - matrix with one row for each fish and columns age, part.year, lengthCM, samplingID, partnumber, partcount, otolithtype:
age - age in whole years, missing values are allowed and denoted NA.
part.year - fraction of year, i.e. realage=age+part.year. Values are >0 and <=1. No missing values allowed. E.g. for seasonal sampling, part.year=0.25 for season 1 etc, for daily sampling, part.year=1/365 for day 1 etc.
lengthCM - length in centimeters. No missing values allowed.
samplingID - id for sampling unit, e.g. haul number, numbered from 1 to number of sampling units. No missing values allowed.
partnumber - (DELNR), can be missing (in which case it is assumed that the haul comes in only one part). If it is not missing and there is more than one part in a haul, the fish in the parts are resampled up to the same total number using partcount as the probability (ie there is now one part with the same number of fish as the sum of the original parts)
partcount - (FANT), the size of the haul. If partcount is missing for this haul the haul is omitted.
otolithtype - classification when multiple stocks, type1 (Coastal cod) and type2 (Atlantic cod): 1-certain type1, 2-uncertain type1, 4-uncertain type2, 5-certain type2. No missing values allowed when corresponding age is observed.
CovariateMatrix - matrix with columns for the different covariates, e.g. constant, season, gearfactor, spatial, haulcount, boat. Each row corresponds to the samplingID in DataMatrix.
info - matrix with one row for each covariate and with columns random, CAR, continuous, in.landings, nlev, interaction, in.slopeModel:
random - if the corresponding covariate is a random effect set random=1, if the covariate is a fixed effect set random=0.
CAR - if the corresponding covariate is a spatial effect set CAR=1, otherwise set CAR=0.
continuous - if the corresponding covariate is a continuous covariate set continuous=1, otherwise set continuous=0.
in.landings - if the corresponding covariate is given in the landing data set in.landings=1, otherwise set in.landings=0.
nlev - number of levels for the corresponding covariates.
interaction - these elements define the cell interaction term. A cell is defined as a combination of selected covariates in the landings data. I.e. if gearfactor, spatial and season is included in the cell interaction term, then one cell represents one gear in one region in one season, and these 3 elements are set to 1 while the others are set to 0, and there will be nlev(gearfactor) times nlev(spatial) times nlev(season) different cells. This definition is regardless of the covariates being fixed or random.
in.slopeModel - if the corresponding covariate is included in the slope model set in.slope=1, otherwise set in.slope=0. (At this point only the covariate term is tested properly for being included in the slope model)
CARNeighbours - list with numNeighbours and idNeighbours.
AgeErrorMatrix - matrix that defines the probability of observing each age given the true age. Must be included if uncertainty in ageing is included in the analysis, i.e. GlobalParameters$age.error=1. The true ages are the columns, the observed ages are the rows and the number of rows and columns must equal the number of age categories defined by minage and maxage. The element in row i, column j defines the probability of a fish of true age j being observed as having age i. The columns must sum to 1 (though the rows need not). The dimension is nAges x nAges, where nAges is the number of age categories.
CCerrorList - list with 8 elements of length 1 that defines the classification error: ptype1.CC: Probability of a certain coastal cod being classified as type 1. ptype1.S: Probability of a certain Atlantic cod being classified as type 1. ptype2.CC: Probability of an uncertain coastal cod being classified as type 2. ptype2.S: Probability of an uncertain Atlantic cod being classified as type 2. ptype4.CC: Probability of an uncertain coastal cod being classified as type 4. ptype4.S: Probability of an uncertain Atlantic cod being classified as type 4. ptype5.CC: Probability of a certain coastal cod being classified as type 5. ptype5.S: Probability of a certain Atlantic cod being classified as type 5.
WeightLength
DataMatrix - matrix with one row for each fish and columns weightKG (weight in kilograms), lengthCM (length in centimeters), samplingID (id for sampling unit, e.g. haul number), partnumber, partcount.
CovariateMatrix - matrix with columns for the different covariates (see AgeLength).
info - matrix with one row for each covariate (see AgeLength).
GlobalParameters
nSamples - number of MCMC samples that are saved
thin - number of MCMC samples run before each sample that is saved, e.g. thin=1 saves every sample, thin=10 saves every 10th sample
burnin - number of MCMC samples run and discarded before any samples are saved
lengthresCM - gives the length interval if catch-at-age by length is to be calculated, in centimeters
maxlength - the maximum length of fish in the data set, in centimeters
minage - minimum age category, used to exclude unreasonable data. The model will include ages from minage to maxage and any fish with observed ages outside this range will be omitted. Note that fish with small lengths but no observed age will be included even though they may be below minage
maxage - maximum age category
resultdir - directory path where the results are stored. Two directories cfiles and resfiles are in this folder (created if they don't exist). In cfiles the temporary binary input files to the c-program are stored, and in resfiles the binary output files are stored.
fitfile - name of the output files from estimating the model. The files are given the extensions .mcmc1 and .mcmc2 for the age and length-given-age model and for the weight-given-length model, respectively.
delta.age - default 0.001 - parameter used to improve estimation when there are ages with no observations
age.error - TRUE if uncertainty in ageing is included in the model, FALSE otherwise
lgamodel - default "log-linear" - The length-given-age model will be log-linear unless specified as "non-linear" in which case the Schnute-Richards model will be used
CC - TRUE if coastal cod is included in the model, FALSE otherwise
CCerror - TRUE if classification error is included in coastal cod model, FALSE otherwise
seed - random seed value that initializes the random number generator. If NULL, a random number is generated for this value. Otherwise, if the same seed is used and the other input values are the same, the results will be the same in different simulations.
eca.predict for running predictions from the catch-at-age model.