# Toy example with Pacific Wren sample data
# First, stratify the sample data
strat_data <- stratify(by = "bbs_cws", sample_data = TRUE)
# Prepare the stratified data for use in a JAGS model.
jags_data <- prepare_jags_data(strat_data = strat_data,
species_to_run = "Pacific Wren",
model = "firstdiff",
min_year = 2009,
max_year = 2018)
# Now run a JAGS model.
jags_mod <- run_model(jags_data = jags_data,
n_adapt = 0,
n_burnin = 0,
n_iter = 10,
n_thin = 1)
# Generate only national, continental, and stratum indices
indices <- generate_indices(jags_mod = jags_mod,
jags_data = jags_data,
regions = c("national",
"continental",
"stratum"))
# Now, plot_indices() will generate a list of plots for all regions
plot_list <- plot_indices(indices_list = indices,
species = "Pacific Wren")
#Suppose we wanted to access the continental plot. We could do so with
cont_plot <- plot_list$continental
# You can specify to only plot a subset of years using min_year and max_year
# Plots indices from 2015 onward
plot_list_2015_on <- plot_indices(indices_list = indices,
min_year = 2015,
species = "Pacific Wren")
#Plot up indices up to the year 2017
plot_list_max_2017 <- plot_indices(indices_list = indices,
max_year = 2017,
species = "Pacific Wren")
#Plot indices between 2011 and 2016
plot_list_2011_2015 <- plot_indices(indices_list = indices,
min_year = 2011,
max_year = 2016,
species = "Pacific Wren")
Run the code above in your browser using DataLab