Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
66602da
add example data for multi-pop and missing yearss
sebdalgarno Nov 13, 2025
7caf3ef
update r depends version
sebdalgarno Nov 13, 2025
e7d8bc0
remove examles from documentation
sebdalgarno Nov 13, 2025
c118742
ignore claude files
sebdalgarno Nov 13, 2025
b5a2968
allow missing values and multi populations
sebdalgarno Nov 18, 2025
555a5ab
rename function to be more clear that checking for one population
sebdalgarno Nov 18, 2025
fe7f945
ignore claude
sebdalgarno Nov 18, 2025
9ad9f26
add new datasets to pkgdown reference index
sebdalgarno Feb 27, 2026
8c7322b
fix missing datasets to use one placeholder row per unobserved year
sebdalgarno Feb 27, 2026
b4be5bb
redesign multi-pop datasets for better edge case coverage
sebdalgarno Feb 27, 2026
e55e996
update recruit and survival datasets
sebdalgarno Mar 2, 2026
b837e6f
make chk when allow_missing = TRUE more strict (i.e. all-or-nothing m…
sebdalgarno Mar 7, 2026
08e2b71
linter and styler
sebdalgarno Mar 12, 2026
b41e775
bump version, add news
sebdalgarno Mar 12, 2026
848da43
Update DESCRIPTION
sebdalgarno Mar 12, 2026
f41a08a
depend on 4.1, as per joe suggestion
sebdalgarno Mar 12, 2026
e88558d
remove fledge comment - no longer using fledge to maintain
sebdalgarno Mar 12, 2026
954715b
use base pipe
sebdalgarno Mar 12, 2026
de0e2f2
rename .chk_population1, add proper chks when allow_missing = TRUE
sebdalgarno Mar 12, 2026
e74b964
Merge branch 'extensions' of github.com:poissonconsulting/bboudata in…
sebdalgarno Mar 12, 2026
ac163f3
add claude.md to buildignore
sebdalgarno Mar 12, 2026
d0a66d3
add ECCC copyright to modified files
sebdalgarno Mar 13, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@
^_pkgdown\.yml$
^README\.Rmd$
^CODE_OF_CONDUCT\.md$
^\.claude$
^CLAUDE\.md$
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,6 @@ output[0-9]/
output-20[0-9][0-9]-[0-9][0-9]*

report/

.claude/
CLAUDE.md
6 changes: 3 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: bboudata
Title: Data for bbou Project
Version: 0.3.2
Version: 0.4.0
Authors@R: c(
person("Troy", "Hegel", , "troy.hegel@gov.ab.ca", role = "aut"),
person("Dave", "Hervieux", , "dave.hervieux@gov.ab.ca", role = "aut"),
Expand Down Expand Up @@ -28,7 +28,7 @@ URL: https://poissonconsulting.github.io/bboudata/,
https://github.com/poissonconsulting/bboudata
BugReports: https://github.com/poissonconsulting/bboudata/issues
Depends:
R (>= 3.4)
R (>= 4.1)
Imports:
chk,
tibble
Expand All @@ -41,5 +41,5 @@ Config/testthat/edition: 3
Encoding: UTF-8
LazyData: true
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.3.2.9000
RoxygenNote: 7.3.3.9000
Config/Needs/website: poissonconsulting/poissontemplate
15 changes: 14 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@
<!-- NEWS.md is maintained by https://fledge.cynkra.com, contributors should not edit this file -->
# bboudata 0.4.0

Updated for bboutools 1.3.0.

## New features

* `bbd_chk_data_survival()` and `bbd_chk_data_recruitment()` gained `multi_population` and `allow_missing` arguments to support multi-population data and unobserved year placeholder rows.
* `bbd_chk_data_survival()` and `bbd_chk_data_recruitment()` now validate that placeholder rows have all measurement columns as NA (not just some) when `allow_missing = TRUE` (#94).

## Datasets

* Added `bbousurv_multi` and `bbourecruit_multi` — multi-population datasets (populations A, B, C) with staggered year ranges, an internal data gap, and unobserved year placeholder rows.
* Added `bbousurv_missing` and `bbourecruit_missing` — single-population (C) datasets with unobserved year placeholder rows.
* Added `bbousurv_annual` — multi-population (A, C) aggregate annual survival data with staggered years.

# bboudata 0.3.2

Expand Down
70 changes: 70 additions & 0 deletions R/bbourecruit.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Copyright 2022-2023 Integrated Ecological Research and Poisson Consulting Ltd.
# Copyright 2024 Province of Alberta
# Copyright 2025 Environment and Climate Change Canada
#
# Licensed under the Apache License, Version 2.0 (the 'License');
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -43,6 +44,75 @@
#'
"bbourecruit_a"

#' Sample Data for Multiple Populations
#'
#' The data contains anonymized recruitment information for boreal caribou populations 'A', 'B' and 'C'
#' with staggered year ranges, an internal gap (B missing 2009-2010), and unobserved year
#' placeholder rows (2016 for all populations). Designed to test multi-population analysis,
#' latent random effects for missing year-population combos, and unobserved year prediction.
#' Filter to single population or remove placeholder rows (where Month is NA) as needed.
#' This dataset follows the methodology described in DeCesare et al. (2012) for estimating
#' population growth rates using calf/cow age ratios.
#'
#' @details The data is released under the [Open Government Licence -
#' Alberta](https://open.alberta.ca/licence)
#'
#' @references
#' DeCesare, N.J., Hebblewhite, M., Bradley, M., Smith, K.G., Hervieux, D., & Neufeld, L. (2012).
#' Estimating ungulate recruitment and growth rates using age ratios.
#' The Journal of Wildlife Management, 76(1), 144-153. doi:10.1002/jwmg.244
#'
#' @format A tibble with columns:
#' \describe{
#' \item{PopulationName}{Name of the population}
#' \item{Year}{The year the observation occurred}
#' \item{Month}{The month the observation occurred}
#' \item{Day}{The day the observation occurred}
#' \item{Cows}{The number of cows counted in the group}
#' \item{Bulls}{The number of bulls counted in the group}
#' \item{UnknownAdults}{The number of adults which could not be sexed in the
#' group}
#' \item{Yearlings}{The number of yearlings counted in the group}
#' \item{Calves}{The number of calves counted in the group}
#' }
#'
"bbourecruit_multi"

#' Sample Data with Unobserved Years
#'
#' The data contains anonymized recruitment information for boreal caribou population 'C',
#' with years 2010-2013 represented as single placeholder rows with all-NA measurement
#' columns. These placeholder rows signal unobserved years to the model: the data pipeline
#' uses them to set Annual factor levels, then strips them before building the likelihood.
#' Random effects for unobserved years are estimated purely from the hierarchical prior.
#' The dataset follows the methodology
#' described in DeCesare et al. (2012) for estimating population growth rates using
#' calf/cow age ratios.
#'
#' @details The data is released under the [Open Government Licence -
#' Alberta](https://open.alberta.ca/licence)
#'
#' @references
#' DeCesare, N.J., Hebblewhite, M., Bradley, M., Smith, K.G., Hervieux, D., & Neufeld, L. (2012).
#' Estimating ungulate recruitment and growth rates using age ratios.
#' The Journal of Wildlife Management, 76(1), 144-153. doi:10.1002/jwmg.244
#'
#' @format A tibble with columns:
#' \describe{
#' \item{PopulationName}{Name of the population}
#' \item{Year}{The year the observation occurred}
#' \item{Month}{The month the observation occurred}
#' \item{Day}{The day the observation occurred}
#' \item{Cows}{The number of cows counted in the group}
#' \item{Bulls}{The number of bulls counted in the group}
#' \item{UnknownAdults}{The number of adults which could not be sexed in the
#' group}
#' \item{Yearlings}{The number of yearlings counted in the group}
#' \item{Calves}{The number of calves counted in the group}
#' }
#'
"bbourecruit_missing"

#' Sample Data for Population B
#'
#' The data contains anonymized recruitment information for boreal caribou population 'B'
Expand Down
102 changes: 102 additions & 0 deletions R/bbousurv.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Copyright 2022-2023 Integrated Ecological Research and Poisson Consulting Ltd.
# Copyright 2024 Province of Alberta
# Copyright 2025 Environment and Climate Change Canada
#
# Licensed under the Apache License, Version 2.0 (the 'License');
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -103,6 +104,107 @@
#'
"bbousurv_c"

#' Sample Data for Multiple Populations
#'
#' The data contains anonymized survival information for boreal caribou populations 'A', 'B' and 'C'
#' with staggered year ranges, an internal gap (B missing 2008-2009), and unobserved year
#' placeholder rows (2015 for all populations). Designed to test multi-population analysis,
#' latent random effects for missing year-population combos, and unobserved year prediction.
#' Filter to single population or remove placeholder rows (where Month is NA) as needed.
#' This dataset follows the methodology described in DeCesare et al. (2012) for estimating
#' population growth rates using adult female survival data.
#'
#' @details
#' The data is released under the [Open Government Licence -
#' Alberta](https://open.alberta.ca/licence)
#'
#' @references
#' DeCesare, N.J., Hebblewhite, M., Bradley, M., Smith, K.G., Hervieux, D., & Neufeld, L. (2012).
#' Estimating ungulate recruitment and growth rates using age ratios.
#' The Journal of Wildlife Management, 76(1), 144-153. doi:10.1002/jwmg.244
#'
#' @format A tibble with columns:
#' \describe{
#' \item{PopulationName}{Name of the population}
#' \item{Year}{The year the observation occurred}
#' \item{Month}{The month the observation occurred}
#' \item{StartTotal}{The total number of collared caribou at the start of the
#' month}
#' \item{MortalitiesCertain}{The number of confirmed caribou mortalities in the
#' month}
#' \item{MortalitiesUncertain}{The total number of mortalities that were not
#' confirmed in that month}
#' }
#'
"bbousurv_multi"

#' Sample Data for Annual Survival Data
#'
#' The data contains anonymized survival information for boreal caribou populations 'A' and 'C',
#' aggregated to annual resolution with staggered year ranges. Designed to test the combination
#' of multi-population analysis with aggregate annual data. Filter to single population for
#' simple annual-only testing.
#' This dataset follows the methodology described in DeCesare et al. (2012) for estimating
#' population growth rates using adult female survival data.
#'
#' @details
#' The data is released under the [Open Government Licence -
#' Alberta](https://open.alberta.ca/licence)
#'
#' @references
#' DeCesare, N.J., Hebblewhite, M., Bradley, M., Smith, K.G., Hervieux, D., & Neufeld, L. (2012).
#' Estimating ungulate recruitment and growth rates using age ratios.
#' The Journal of Wildlife Management, 76(1), 144-153. doi:10.1002/jwmg.244
#'
#' @format A tibble with columns:
#' \describe{
#' \item{PopulationName}{Name of the population}
#' \item{Year}{The year the observation occurred}
#' \item{Month}{The month the observation occurred}
#' \item{StartTotal}{The total number of collared caribou at the start of the
#' month}
#' \item{MortalitiesCertain}{The number of confirmed caribou mortalities in the
#' month}
#' \item{MortalitiesUncertain}{The total number of mortalities that were not
#' confirmed in that month}
#' }
#'
"bbousurv_annual"

#' Sample Data with Unobserved Years
#'
#' The data contains anonymized survival information for boreal caribou population 'C',
#' with years 2010-2013 represented as single placeholder rows with all-NA measurement
#' columns. These placeholder rows signal unobserved years to the model: the data pipeline
#' uses them to set Annual factor levels, then strips them before building the likelihood.
#' Random effects for unobserved years are estimated purely from the hierarchical prior.
#' The dataset follows the methodology described
#' in DeCesare et al. (2012) for estimating population growth rates using adult female survival data.
#'
#' @details
#' The data is released under the [Open Government Licence -
#' Alberta](https://open.alberta.ca/licence)
#'
#' @references
#' DeCesare, N.J., Hebblewhite, M., Bradley, M., Smith, K.G., Hervieux, D., & Neufeld, L. (2012).
#' Estimating ungulate recruitment and growth rates using age ratios.
#' The Journal of Wildlife Management, 76(1), 144-153. doi:10.1002/jwmg.244
#'
#' @format A tibble with columns:
#' \describe{
#' \item{PopulationName}{Name of the population}
#' \item{Year}{The year the observation occurred}
#' \item{Month}{The month the observation occurred}
#' \item{StartTotal}{The total number of collared caribou at the start of the
#' month}
#' \item{MortalitiesCertain}{The number of confirmed caribou mortalities in the
#' month}
#' \item{MortalitiesUncertain}{The total number of mortalities that were not
#' confirmed in that month}
#' }
#'
"bbousurv_missing"

#' Simulated Data for Scenario 1
#'
#' Data are simulated with the [`bbousims`](https://poissonconsulting.github.io/bbousims/) package.
Expand Down
70 changes: 52 additions & 18 deletions R/chk-data-recruitment.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Copyright 2022-2023 Integrated Ecological Research and Poisson Consulting Ltd.
# Copyright 2024 Province of Alberta
# Copyright 2025 Environment and Climate Change Canada
#
# Licensed under the Apache License, Version 2.0 (the 'License');
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -40,10 +41,12 @@
#' survey/year. Must be a positive integer.}
#' }
#'
#' @param data The data frame check.
#' @param x_name Name of data frame.
#'
#' @return An invisible copy of the original data frame.
#' @param data The data.frame to check.
#' @param x_name A string of the name of the data.frame.
#' @param multi_population A flag indicating whether to accept multiple populations.
#' @param allow_missing A flag indicating whether to accept placeholder rows for unobserved years. When TRUE, rows with all-NA measurement columns (Month, Day, Cows, Bulls, UnknownAdults, Yearlings, Calves) are permitted. These rows signal unobserved years to the model.

#' @return An invisible copy of the original data.frame.
#' @export
#'
#' @examples
Expand All @@ -55,7 +58,11 @@
#' x <- bbourecruit_a
#' x[1, 4] <- 32L
#' try(bbd_chk_data_recruitment(x))
bbd_chk_data_recruitment <- function(data, x_name = deparse(substitute(data))) {
bbd_chk_data_recruitment <- function(data, x_name = deparse(substitute(data)),
multi_population = FALSE, allow_missing = FALSE) {
chk::chk_flag(multi_population)
chk::chk_flag(allow_missing)

nms <- c(
"PopulationName", "Year", "Month", "Day", "Cows",
"Bulls", "UnknownAdults", "Yearlings", "Calves"
Expand All @@ -64,35 +71,62 @@ bbd_chk_data_recruitment <- function(data, x_name = deparse(substitute(data))) {

chk::chk_character_or_factor(data$PopulationName, x_name = xname(x_name, "PopulationName"))
chk::chk_not_any_na(data$PopulationName, x_name = "PopulationName")
.chk_population(data)
if (!multi_population) {
.chk_single_population(data)
}

chk::chk_whole_numeric(data$Year, x_name = xname(x_name, "Year"))
chk::chk_gte(data$Year, 0, x_name = xname(x_name, "Year"))

chk::chk_whole_numeric(data$Month, x_name = xname(x_name, "Month"))
chk::chk_range(data$Month, range = c(1, 12), x_name = xname(x_name, "Month"))

chk::chk_whole_numeric(data$Day, x_name = xname(x_name, "Day"))
chk::chk_range(data$Day, range = c(1, 31), x_name = xname(x_name, "Day"))

chk::chk_not_any_na(data$Year, x_name = "Year")
chk::chk_not_any_na(data$Month, x_name = "Month")
chk::chk_not_any_na(data$Day, x_name = "Day")

chk::chk_whole_numeric(data$Month, x_name = xname(x_name, "Month"))
chk::chk_whole_numeric(data$Day, x_name = xname(x_name, "Day"))
chk::chk_whole_numeric(data$Cows, x_name = xname(x_name, "Cows"))
chk::chk_gte(data$Cows, 0, x_name = xname(x_name, "Cows"))

chk::chk_whole_numeric(data$Bulls, x_name = xname(x_name, "Bulls"))
chk::chk_gte(data$Bulls, 0, x_name = xname(x_name, "Bulls"))

chk::chk_whole_numeric(data$UnknownAdults, x_name = xname(x_name, "UnknownAdults"))
chk::chk_gte(data$UnknownAdults, 0, x_name = xname(x_name, "UnknownAdults"))

chk::chk_whole_numeric(data$Yearlings, x_name = xname(x_name, "Yearlings"))
chk::chk_gte(data$Yearlings, 0, x_name = xname(x_name, "Yearlings"))

chk::chk_whole_numeric(data$Calves, x_name = xname(x_name, "Calves"))
chk::chk_gte(data$Calves, 0, x_name = xname(x_name, "Calves"))

if (!allow_missing) {
chk::chk_range(data$Month, range = c(1, 12), x_name = xname(x_name, "Month"))
chk::chk_not_any_na(data$Month, x_name = "Month")
chk::chk_range(data$Day, range = c(1, 31), x_name = xname(x_name, "Day"))
chk::chk_not_any_na(data$Day, x_name = "Day")
chk::chk_not_any_na(data$Cows, x_name = xname(x_name, "Cows"))
chk::chk_not_any_na(data$Bulls, x_name = xname(x_name, "Bulls"))
chk::chk_not_any_na(data$UnknownAdults, x_name = xname(x_name, "UnknownAdults"))
chk::chk_not_any_na(data$Yearlings, x_name = xname(x_name, "Yearlings"))
chk::chk_not_any_na(data$Calves, x_name = xname(x_name, "Calves"))
} else {
.chk_placeholder_all_or_nothing(
data,
c("Cows", "Bulls", "UnknownAdults", "Yearlings", "Calves")
)
placeholder <- is.na(data$Cows) &
is.na(data$Bulls) &
is.na(data$UnknownAdults) &
is.na(data$Yearlings) &
is.na(data$Calves)
if (any(placeholder) && !all(is.na(data$Month[placeholder]))) {
chk::abort_chk("Placeholder rows must have `Month` as NA.")
}
if (any(placeholder) && !all(is.na(data$Day[placeholder]))) {
chk::abort_chk("Placeholder rows must have `Day` as NA.")
}
if (any(!placeholder)) {
obs <- data[!placeholder, , drop = FALSE]
chk::chk_not_any_na(obs$Month, x_name = "Month")
chk::chk_range(obs$Month, range = c(1, 12), x_name = xname(x_name, "Month"))
chk::chk_not_any_na(obs$Day, x_name = "Day")
chk::chk_range(obs$Day, range = c(1, 31), x_name = xname(x_name, "Day"))
}
}

invisible(data)
}
Loading
Loading