On this page

Return the population estimates of a fit as one long table, with standard errors, approximate intervals and a flag for the values that the model predicts without survey information.

Usage

extract_estimates(
  fit,
  quantities = c("SSB", "Rec", "B", "N", "CN", "F"),
  conf_level = 0.95,
  interval = c("lognormal", "wald")
)

Arguments

ArgumentDefaultDescription
fitrequired

An ACL or ALSCL fit, or a saved fit read with read_assessment().

quantitiesc("SSB", "Rec", "B", "N", "CN", "F")

Character vector of quantity names. Both models report SSB, Rec, B, N, CN, NA, NL, BL, SBL, CNA and F ("F" gives F at age for ACL and F at length, FL, for ALSCL). ALSCL also reports CB, BA, SBA, CNL, CBA, CBL, FL, FA and the joint arrays NLA, BLA, SBLA, CNLA and CBLA; asking an ACL fit for these is an error. Numbers at age can also be requested as N_at_age, an alias of NA. Letter case does not matter.

conf_level0.95

Nominal confidence level of the approximate intervals, strictly between zero and one.

intervalc("lognormal", "wald")

"lognormal" (default) gives exp(log(estimate) +/- z * SE / estimate), the interval of the plots of the package and of self_test(); "wald" gives estimate +/- z * SE. Under "lognormal", an estimate of zero gets the Wald upper bound and a lower bound of zero, and a negative estimate keeps the Wald bounds. Letter case does not matter.

Value

A long data frame with the columns quantity, report_name, year, age, length, length_label, estimate, std_error, conf_low, conf_high, numerical_ok and extrapolated. numerical_ok is the verdict of the numerical checks of the fit, the same that summary() reports. extrapolated is TRUE for the rows that depend on the fishing mortality rate (F) of the last time step and for every row after the last time step with a survey observation; the model predicts these values without survey information.

Details

Estimates come from fit$report. Standard errors come from the rows of fit$est_std with exactly the same name, and only when these are complete; otherwise the standard errors and the interval bounds are NA. F keeps the age classes or length bins of the model and is a rate per model time step, without averaging or conversion to an annual rate. FA uses the ages and time steps at the start of each survival interval. Under the default "lognormal", the interval of a positive estimate stays positive; an estimate of zero, or one whose lognormal upper bound overflows, gets the Wald upper bound and a lower bound of zero, and a negative estimate keeps the Wald bounds. interval = "wald" gives the symmetric interval, which is not truncated at zero.

conf_level is the nominal confidence level of the approximate intervals. summarize_simulations() reports the proportion of simulation intervals that contain the true value.

No observation informs F in the last time step. The survey index of a time step measures abundance at its start, and that abundance depends on F in earlier time steps only. The reported F of the last time step (F and FL) is therefore the first-order autoregressive (AR(1)) prediction from the time step before, and its standard error reflects the F process, not the data. Catch in number (CN, CNA, CNL, CNLA) and catch in weight (CB, CBA, CBL, CBLA) of the last time step are the product of an abundance that the data inform and this predicted F. These rows have extrapolated = TRUE, as do the rows of ALSCL F at age (FA) in the last time step. When the last time steps have no positive survey observation, F and catch are predictions from the last time step with an observation onwards, and every other quantity (SSB, B, N, Rec and the quantities at age and at length) is a prediction in the time steps after it; all these rows have extrapolated = TRUE.

For ALSCL, FA covers every age class, including the plus group, and every time step. The fitted report (fit$report$FA) holds the age classes before the plus group and the time steps before the last, with standard errors. The other cells are calculated by the same formula from the reported numbers at length and age (fit$report$NLA) and total mortality at length (fit$report$ZL), and their standard errors are NA. They are calculated after fitting, because calculating them in the model template would change the fitted values at the level of rounding. A result without numbers at length and age, for example a hand-made list, returns the reported cells only.

Numbers at age can also be requested as N_at_age, an alias of NA. A table with the label "NA" loses that label when it is written to a CSV file and read back with the default settings of read.csv(), which read "NA" as a missing value; use N_at_age, or na.strings = "" when reading. In the fitted report the matrix is fit$report[["NA"]], with double brackets because NA is a reserved word in R.

Additional details from R help

Estimates come from report. Complete finite nonnegative standard errors come from exact matching rows of est_std. Incomplete uncertainty for a quantity remains NA, and so do its interval bounds. Lognormal intervals of a positive estimate stay positive. An estimate of zero, or one whose lognormal upper bound overflows, keeps the Wald bounds with the lower bound stopped at zero, and a negative estimate keeps the Wald bounds. Wald intervals are not truncated at zero. FA is labelled with the age and time step at the start of the survival interval of the cohort, not at its end.

No observation informs F in the last time step. The survey index of a time step measures abundance at its start, which depends on F in earlier time steps only. The reported F of the last time step (F and FL) is therefore the first-order autoregressive (AR(1)) prediction from the time step before, and its standard error reflects the F process, not data. Catch in number (CN, CNA, CNL, CNLA) and catch in weight (CB, CBA, CBL, CBLA) of the last time step are the product of an abundance that the data inform and this predicted F. These rows have extrapolated = TRUE, as do the rows of ALSCL F at age (FA) of the last time step. When the last time steps have no positive survey observation, F and catch are predictions from the last time step with an observation onwards, and every other quantity (SSB, B, N, Rec and the quantities at age and at length) is a prediction in the time steps after it; all these rows have extrapolated = TRUE.

For ALSCL, FA covers every age, including the plus group, and every time step. The fitted report (fit$report$FA) holds the ages before the plus group and the time steps before the last, with standard errors. The other cells are computed by the same formula from the reported numbers at length and age and total mortality at length, and their standard errors are NA.

Examples

Run the setup before the example. Fitting examples require an R-compatible C++ toolchain; simulation and export examples may write files.

Example setup
library(ALSCL)
library(ggplot2)
library(patchwork)
data("YTF_example")
x <- YTF_example
inputs <- x[c("data.CatL", "data.wgt", "data.mat")]
dat <- x$data.CatL
a <- run_acl(x, silent = TRUE)
b <- run_alscl(x, silent = TRUE)
est <- extract_estimates(b, quantities = c("SSB", "Rec", "F"))
head(est)

See also

Search documentation