Chapter 6 Estimating Annual Indices and Trends

Once the model has finished running, we can use the saved output to calculate the population trajectories and trends. As an example, we’ll load some saved model output for Barn Swallow, from the gamye model. If you haven’t already, you can download the model output file here, then save it into your working directory.

This saved workspace includes two objects:

  1. jags_data - the data object created with the prepare_jags_data() function.

  2. jags_mod - the model output created with the run_model() function.

load("data/gamye_Barn_Swallow/jags_mod_full.RData")

6.1 Annual Indices

The annual indices of relative abundance (“annual indices”) from all of the bbsBayes models represent the expected mean count on the BBS routes in a given region and year. The time-series of these annual indices in a given region make up the estimated population trajectory.

indices <- generate_indices(jags_mod = jags_mod,
                            jags_data = jags_data)
## Note: this function can take ~20 minutes to run for a species with a broad range (many strata) and if the model run included a long time-series (many years).

By default, this function generates estimates for the continent (i.e., survey-wide) and for the individual strata. However, if using one of the two BBS stratifications “bbs_usgs” or “bbs_cws,” the user can also select summaries for composite regions (regions made up of collections of strata), such as countries, provinces/states, Bird Conservation Regions, etc.

indices <- generate_indices(jags_mod = jags_mod,
                            jags_data = jags_data,
                            regions = c("continental",
                            "national",
                            "prov_state",
                            "stratum"))
                            #also "bcr", #BCR specific estimates
                            # "bcr_by_country" #e.g., splits the BCRs along the national borders

The generate_indices() function creates a list that includes an object called data_summary, which is a dataframe with all of the estimated annual indices indices$data_summary.

knitr::kable(head(indices$data_summary[,c(1,2,4,7,8,13,14,15,16)]))
Year Region Region_type Index Index_q_0.025 Index_q_0.975 obs_mean nrts nnzero
1966 Continental continental 9.48 8.64 10.8 2.36 396 338
1967 Continental continental 9.78 9.05 10.8 4.87 814 670
1968 Continental continental 10.23 9.59 11.1 7.64 869 711
1969 Continental continental 10.66 10.10 11.4 8.75 1187 963
1970 Continental continental 11.09 10.57 11.7 9.45 1276 1047
1971 Continental continental 11.36 10.89 11.9 9.84 1368 1158

For example, one may wish to export the annual indices to a text file that can be read using Microsoft Excel.

write.csv(indices$data_summary, "Barn_Swallow_trajectories.csv")

The list also includes a number of other objects that retain the stratification information, strata area weights, and the full posterior samples for every estimated annual index. Generally these other objects are only used by subsequent functions and the user won’t access them directly.

The function also accepts the alternative annual indices, such as the smooth-only indices from the gamye model.

indices_smooth <- generate_indices(jags_mod = jags_mod,
                            jags_data = jags_data,
                            alternate_n = "n3",
                            regions = c("continental",
                            "national",
                            "prov_state",
                            "stratum"))
                            #also "bcr", #BCR specific estimates
                            # "bcr_by_country" #e.g., splits the BCRs along the national borders