Skip to contents

Check and filter the stratified data by minimum required samples for modelling, and prepare data format for use by models.

Usage

prepare_data(
  strata_data,
  min_year = NULL,
  max_year = NULL,
  min_n_routes = 3,
  min_max_route_years = 3,
  min_mean_route_years = 1,
  quiet = FALSE
)

Arguments

strata_data

List. Stratified data generated by stratify()

min_year

Numeric. Minimum year to use. Default (NULL) uses first year in data.

max_year

Numeric. Maximum year to use. Default (NULL) uses first year in data.

min_n_routes

Numeric. Required minimum routes per strata where species has been observed. Default 3.

min_max_route_years

Numeric. Required minimum number of years with non-zero observations of species on at least 1 route. Default 3. Only retain strata with at least one route where the species was observed at least once in this many years.

min_mean_route_years

Numeric. Required minimum average of years per route with the species observed. Default 1. Only retain strata where the average number of years the species was observed per route is greater than this value.

quiet

Logical. Suppress progress messages? Default FALSE.

Value

List of prepared (meta) data to be used for modelling and further steps.

  • model_data - list of data formatted for use in Stan modelling

  • meta_data - meta data defining the analysis

  • meta_strata - data frame listing strata meta data

  • raw_data - data frame of summarized counts used to create model_data (just formatted more nicely)

See also

Other Data prep functions: prepare_model(), prepare_spatial(), stratify()

Examples

# Toy example with Pacific Wren sample data

# First, stratify the sample data

s <- stratify(by = "bbs_cws", sample_data = TRUE)
#> Using 'bbs_cws' (standard) stratification
#> Using sample BBS data...
#> Using species Pacific Wren (sample data)
#> Stratifying data...
#>   Combining BCR 7 and NS and PEI...
#>   Renaming routes...

# Prepare the stratified data for use in a model. In this
#   toy example, we will set the minimum year as 2009 and
#   maximum year as 2018, effectively only setting up to
#   model 10 years of data.

p <- prepare_data(s, min_year = 2009, max_year = 2018)