This function is primarily designed for use within run_strat(). It first calculates statistics at the stratum level and then computes broader summaries like total abundance.

strat_means(
  data = NULL,
  metric = NULL,
  strat_groups = NULL,
  survey_groups = NULL,
  confidence = 95
)

Arguments

data

A data.table with all grouping variables in stacked format. Must include strat_area and tow_area for scaling values.

metric

Name of the variable in data.table to summarize (e.g., "number", "mass").

strat_groups

Grouping variables for fine-scale stratum-level means. Must include "strat" and "strat_area". Example: c("year", "species", "shiptrip", "NAFOdiv", "strat", "strat_area", "age")

survey_groups

Grouping variables for large-scale summary calculations Example: c("year", "species")

confidence

Confidence limit percentage (e.g., 95 for 95% CI).

Value

A data.table containing stratified estimates of abundance.