Learn R Programming

scape (version 2.3.5)

estN: Estimate Effective Sample Size

Description

Estimate the effective sample size for catch-at-age or catch-at-length data, based on the multinomial distribution.

Usage

estN(model, what="CAc", series=NULL, init=NULL, FUN=mean, ceiling=Inf,
     digits=0)

estN.int(P, Phat) # internal function

Value

Numeric vector of effective sample sizes (one value if init=1), or a list of such vectors when analyzing multiple series.

Arguments

model

fitted scape model containing catch-at-age and/or catch-at-length data.

what

name of model element: "CAc", "CAs", "CLc", or "CLs".

series

vector of strings indicating which gears or surveys to analyze (all by default).

init

initial sample size, determining the relative pattern of the effective sample size between years.

FUN

function to standardize the effective sample size.

ceiling

largest possible sample size in one year.

digits

number of decimal places to use when rounding, or NULL to suppress rounding.

P

observed catch-at-age or catch-at-length matrix.

Phat

fitted catch-at-age or catch-at-length matrix.

Details

The 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 value of init can be one of the following:

NULL

means read the initial sample sizes from the existing SS column (default).

model

means read the initial sample sizes from the SS column in that model (object of class scape).

numeric vector

means those are the initial sample sizes (same length as the number of years).

FALSE

means ignore the initial sample sizes and use the empirical multinomial sample size (\(\hat n\)) in each year.

1

means calculate one effective sample size to use across all years, e.g. the mean or median of \(\hat n\).

The idea behind FUN=mean is to guarantee that regardless of the value of init, the mean effective sample size will always be the same. Other functions can be used to a similar effect, such as FUN=median.

The 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 datasets in matrix format. The int in estN.int stands for internal (not integer), analogous to rep.int, seq.int, sort.int, and similar functions.

References

Gavaris, S. and Ianelli, J.N. (2002). Statistical issues in fisheries' stock assessments. Scandinavian Journal of Statistics, 29, 245--271. tools:::Rd_expr_doi("10.1111/1467-9469.00282")

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. tools:::Rd_expr_doi("10.1111/j.1467-2979.2012.00473.x")

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. tools:::Rd_expr_doi("10.1139/f96-285")

See Also

getN, getSigmaI, getSigmaR, estN, estSigmaI, and estSigmaR extract and estimate sample sizes and sigmas.

iterate combines all the get* and est* functions in one call.

plotCA and plotCL show what is behind the sample-size estimation.

scape-package gives an overview of the package.

Examples

Run this code
## 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

Run the code above in your browser using DataLab