calc_population_stom: Compilation of observed stomach contents into population diet

View source: R/population_stom.R

calc_population_stomR Documentation

Compilation of observed stomach contents into population diet

Description

Stratification of data must first be done by the function add_strata. With stratification added diet data are firstly compiled for each sub_strata (e.g. ICES rectangles), then compiled by strata (e.g. ICES roundfish areas) and finally compiled for the whole population area. The methods for data compilations must be provided in the control object to the input data, see Details.

Usage

calc_population_stom(s, verbose = FALSE)

Arguments

s

Stomach data set of class STOMobs. It is assumed that the stomach contents weight correspond to the number of stomachs, i.e. the stomach contents for a single predator, or the sum of preys if the sample includes more than one predator (stomach).

verbose

Logical, show details

Details

The compilation method must be specified in the control attribute by the slots. @calc_sub_strata, @calc_strata and @calc_total. Each of the slots must include a list with the following names relative_weight (type=boolean), weighting_factor (type=expression) and weighting_factor_file (type character). An example of such input is shown below:

hom<-edit_control(hom,
 calc_sub_strata=list(
    # do not transform into relative weight before data are compiled
   relative_weight=FALSE,
    # use number of stomachs (n_tot) as weighting factor
   weighting_factor=expression(n_tot),
    # do not use data from external file
   weighting_factor_file=NA
 ),
 calc_strata=list(
   # weight mean stomach contents by sub_strata by the square root of the mean CPUE within the sub_strata
  relative_weight=TRUE,
  weighting_factor=expression(sqrt(pred_cpue)),
  weighting_factor_file=NA
 )
 calc_total=list(
   relative_weight=TRUE,
   weighting_factor=NA,
   weighting_factor_file=file.path(config_dir,'hom_weighting_total.csv')
))

The calc_sub_strata list specifies that the observed stomach contents by samples should not be translated into a relative stomach contents by sample (relative_weight=FALSE) before processed. In cases with more samples from a sub_strata, the average stomach contents within the sub_strata should be calculated as a weighted mean where the number of stomachs sampled (n_tot) is used as weighting factor. Note that you have to use "expression" if you refer to a variable (in this case, n_tot) withinh the data set.

The calc_strata list specified that the average stomach contents by sub_strata initially should be transformed into relative stomach contents by sub_strata (relative_weight=TRUE). The average stomach contents within a stratum should the be calculated as a weighted mean using the squaret root of the CPUE as weighting factor.

The average stomach contents, specified by the list calc_total should be calculated as a weighed mean of the relative stomach contents by stratum weighted by a factor provided in the file hom_weighting_total.csv. Some rows from the file are shown below:

pred_name, stratum_time, pred_size, stratum_area, w_fac_area
HOM,       1991-Q3,      0250-0300,  R-2,         25
HOM,       1991-Q3,      0350-0400,  R-2,          2
HOM,       1991-Q3,      0300-0350,  R-2,         25
HOM,       1991-Q4,      0250-0300,  R-3,         19
HOM,       1991-Q4,      0350-0400,  R-1,         45

The file specifies which weighting factor, w_fac_area, that should be used for a given predator and predator size, within a given temporal (time) stratum and area stratum. See make_template_strata_weighting for how to make such file with the right format.

Value

Diet data set of class STOMdiet


MortenVinther/FishStomachs documentation built on Feb. 14, 2025, 7:33 a.m.