diff --git a/R/model-recruitment.R b/R/model-recruitment.R index 4df1dba5..cc860691 100644 --- a/R/model-recruitment.R +++ b/R/model-recruitment.R @@ -36,7 +36,7 @@ model_data_recruitment <- function( if (any(placeholder)) { unobserved_years <- caribou_year( data$Year[placeholder], - year_start, + ifelse("Month" %in% colnames(data), year_start - 1, year_start), year_start = year_start ) if (!quiet) { diff --git a/tests/testthat/_snaps/plot-month-survival/plot_month_survival_multi.png b/tests/testthat/_snaps/plot-month-survival/plot_month_survival_multi.png index 9ec7872d..e5d8a488 100644 Binary files a/tests/testthat/_snaps/plot-month-survival/plot_month_survival_multi.png and b/tests/testthat/_snaps/plot-month-survival/plot_month_survival_multi.png differ diff --git a/tests/testthat/_snaps/plot-month-survival/plot_month_survival_predict_survival.png b/tests/testthat/_snaps/plot-month-survival/plot_month_survival_predict_survival.png index a9ce8b84..846b34e2 100644 Binary files a/tests/testthat/_snaps/plot-month-survival/plot_month_survival_predict_survival.png and b/tests/testthat/_snaps/plot-month-survival/plot_month_survival_predict_survival.png differ diff --git a/tests/testthat/_snaps/plot-month-survival/plot_month_survival_predict_survival_ml.png b/tests/testthat/_snaps/plot-month-survival/plot_month_survival_predict_survival_ml.png index e904c641..d0a9c02f 100644 Binary files a/tests/testthat/_snaps/plot-month-survival/plot_month_survival_predict_survival_ml.png and b/tests/testthat/_snaps/plot-month-survival/plot_month_survival_predict_survival_ml.png differ diff --git a/tests/testthat/_snaps/plot-month-survival/plot_month_survival_survival.png b/tests/testthat/_snaps/plot-month-survival/plot_month_survival_survival.png index a9ce8b84..846b34e2 100644 Binary files a/tests/testthat/_snaps/plot-month-survival/plot_month_survival_survival.png and b/tests/testthat/_snaps/plot-month-survival/plot_month_survival_survival.png differ diff --git a/tests/testthat/_snaps/plot-month-survival/plot_month_survival_survival_ml.png b/tests/testthat/_snaps/plot-month-survival/plot_month_survival_survival_ml.png index e904c641..d0a9c02f 100644 Binary files a/tests/testthat/_snaps/plot-month-survival/plot_month_survival_survival_ml.png and b/tests/testthat/_snaps/plot-month-survival/plot_month_survival_survival_ml.png differ diff --git a/tests/testthat/_snaps/plot-month/plot_month_predict_0.png b/tests/testthat/_snaps/plot-month/plot_month_predict_0.png index ed31f905..f4669b0f 100644 Binary files a/tests/testthat/_snaps/plot-month/plot_month_predict_0.png and b/tests/testthat/_snaps/plot-month/plot_month_predict_0.png differ diff --git a/tests/testthat/_snaps/plot-month/plot_month_predict_1.png b/tests/testthat/_snaps/plot-month/plot_month_predict_1.png index f5bb3bbd..0ce6278a 100644 Binary files a/tests/testthat/_snaps/plot-month/plot_month_predict_1.png and b/tests/testthat/_snaps/plot-month/plot_month_predict_1.png differ diff --git a/tests/testthat/_snaps/plot-month/plot_month_predict_survival.png b/tests/testthat/_snaps/plot-month/plot_month_predict_survival.png index 82c8f976..0b4a43e3 100644 Binary files a/tests/testthat/_snaps/plot-month/plot_month_predict_survival.png and b/tests/testthat/_snaps/plot-month/plot_month_predict_survival.png differ diff --git a/tests/testthat/_snaps/plot-month/plot_month_predict_survival_ml.png b/tests/testthat/_snaps/plot-month/plot_month_predict_survival_ml.png index a1e6910d..1eac6cae 100644 Binary files a/tests/testthat/_snaps/plot-month/plot_month_predict_survival_ml.png and b/tests/testthat/_snaps/plot-month/plot_month_predict_survival_ml.png differ diff --git a/tests/testthat/_snaps/plot-month/plot_month_survival.png b/tests/testthat/_snaps/plot-month/plot_month_survival.png index 82c8f976..0b4a43e3 100644 Binary files a/tests/testthat/_snaps/plot-month/plot_month_survival.png and b/tests/testthat/_snaps/plot-month/plot_month_survival.png differ diff --git a/tests/testthat/_snaps/plot-month/plot_month_survival_ml.png b/tests/testthat/_snaps/plot-month/plot_month_survival_ml.png index a1e6910d..1eac6cae 100644 Binary files a/tests/testthat/_snaps/plot-month/plot_month_survival_ml.png and b/tests/testthat/_snaps/plot-month/plot_month_survival_ml.png differ diff --git a/tests/testthat/_snaps/plot-year-growth/plot_year_growth.png b/tests/testthat/_snaps/plot-year-growth/plot_year_growth.png index 763aff2a..20881d8e 100644 Binary files a/tests/testthat/_snaps/plot-year-growth/plot_year_growth.png and b/tests/testthat/_snaps/plot-year-growth/plot_year_growth.png differ diff --git a/tests/testthat/_snaps/plot-year-growth/plot_year_growth_ml.png b/tests/testthat/_snaps/plot-year-growth/plot_year_growth_ml.png index 6bd9514e..c7132690 100644 Binary files a/tests/testthat/_snaps/plot-year-growth/plot_year_growth_ml.png and b/tests/testthat/_snaps/plot-year-growth/plot_year_growth_ml.png differ diff --git a/tests/testthat/_snaps/plot-year-growth/plot_year_growth_multi.png b/tests/testthat/_snaps/plot-year-growth/plot_year_growth_multi.png index c273e5bc..cebf8dea 100644 Binary files a/tests/testthat/_snaps/plot-year-growth/plot_year_growth_multi.png and b/tests/testthat/_snaps/plot-year-growth/plot_year_growth_multi.png differ diff --git a/tests/testthat/_snaps/plot-year-growth/plot_year_population_change.png b/tests/testthat/_snaps/plot-year-growth/plot_year_population_change.png index bb1e8df2..b26403cf 100644 Binary files a/tests/testthat/_snaps/plot-year-growth/plot_year_population_change.png and b/tests/testthat/_snaps/plot-year-growth/plot_year_population_change.png differ diff --git a/tests/testthat/_snaps/plot-year-growth/plot_year_population_change_ml.png b/tests/testthat/_snaps/plot-year-growth/plot_year_population_change_ml.png index 4a528905..6a96c258 100644 Binary files a/tests/testthat/_snaps/plot-year-growth/plot_year_population_change_ml.png and b/tests/testthat/_snaps/plot-year-growth/plot_year_population_change_ml.png differ diff --git a/tests/testthat/_snaps/plot-year-growth/plot_year_population_change_multi.png b/tests/testthat/_snaps/plot-year-growth/plot_year_population_change_multi.png index b43595aa..e9dd4e35 100644 Binary files a/tests/testthat/_snaps/plot-year-growth/plot_year_population_change_multi.png and b/tests/testthat/_snaps/plot-year-growth/plot_year_population_change_multi.png differ diff --git a/tests/testthat/_snaps/plot-year-recruitment/dataframe.png b/tests/testthat/_snaps/plot-year-recruitment/dataframe.png index 09063aee..b18654bc 100644 Binary files a/tests/testthat/_snaps/plot-year-recruitment/dataframe.png and b/tests/testthat/_snaps/plot-year-recruitment/dataframe.png differ diff --git a/tests/testthat/_snaps/plot-year-recruitment/dataframe_ml.png b/tests/testthat/_snaps/plot-year-recruitment/dataframe_ml.png index 747b14ae..2e35f177 100644 Binary files a/tests/testthat/_snaps/plot-year-recruitment/dataframe_ml.png and b/tests/testthat/_snaps/plot-year-recruitment/dataframe_ml.png differ diff --git a/tests/testthat/_snaps/plot-year-recruitment/plot_year_recruitment_missing.png b/tests/testthat/_snaps/plot-year-recruitment/plot_year_recruitment_missing.png index b84e7e6e..1bdf07dd 100644 Binary files a/tests/testthat/_snaps/plot-year-recruitment/plot_year_recruitment_missing.png and b/tests/testthat/_snaps/plot-year-recruitment/plot_year_recruitment_missing.png differ diff --git a/tests/testthat/_snaps/plot-year-recruitment/plot_year_recruitment_multi.png b/tests/testthat/_snaps/plot-year-recruitment/plot_year_recruitment_multi.png index b42c648c..7fa038f7 100644 Binary files a/tests/testthat/_snaps/plot-year-recruitment/plot_year_recruitment_multi.png and b/tests/testthat/_snaps/plot-year-recruitment/plot_year_recruitment_multi.png differ diff --git a/tests/testthat/_snaps/plot-year-recruitment/recruitment.png b/tests/testthat/_snaps/plot-year-recruitment/recruitment.png index 09063aee..b18654bc 100644 Binary files a/tests/testthat/_snaps/plot-year-recruitment/recruitment.png and b/tests/testthat/_snaps/plot-year-recruitment/recruitment.png differ diff --git a/tests/testthat/_snaps/plot-year-recruitment/recruitment_ml.png b/tests/testthat/_snaps/plot-year-recruitment/recruitment_ml.png index 747b14ae..2e35f177 100644 Binary files a/tests/testthat/_snaps/plot-year-recruitment/recruitment_ml.png and b/tests/testthat/_snaps/plot-year-recruitment/recruitment_ml.png differ diff --git a/tests/testthat/_snaps/plot-year-survival/plot_year_survival_annual.png b/tests/testthat/_snaps/plot-year-survival/plot_year_survival_annual.png index a4b02eca..8333c9cf 100644 Binary files a/tests/testthat/_snaps/plot-year-survival/plot_year_survival_annual.png and b/tests/testthat/_snaps/plot-year-survival/plot_year_survival_annual.png differ diff --git a/tests/testthat/_snaps/plot-year-survival/plot_year_survival_missing.png b/tests/testthat/_snaps/plot-year-survival/plot_year_survival_missing.png index 02dd55cb..d6fb898b 100644 Binary files a/tests/testthat/_snaps/plot-year-survival/plot_year_survival_missing.png and b/tests/testthat/_snaps/plot-year-survival/plot_year_survival_missing.png differ diff --git a/tests/testthat/_snaps/plot-year-survival/plot_year_survival_multi.png b/tests/testthat/_snaps/plot-year-survival/plot_year_survival_multi.png index c98f8d57..d2e70293 100644 Binary files a/tests/testthat/_snaps/plot-year-survival/plot_year_survival_multi.png and b/tests/testthat/_snaps/plot-year-survival/plot_year_survival_multi.png differ diff --git a/tests/testthat/_snaps/plot-year-survival/plot_year_survival_predict_survival.png b/tests/testthat/_snaps/plot-year-survival/plot_year_survival_predict_survival.png index 659394fa..c6ab90d5 100644 Binary files a/tests/testthat/_snaps/plot-year-survival/plot_year_survival_predict_survival.png and b/tests/testthat/_snaps/plot-year-survival/plot_year_survival_predict_survival.png differ diff --git a/tests/testthat/_snaps/plot-year-survival/plot_year_survival_predict_survival_ml.png b/tests/testthat/_snaps/plot-year-survival/plot_year_survival_predict_survival_ml.png index 026cc37f..1c9c11a6 100644 Binary files a/tests/testthat/_snaps/plot-year-survival/plot_year_survival_predict_survival_ml.png and b/tests/testthat/_snaps/plot-year-survival/plot_year_survival_predict_survival_ml.png differ diff --git a/tests/testthat/_snaps/plot-year-survival/plot_year_survival_survival.png b/tests/testthat/_snaps/plot-year-survival/plot_year_survival_survival.png index 659394fa..c6ab90d5 100644 Binary files a/tests/testthat/_snaps/plot-year-survival/plot_year_survival_survival.png and b/tests/testthat/_snaps/plot-year-survival/plot_year_survival_survival.png differ diff --git a/tests/testthat/_snaps/plot-year-survival/plot_year_survival_survival_ml.png b/tests/testthat/_snaps/plot-year-survival/plot_year_survival_survival_ml.png index 026cc37f..1c9c11a6 100644 Binary files a/tests/testthat/_snaps/plot-year-survival/plot_year_survival_survival_ml.png and b/tests/testthat/_snaps/plot-year-survival/plot_year_survival_survival_ml.png differ diff --git a/tests/testthat/_snaps/plot-year-trend-calf-cow-ratio/plot_year_trend_calf_cow_ratio.png b/tests/testthat/_snaps/plot-year-trend-calf-cow-ratio/plot_year_trend_calf_cow_ratio.png index a35f11a9..2966cbaf 100644 Binary files a/tests/testthat/_snaps/plot-year-trend-calf-cow-ratio/plot_year_trend_calf_cow_ratio.png and b/tests/testthat/_snaps/plot-year-trend-calf-cow-ratio/plot_year_trend_calf_cow_ratio.png differ diff --git a/tests/testthat/_snaps/plot-year-trend-calf-cow-ratio/plot_year_trend_calf_cow_ratio_df.png b/tests/testthat/_snaps/plot-year-trend-calf-cow-ratio/plot_year_trend_calf_cow_ratio_df.png index a35f11a9..2966cbaf 100644 Binary files a/tests/testthat/_snaps/plot-year-trend-calf-cow-ratio/plot_year_trend_calf_cow_ratio_df.png and b/tests/testthat/_snaps/plot-year-trend-calf-cow-ratio/plot_year_trend_calf_cow_ratio_df.png differ diff --git a/tests/testthat/_snaps/plot-year-trend-recruitment/plot_year_trend_0.png b/tests/testthat/_snaps/plot-year-trend-recruitment/plot_year_trend_0.png index bfc4b876..5e1901c2 100644 Binary files a/tests/testthat/_snaps/plot-year-trend-recruitment/plot_year_trend_0.png and b/tests/testthat/_snaps/plot-year-trend-recruitment/plot_year_trend_0.png differ diff --git a/tests/testthat/_snaps/plot-year-trend-recruitment/plot_year_trend_recruitment.png b/tests/testthat/_snaps/plot-year-trend-recruitment/plot_year_trend_recruitment.png index ec7c636c..f985fb83 100644 Binary files a/tests/testthat/_snaps/plot-year-trend-recruitment/plot_year_trend_recruitment.png and b/tests/testthat/_snaps/plot-year-trend-recruitment/plot_year_trend_recruitment.png differ diff --git a/tests/testthat/_snaps/plot-year-trend-recruitment/plot_year_trend_recruitment_df.png b/tests/testthat/_snaps/plot-year-trend-recruitment/plot_year_trend_recruitment_df.png index ec7c636c..f985fb83 100644 Binary files a/tests/testthat/_snaps/plot-year-trend-recruitment/plot_year_trend_recruitment_df.png and b/tests/testthat/_snaps/plot-year-trend-recruitment/plot_year_trend_recruitment_df.png differ diff --git a/tests/testthat/_snaps/plot-year-trend-recruitment/plot_year_trend_recruitment_ml.png b/tests/testthat/_snaps/plot-year-trend-recruitment/plot_year_trend_recruitment_ml.png index c6cbd79b..c252da87 100644 Binary files a/tests/testthat/_snaps/plot-year-trend-recruitment/plot_year_trend_recruitment_ml.png and b/tests/testthat/_snaps/plot-year-trend-recruitment/plot_year_trend_recruitment_ml.png differ diff --git a/tests/testthat/_snaps/plot-year-trend-recruitment/plot_year_trend_recruitment_ml_df.png b/tests/testthat/_snaps/plot-year-trend-recruitment/plot_year_trend_recruitment_ml_df.png index c6cbd79b..c252da87 100644 Binary files a/tests/testthat/_snaps/plot-year-trend-recruitment/plot_year_trend_recruitment_ml_df.png and b/tests/testthat/_snaps/plot-year-trend-recruitment/plot_year_trend_recruitment_ml_df.png differ diff --git a/tests/testthat/_snaps/plot-year-trend-survival/plot_year_trend_survival.png b/tests/testthat/_snaps/plot-year-trend-survival/plot_year_trend_survival.png index 3fe86c8a..79caeced 100644 Binary files a/tests/testthat/_snaps/plot-year-trend-survival/plot_year_trend_survival.png and b/tests/testthat/_snaps/plot-year-trend-survival/plot_year_trend_survival.png differ diff --git a/tests/testthat/_snaps/plot-year-trend-survival/plot_year_trend_survival_df.png b/tests/testthat/_snaps/plot-year-trend-survival/plot_year_trend_survival_df.png index 3fe86c8a..79caeced 100644 Binary files a/tests/testthat/_snaps/plot-year-trend-survival/plot_year_trend_survival_df.png and b/tests/testthat/_snaps/plot-year-trend-survival/plot_year_trend_survival_df.png differ diff --git a/tests/testthat/_snaps/plot-year-trend-survival/plot_year_trend_survival_ml.png b/tests/testthat/_snaps/plot-year-trend-survival/plot_year_trend_survival_ml.png index 50309a73..ba667ab9 100644 Binary files a/tests/testthat/_snaps/plot-year-trend-survival/plot_year_trend_survival_ml.png and b/tests/testthat/_snaps/plot-year-trend-survival/plot_year_trend_survival_ml.png differ diff --git a/tests/testthat/_snaps/plot-year-trend-survival/plot_year_trend_survival_ml_df.png b/tests/testthat/_snaps/plot-year-trend-survival/plot_year_trend_survival_ml_df.png index 50309a73..ba667ab9 100644 Binary files a/tests/testthat/_snaps/plot-year-trend-survival/plot_year_trend_survival_ml_df.png and b/tests/testthat/_snaps/plot-year-trend-survival/plot_year_trend_survival_ml_df.png differ diff --git a/tests/testthat/_snaps/plot-year/plot_year_multi.png b/tests/testthat/_snaps/plot-year/plot_year_multi.png index cfa1f219..48d6e6e2 100644 Binary files a/tests/testthat/_snaps/plot-year/plot_year_multi.png and b/tests/testthat/_snaps/plot-year/plot_year_multi.png differ diff --git a/tests/testthat/_snaps/plot-year/plot_year_predict_0.png b/tests/testthat/_snaps/plot-year/plot_year_predict_0.png index 698b7714..87e00887 100644 Binary files a/tests/testthat/_snaps/plot-year/plot_year_predict_0.png and b/tests/testthat/_snaps/plot-year/plot_year_predict_0.png differ diff --git a/tests/testthat/_snaps/plot-year/plot_year_predict_1.png b/tests/testthat/_snaps/plot-year/plot_year_predict_1.png index df5efb6f..9e626806 100644 Binary files a/tests/testthat/_snaps/plot-year/plot_year_predict_1.png and b/tests/testthat/_snaps/plot-year/plot_year_predict_1.png differ diff --git a/tests/testthat/_snaps/plot-year/plot_year_predict_survival.png b/tests/testthat/_snaps/plot-year/plot_year_predict_survival.png index 2aeeefa1..8fc060f6 100644 Binary files a/tests/testthat/_snaps/plot-year/plot_year_predict_survival.png and b/tests/testthat/_snaps/plot-year/plot_year_predict_survival.png differ diff --git a/tests/testthat/_snaps/plot-year/plot_year_predict_survival_ml.png b/tests/testthat/_snaps/plot-year/plot_year_predict_survival_ml.png index 70b09b80..0cf772aa 100644 Binary files a/tests/testthat/_snaps/plot-year/plot_year_predict_survival_ml.png and b/tests/testthat/_snaps/plot-year/plot_year_predict_survival_ml.png differ diff --git a/tests/testthat/_snaps/plot-year/plot_year_recruitment.png b/tests/testthat/_snaps/plot-year/plot_year_recruitment.png index 3f0b07b3..1fc03270 100644 Binary files a/tests/testthat/_snaps/plot-year/plot_year_recruitment.png and b/tests/testthat/_snaps/plot-year/plot_year_recruitment.png differ diff --git a/tests/testthat/_snaps/plot-year/plot_year_recruitment_ml.png b/tests/testthat/_snaps/plot-year/plot_year_recruitment_ml.png index b7d0f124..366687a3 100644 Binary files a/tests/testthat/_snaps/plot-year/plot_year_recruitment_ml.png and b/tests/testthat/_snaps/plot-year/plot_year_recruitment_ml.png differ diff --git a/tests/testthat/_snaps/plot-year/plot_year_survival.png b/tests/testthat/_snaps/plot-year/plot_year_survival.png index 2aeeefa1..8fc060f6 100644 Binary files a/tests/testthat/_snaps/plot-year/plot_year_survival.png and b/tests/testthat/_snaps/plot-year/plot_year_survival.png differ diff --git a/tests/testthat/_snaps/plot-year/plot_year_survival_ml.png b/tests/testthat/_snaps/plot-year/plot_year_survival_ml.png index 70b09b80..0cf772aa 100644 Binary files a/tests/testthat/_snaps/plot-year/plot_year_survival_ml.png and b/tests/testthat/_snaps/plot-year/plot_year_survival_ml.png differ diff --git a/tests/testthat/_snaps/prior-only/recruitment_pred_prior_only.csv b/tests/testthat/_snaps/prior-only/recruitment_pred_prior_only.csv index 41d091ef..56902363 100644 --- a/tests/testthat/_snaps/prior-only/recruitment_pred_prior_only.csv +++ b/tests/testthat/_snaps/prior-only/recruitment_pred_prior_only.csv @@ -1,4 +1,4 @@ PopulationName,CaribouYear,Month,estimate,lower,upper -A,2020,NA,0.112,0.0485,0.201 -A,2021,NA,0.0522,0.021,0.116 -A,2022,NA,0.0208,0.00716,0.0555 +A,2019,NA,0.112,0.0485,0.201 +A,2020,NA,0.0522,0.021,0.116 +A,2021,NA,0.0208,0.00716,0.0555 diff --git a/tests/testthat/test-prior-only.R b/tests/testthat/test-prior-only.R index 84602a9b..112ce8c7 100644 --- a/tests/testthat/test-prior-only.R +++ b/tests/testthat/test-prior-only.R @@ -129,7 +129,8 @@ test_that("bb_fit_recruitment works with prior-only data", { pred <- bb_predict_recruitment(fit) expect_s3_class(pred, "tbl_df") expect_gt(nrow(pred), 0) - expect_true(all(pred$CaribouYear %in% 2020:2022)) + # CaribouYear is one less than year because recruitment survey happens spring after + expect_true(all(pred$CaribouYear %in% 2019:2021)) expect_snapshot_data(pred, "recruitment_pred_prior_only") })