Chapter 8 Advanced options

8.1 Custom regional summaries

Yes, you can calculate the trend and trajectories for custom combinations of strata, such as a formal trend estimate for populations of Scarlet Tanager in the North East (BCRs 7, 8, 12, 13, and 14).

load("jags_mod_full.RData") #saved Scarlet Tanager model output and data

8.1.1 Define the custom regions as a collection of the existing strata.

First extract a dataframe that defines the original strata used in the analysis.

st_comp_regions <- get_composite_regions(strata_type = "bbs_cws")
knitr::kable(head(st_comp_regions))
prov_state region area_sq_km national bcr Province_State Country bcr_by_country
AB CA-AB-10 52565 CA 10 Alberta Canada Canada-BCR_10
AB CA-AB-6 445136 CA 6 Alberta Canada Canada-BCR_6
AB CA-AB-8 6987 CA 8 Alberta Canada Canada-BCR_8
AB CA-AB-11 149352 CA 11 Alberta Canada Canada-BCR_11
AK US-AK-1 9551 US 1 ALASKA United States of America United States of America-BCR_1
AK US-AK-2 283405 US 2 ALASKA United States of America United States of America-BCR_2

Then add a column to the dataframe that groups the original strata into the desired custom regions.

st_comp_regions$NorthEast <- ifelse(st_comp_regions$bcr %in% c(7,8,12:14),"NorthEast","Other")

8.2 Exporting the JAGS model

You can easily export any of the bbsBayes models to a text file.

model_to_file(model = "slope",
              filename = "my_slope_model.txt")

Then, you can modify the model text (e.g., try a different prior) and run the modified model

run_model <- function(... ,
                      model_file_path = "my_modified_slope_model.txt",
                      ... )

Details coming soon…

8.3 Customizing the JAGS model and data

You can even export the bbsBayes model as text, and modify it to add in covariates. For example a GAM smooth to estimate the effect of the day of year on the observations, or an annual weather covariate, or… Then add the relevant covariate data to the jags_data object, and you’re off! We’ll add some more details and examples soon.

8.4 Comparing Models

Finally, bbsBayes can be used to run Bayesian cross-validations. For example, the get_final_values() function is useful to provide an efficient starting point for a cross-validation runs, without having to wait for another full burn-in period.

Paper that includes an example of how to implement a cross-validation using bbsBayes.

Pre-print: https://doi.org/10.1101/2020.03.26.010215 Supplement: https://zenodo.org/badge/latestdoi/228419725

NOTE: although bbsBayes includes functions to calculate WAIC, recent work has shown that WAIC performs very poorly with the BBS data (https://doi.org/10.1650/CONDOR-17-1.1). We recommend a k-fold cross-validation approach, as in the above zenodo archive.