Estimate the effective sample size for catch-at-age or catch-at-length data, based on the multinomial distribution.
1 2 3 4
name of model element:
vector of strings indicating which gears or surveys to analyze (all by default).
initial sample size, determining the relative pattern of the effective sample size between years.
function to standardize the effective sample size.
largest possible sample size in one year.
number of decimal places to use when rounding, or
observed catch-at-age or catch-at-length matrix.
fitted catch-at-age or catch-at-length matrix.
init sample sizes set a fixed pattern for the relative
sample sizes between years. For example, if there are two years of
catch-at-age data and the initial sample sizes are 100 in year 1 and
200 in year 2, the effective sample size will be two times greater in
year 2 than in year 1, although both will be scaled up or down
depending on how closely the model fits the catch-at-age data. The
init can be one of the following:
means read the initial sample sizes from the
SS column (default).
means read the initial sample sizes from the
column in that model (object of class
means those are the initial sample sizes (same length as the number of years).
means ignore the initial sample sizes and use the empirical multinomial sample size (nhat) in each year.
means calculate one effective sample size to use across all years, e.g. the mean or median of nhat.
The idea behind
FUN=mean is to guarantee that regardless of the
init, the mean effective sample size will always be
the same. Other functions can be used to a similar effect, such as
estN function is implemented for basic single-sex datasets.
If the data are sex-specific,
estN pools (averages) the sexes
before estimating effective sample sizes. The general function
estN.int, on the other hand, is suitable for analyzing any
matrix format. The int in
stands for internal (not integer), analogous to
sort.int, and similar functions.
Numeric vector of effective sample sizes (one value if
or a list of such vectors when analyzing multiple series.
This function uses the empirical multinomial sample size to estimate an effective sample size, which may be appropriate as likelihood weights for catch-at-age and catch-at-length data. The better the model fits the data, the larger the effective sample size. See McAllister and Ianelli (1997), Gavaris and Ianelli (2002), and Magnusson et al. (2013).
estN can be used iteratively, along with
estSigmaR to assign
likelihood weights that are indicated by the model fit to the data.
Sigmas and sample sizes are then adjusted between model runs, until
they converge. The
iterate function facilitates this procedure.
If P[t,a] is the observed proportion of fish at age (or length bin) a in year t, and Phat[t,a] is the fitted proportion, then the estimated sample size in that year is:
nhat[t] = sum_a(Phat[t,a]*(1-Phat[t,a])) / sum_a((P[t,a]-Phat[t,a])^2)
Due to the non-random and non-independent nature of sampling fish, the effective sample size, for statistical purposes, is much less than the number of fish sampled. Common starting points include using the number of tows as the sample size in each year, or using the empirical multinomial sample sizes. Those “initial” sample sizes can then be scaled up or down. Sample sizes between 20 and 200 are common in the stock assessment literature.
Gavaris, S. and Ianelli, J. N. (2002) Statistical issues in fisheries' stock assessments. Scandinavian Journal of Statistics 29, 245–271.
Magnusson, A., Punt, A. E., and Hilborn, R. (2013) Measuring uncertainty in fisheries stock assessment: the delta method, bootstrap, and MCMC. Fish and Fisheries 14, 325–342.
McAllister, M. K. and Ianelli, J. N. (1997) Bayesian stock assessment using catch-age data and the sampling-importance resampling algorithm. Canadian Journal of Fisheries and Aquaticic Sciences 54, 284–300.
scape-package gives an overview of the package.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
## Exploring candidate sample sizes: getN(x.sbw) # sample sizes used in assessment: number of tows estN(x.sbw) # effective sample size, given data (tows) and model fit estN(x.sbw, ceiling=200) # could use this estN(x.sbw, init=FALSE) # from model fit, disregarding tows plotCA(x.sbw) # years with good fit => large sample size estN(x.sbw, init=1) # one sample size across all years estN(x.sbw, init=c(rep(1,14),rep(2,9))) # two sampling periods ## Same mean, regardless of init: mean(estN(x.sbw, digits=NULL)) mean(estN(x.sbw, digits=NULL, init=FALSE)) mean(estN(x.sbw, digits=NULL, init=1)) mean(estN(x.sbw, digits=NULL, init=c(rep(1,14),rep(2,9)))) ## Same median, regardless of init: median(estN(x.sbw, FUN=median, digits=NULL)) median(estN(x.sbw, FUN=median, digits=NULL, init=FALSE)) median(estN(x.sbw, FUN=median, digits=NULL, init=1)) median(estN(x.sbw, FUN=median, digits=NULL, init=c(rep(1,14),rep(2,9)))) ## Multiple series: getN(x.ling, "CLc") # sample size used in assessment getN(x.ling, "CLc", digits=0) # rounded estN(x.ling, "CLc") # model fit implies larger sample sizes getN(x.ling, "CLc", series="1", digits=0) # get one series estN(x.ling, "CLc", series="1") # estimate one series
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.