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,
species,
model,
heavy_tailed,
n_knots,
basis,
sampler,
strat_data,
strata_rem
)
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
.- species
Defunct. Use
species
instratify()
instead- model
Defunct. Use
model
inprepare_model()
instead- heavy_tailed
Defunct. Use
heavy_tailed
inprepare_model()
instead- n_knots
Defunct. Use
n_knots
inprepare_model()
instead- basis
Defunct. Use
basis
inprepare_model()
instead- sampler
Defunct.
- strat_data
Defunct. Use
strata_data
instead- strata_rem
Defunct. Use
custom_strata
instratify()
instead
Value
List of prepared (meta) data to be used for modelling and further steps.
model_data
list of data formatted for use in Stan modellingmeta_data
meta data defining the analysismeta_strata
data frame listing strata meta dataraw_data
contains a data frame of summarized data used to createmodel_data
(just formatted more nicely)
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)