R/demographicRates.R
, R/sampleRates.R
demographicRates.Rd
Apply the sampled coefficients to the disturbance covariates
to calculate expected recruitment and survival according to the beta
regression models estimated by Johnson et al. (2020).demographicRates
is a wrapper
around sampleRates
to sample both survival and recruitment rates based on
the result of demographicCoefficients()
and using recommended defaults.
demographicRates(
covTable,
popGrowthPars,
ignorePrecision = FALSE,
returnSample = FALSE,
useQuantiles = TRUE,
predInterval = list(PI_R = c(0.025, 0.975), PI_S = c(0.025, 0.975)),
transformFns = list(S_transform = function(y) {
(y * 46 - 0.5)/45
}, R_transform
= function(y) {
y
})
)
sampleRates(
covTable,
coefSamples,
coefValues,
modelVersion,
resVar,
ignorePrecision,
returnSample,
quantilesToUse = NULL,
predInterval = c(0.025, 0.975),
transformFn = function(y) {
y
}
)
data.frame. A table of covariate values to be used. Column names must match the coefficient names in popGrowthTableJohnsonECCC. Each row is a different scenario.
list. Coefficient values and (optionally) quantiles
returned by demographicCoefficients
.
logical. Should the precision of the model be used if it is available? When precision is used variation among populations around the National mean responses is considered in addition to the uncertainty about the coefficient estimates.
logical. If TRUE the returned data.frame has replicates * scenarios rows. If FALSE the returned data.frame has one row per scenario and additional columns summarizing the variation among replicates. See Value for details.
logical or numeric. If it is a numeric vector it must be
length 2 and give the low and high limits of the quantiles to use. Only
relevant when ignorePrecision = FALSE
. If useQuantiles != FALSE
, each
replicate population is assigned to a quantile of the distribution of
variation around the expected values, and remains in that quantile as
covariates change. If useQuantiles != FALSE
and popGrowthPars contains
quantiles, those quantiles will be used. If useQuantiles = TRUE
and
popGrowthPars does not contain quantiles, replicate populations will be
assigned to quantiles in the default range of 0.025 and 0.975. If
useQuantiles = FALSE
, sampling is done independently for each combination
of scenario and replicate, so the value for a particular replicate
population in one scenario is unrelated to the values for that replicate in
other scenarios. Useful for projecting impacts of changing disturbance on
the trajectories of replicate populations.
numeric vector with length 2. The default 95% interval
is (c(0.025,0.975)
). Only relevant when returnSample = TRUE
and
quantilesToUse = NULL
.
list of functions used to transform demographic rates.
The default is list(S_transform = function(y){(y*46-0.5)/45},R_transform = function(y){y})
. The back transformation is applied to survival rates as
in Johnson et al. 2020.
matrix. Bootstrapped coefficients with one row per replicate and one column per coefficient
data.table. One row table with expected values for each coefficient
character. Which model version to use. Currently the only option is "Johnson" for the model used in Johnson et. al. (2020), but additional options may be added in the future.
character. Response variable, typically "femaleSurvival" or "recruitment"
numeric vector of length coefSamples
. See useQuantiles
.
function used to transform demographic rates.
A data.frame of predictions. The data.frame includes all columns in
covTable
with additional columns depending on returnSample
.
If returnSample = FALSE
the number of rows is the same as the number of
rows in covTable
, additional columns are:
"S_bar" and "R_bar": The mean estimated values of survival and recruitment (calves per cow)
"S_stdErr" and "R_stdErr": Standard error of the estimated values
"S_PIlow"/"S_PIhigh" and "R_PIlow"/"R_PIhigh": If not using quantiles, 95\ minimum values are returned.
If returnSample = TRUE
the number of rows is nrow(covTable) * replicates
additional columns are:
"scnID": A unique identifier for scenarios provided in
covTable
"replicate": A replicate identifier, unique within each scenario
"S_bar" and "R_bar": The expected values of survival and recruitment (calves per cow)
For sampleRates
a similar data frame for one response variable
Each population is optionally assigned to quantiles of the Beta error distributions for survival and recruitment. Using quantiles means that the population will stay in these quantiles as disturbance changes over time, so there is persistent variation in recruitment and survival among example populations.
A transformation function is also applied to survival to avoid survival probabilities of 1.
A detailed description of the model is available in Hughes et al. (2025)
Hughes, J., Endicott, S., Calvert, A.M. and Johnson, C.A., 2025. Integration of national demographic-disturbance relationships and local data can improve caribou population viability projections and inform monitoring decisions. Ecological Informatics, 87, p.103095. https://doi.org/10.1016/j.ecoinf.2025.103095
Johnson, C.A., Sutherland, G.D., Neave, E., Leblond, M., Kirby, P., Superbie, C. and McLoughlin, P.D., 2020. Science to inform policy: linking population dynamics to habitat for a threatened species in Canada. Journal of Applied Ecology, 57(7), pp.1314-1327. https://doi.org/10.1111/1365-2664.13637
Caribou demography functions:
caribouBayesianPM()
,
caribouPopGrowth()
,
compositionBiasCorrection()
,
demographicCoefficients()
,
demographicProjectionApp()
,
getOutputTables()
,
getPriors()
,
getScenarioDefaults()
,
getSimsNational()
,
plotRes()
,
popGrowthTableJohnsonECCC
,
runScnSet()
,
simulateObservations()
# get coefficient samples
coefs <- demographicCoefficients(10)
# table of different scenarios to test
covTableSim <- expand.grid(Anthro = seq(0, 90, by = 20),
fire_excl_anthro = seq(0, 70, by = 20))
covTableSim$Total_dist = covTableSim$Anthro + covTableSim$fire_excl_anthro
demographicRates(covTableSim, coefs)
#> popGrowthPars contains quantiles so they are used instead of the defaults
#> popGrowthPars contains quantiles so they are used instead of the defaults
#> Anthro fire_excl_anthro Total_dist S_bar S_stdErr S_PIlow S_PIhigh
#> 1 0 0 0 0.8757906 0.05112588 0.7829516 0.9562421
#> 2 0 20 20 0.8757906 0.05112588 0.7829516 0.9562421
#> 3 0 40 40 0.8757906 0.05112588 0.7829516 0.9562421
#> 4 0 60 60 0.8757906 0.05112588 0.7829516 0.9562421
#> 5 20 0 20 0.8617131 0.05398541 0.7664890 0.9472085
#> 6 20 20 40 0.8617131 0.05398541 0.7664890 0.9472085
#> 7 20 40 60 0.8617131 0.05398541 0.7664890 0.9472085
#> 8 20 60 80 0.8617131 0.05398541 0.7664890 0.9472085
#> 9 40 0 40 0.8478591 0.05666531 0.7505536 0.9379860
#> 10 40 20 60 0.8478591 0.05666531 0.7505536 0.9379860
#> 11 40 40 80 0.8478591 0.05666531 0.7505536 0.9379860
#> 12 40 60 100 0.8478591 0.05666531 0.7505536 0.9379860
#> 13 60 0 60 0.8342249 0.05918083 0.7350979 0.9286268
#> 14 60 20 80 0.8342249 0.05918083 0.7350979 0.9286268
#> 15 60 40 100 0.8342249 0.05918083 0.7350979 0.9286268
#> 16 60 60 120 0.8342249 0.05918083 0.7350979 0.9286268
#> 17 80 0 80 0.8208071 0.06154519 0.7200837 0.9191709
#> 18 80 20 100 0.8208071 0.06154519 0.7200837 0.9191709
#> 19 80 40 120 0.8208071 0.06154519 0.7200837 0.9191709
#> 20 80 60 140 0.8208071 0.06154519 0.7200837 0.9191709
#> R_bar R_stdErr R_PIlow R_PIhigh
#> 1 0.35951478 0.12568548 0.135930484 0.5408642
#> 2 0.30574618 0.11858848 0.116476609 0.5128341
#> 3 0.26001915 0.11389136 0.099452373 0.4863481
#> 4 0.22113100 0.11057113 0.084578689 0.4613409
#> 5 0.25589195 0.11474545 0.068138685 0.4286601
#> 6 0.21762106 0.10735767 0.057318636 0.4069211
#> 7 0.18507391 0.10191563 0.047945539 0.3864248
#> 8 0.15739448 0.09771470 0.039855377 0.3671029
#> 9 0.18213629 0.10156486 0.031059747 0.3418804
#> 10 0.15489621 0.09460101 0.025384154 0.3251112
#> 11 0.13173012 0.08920783 0.020565044 0.3093000
#> 12 0.11202872 0.08488074 0.016500158 0.2943889
#> 13 0.12963921 0.08821155 0.012212993 0.2749066
#> 14 0.11025053 0.08195882 0.009543772 0.2619366
#> 15 0.09376159 0.07697176 0.007357009 0.2496901
#> 16 0.07973872 0.07287895 0.005586222 0.2381211
#> 17 0.09227334 0.07570845 0.003815688 0.2229694
#> 18 0.07847305 0.07024486 0.002780375 0.2128545
#> 19 0.06673672 0.06579827 0.001983404 0.2032793
#> 20 0.05675565 0.06208960 0.001381999 0.1942084
cfs <- getCoefs(popGrowthTableJohnsonECCC, "recruitment", "Johnson", "M3")
cfSamps <- sampleCoefs(cfs[[1]], 10)
# disturbance scenarios
distScen <- data.frame(Total_dist = 1:10/10)
# return summary across replicates
sampleRates(distScen, cfSamps$coefSamples, cfSamps$coefValues,
"Johnson", "recruitment", ignorePrecision = TRUE,
returnSample = FALSE)
#> Total_dist average stdErr PIlow PIhigh
#> 1 0.1 0.3838513 0.02265521 0.3375346 0.4056440
#> 2 0.2 0.3832760 0.02260227 0.3370401 0.4050615
#> 3 0.3 0.3827015 0.02254960 0.3365463 0.4044799
#> 4 0.4 0.3821279 0.02249718 0.3360532 0.4038990
#> 5 0.5 0.3815551 0.02244502 0.3355609 0.4033191
#> 6 0.6 0.3809832 0.02239312 0.3350693 0.4027399
#> 7 0.7 0.3804122 0.02234149 0.3345784 0.4021616
#> 8 0.8 0.3798420 0.02229011 0.3340882 0.4015842
#> 9 0.9 0.3792726 0.02223899 0.3335988 0.4010075
#> 10 1.0 0.3787041 0.02218813 0.3331101 0.4004317
# return one row per replicate * scenario
sampleRates(distScen, cfSamps$coefSamples, cfSamps$coefValues,
"Johnson", "recruitment", ignorePrecision = TRUE,
returnSample = TRUE)
#> scnID Total_dist replicate value
#> 1 1 0.1 V1 0.4058696
#> 2 1 0.1 V5 0.3508252
#> 3 1 0.1 V9 0.3974717
#> 4 1 0.1 V3 0.3816533
#> 5 1 0.1 V4 0.3336761
#> 6 1 0.1 V8 0.3757682
#> 7 1 0.1 V2 0.3790394
#> 8 1 0.1 V6 0.4048670
#> 9 1 0.1 V7 0.3834037
#> 10 1 0.1 V10 0.3775554
#> 11 2 0.2 V7 0.3827928
#> 12 2 0.2 V8 0.3752259
#> 13 2 0.2 V9 0.3968384
#> 14 2 0.2 V10 0.3770056
#> 15 2 0.2 V1 0.4053196
#> 16 2 0.2 V5 0.3503846
#> 17 2 0.2 V2 0.3784911
#> 18 2 0.2 V3 0.3809682
#> 19 2 0.2 V4 0.3331659
#> 20 2 0.2 V6 0.4041727
#> 21 3 0.3 V4 0.3326565
#> 22 3 0.3 V5 0.3499446
#> 23 3 0.3 V3 0.3802844
#> 24 3 0.3 V7 0.3821828
#> 25 3 0.3 V8 0.3746844
#> 26 3 0.3 V9 0.3962062
#> 27 3 0.3 V6 0.4034795
#> 28 3 0.3 V10 0.3764566
#> 29 3 0.3 V1 0.4047703
#> 30 3 0.3 V2 0.3779435
#> 31 4 0.4 V1 0.4042217
#> 32 4 0.4 V9 0.3955749
#> 33 4 0.4 V3 0.3796018
#> 34 4 0.4 V4 0.3321478
#> 35 4 0.4 V5 0.3495052
#> 36 4 0.4 V2 0.3773968
#> 37 4 0.4 V6 0.4027875
#> 38 4 0.4 V7 0.3815738
#> 39 4 0.4 V8 0.3741436
#> 40 4 0.4 V10 0.3759083
#> 41 5 0.5 V8 0.3736037
#> 42 5 0.5 V9 0.3949447
#> 43 5 0.5 V10 0.3753609
#> 44 5 0.5 V1 0.4036739
#> 45 5 0.5 V5 0.3490663
#> 46 5 0.5 V2 0.3768509
#> 47 5 0.5 V3 0.3789204
#> 48 5 0.5 V4 0.3316400
#> 49 5 0.5 V6 0.4020967
#> 50 5 0.5 V7 0.3809658
#> 51 6 0.6 V4 0.3311329
#> 52 6 0.6 V5 0.3486280
#> 53 6 0.6 V7 0.3803588
#> 54 6 0.6 V8 0.3730645
#> 55 6 0.6 V9 0.3943155
#> 56 6 0.6 V6 0.4014071
#> 57 6 0.6 V10 0.3748143
#> 58 6 0.6 V1 0.4031269
#> 59 6 0.6 V2 0.3763058
#> 60 6 0.6 V3 0.3782402
#> 61 7 0.7 V1 0.4025805
#> 62 7 0.7 V3 0.3775613
#> 63 7 0.7 V4 0.3306266
#> 64 7 0.7 V5 0.3481902
#> 65 7 0.7 V9 0.3936873
#> 66 7 0.7 V6 0.4007186
#> 67 7 0.7 V7 0.3797527
#> 68 7 0.7 V8 0.3725261
#> 69 7 0.7 V2 0.3757614
#> 70 7 0.7 V10 0.3742684
#> 71 8 0.8 V9 0.3930601
#> 72 8 0.8 V10 0.3737234
#> 73 8 0.8 V1 0.4020350
#> 74 8 0.8 V5 0.3477530
#> 75 8 0.8 V2 0.3752178
#> 76 8 0.8 V3 0.3768836
#> 77 8 0.8 V4 0.3301211
#> 78 8 0.8 V8 0.3719885
#> 79 8 0.8 V6 0.4000314
#> 80 8 0.8 V7 0.3791476
#> 81 9 0.9 V5 0.3473163
#> 82 9 0.9 V7 0.3785434
#> 83 9 0.9 V8 0.3714516
#> 84 9 0.9 V9 0.3924339
#> 85 9 0.9 V6 0.3993453
#> 86 9 0.9 V10 0.3731791
#> 87 9 0.9 V1 0.4014901
#> 88 9 0.9 V2 0.3746751
#> 89 9 0.9 V3 0.3762071
#> 90 9 0.9 V4 0.3296163
#> 91 10 1.0 V1 0.4009460
#> 92 10 1.0 V4 0.3291123
#> 93 10 1.0 V5 0.3468802
#> 94 10 1.0 V9 0.3918086
#> 95 10 1.0 V3 0.3755318
#> 96 10 1.0 V7 0.3779403
#> 97 10 1.0 V8 0.3709155
#> 98 10 1.0 V2 0.3741331
#> 99 10 1.0 V6 0.3986604
#> 100 10 1.0 V10 0.3726356
# return one row per replicate * scenario with replicates assigned to a quantile
sampleRates(distScen, cfSamps$coefSamples, cfSamps$coefValues,
"Johnson", "recruitment", ignorePrecision = TRUE,
returnSample = TRUE,
quantilesToUse = quantile(x = c(0, 1),
probs = seq(0.025, 0.975, length.out = 10)))
#> scnID Total_dist replicate value
#> 1 1 0.1 V1 0.4058696
#> 2 1 0.1 V5 0.3508252
#> 3 1 0.1 V9 0.3974717
#> 4 1 0.1 V3 0.3816533
#> 5 1 0.1 V4 0.3336761
#> 6 1 0.1 V8 0.3757682
#> 7 1 0.1 V2 0.3790394
#> 8 1 0.1 V6 0.4048670
#> 9 1 0.1 V7 0.3834037
#> 10 1 0.1 V10 0.3775554
#> 11 2 0.2 V7 0.3827928
#> 12 2 0.2 V8 0.3752259
#> 13 2 0.2 V9 0.3968384
#> 14 2 0.2 V10 0.3770056
#> 15 2 0.2 V1 0.4053196
#> 16 2 0.2 V5 0.3503846
#> 17 2 0.2 V2 0.3784911
#> 18 2 0.2 V3 0.3809682
#> 19 2 0.2 V4 0.3331659
#> 20 2 0.2 V6 0.4041727
#> 21 3 0.3 V4 0.3326565
#> 22 3 0.3 V5 0.3499446
#> 23 3 0.3 V3 0.3802844
#> 24 3 0.3 V7 0.3821828
#> 25 3 0.3 V8 0.3746844
#> 26 3 0.3 V9 0.3962062
#> 27 3 0.3 V6 0.4034795
#> 28 3 0.3 V10 0.3764566
#> 29 3 0.3 V1 0.4047703
#> 30 3 0.3 V2 0.3779435
#> 31 4 0.4 V1 0.4042217
#> 32 4 0.4 V9 0.3955749
#> 33 4 0.4 V3 0.3796018
#> 34 4 0.4 V4 0.3321478
#> 35 4 0.4 V5 0.3495052
#> 36 4 0.4 V2 0.3773968
#> 37 4 0.4 V6 0.4027875
#> 38 4 0.4 V7 0.3815738
#> 39 4 0.4 V8 0.3741436
#> 40 4 0.4 V10 0.3759083
#> 41 5 0.5 V8 0.3736037
#> 42 5 0.5 V9 0.3949447
#> 43 5 0.5 V10 0.3753609
#> 44 5 0.5 V1 0.4036739
#> 45 5 0.5 V5 0.3490663
#> 46 5 0.5 V2 0.3768509
#> 47 5 0.5 V3 0.3789204
#> 48 5 0.5 V4 0.3316400
#> 49 5 0.5 V6 0.4020967
#> 50 5 0.5 V7 0.3809658
#> 51 6 0.6 V4 0.3311329
#> 52 6 0.6 V5 0.3486280
#> 53 6 0.6 V7 0.3803588
#> 54 6 0.6 V8 0.3730645
#> 55 6 0.6 V9 0.3943155
#> 56 6 0.6 V6 0.4014071
#> 57 6 0.6 V10 0.3748143
#> 58 6 0.6 V1 0.4031269
#> 59 6 0.6 V2 0.3763058
#> 60 6 0.6 V3 0.3782402
#> 61 7 0.7 V1 0.4025805
#> 62 7 0.7 V3 0.3775613
#> 63 7 0.7 V4 0.3306266
#> 64 7 0.7 V5 0.3481902
#> 65 7 0.7 V9 0.3936873
#> 66 7 0.7 V6 0.4007186
#> 67 7 0.7 V7 0.3797527
#> 68 7 0.7 V8 0.3725261
#> 69 7 0.7 V2 0.3757614
#> 70 7 0.7 V10 0.3742684
#> 71 8 0.8 V9 0.3930601
#> 72 8 0.8 V10 0.3737234
#> 73 8 0.8 V1 0.4020350
#> 74 8 0.8 V5 0.3477530
#> 75 8 0.8 V2 0.3752178
#> 76 8 0.8 V3 0.3768836
#> 77 8 0.8 V4 0.3301211
#> 78 8 0.8 V8 0.3719885
#> 79 8 0.8 V6 0.4000314
#> 80 8 0.8 V7 0.3791476
#> 81 9 0.9 V5 0.3473163
#> 82 9 0.9 V7 0.3785434
#> 83 9 0.9 V8 0.3714516
#> 84 9 0.9 V9 0.3924339
#> 85 9 0.9 V6 0.3993453
#> 86 9 0.9 V10 0.3731791
#> 87 9 0.9 V1 0.4014901
#> 88 9 0.9 V2 0.3746751
#> 89 9 0.9 V3 0.3762071
#> 90 9 0.9 V4 0.3296163
#> 91 10 1.0 V1 0.4009460
#> 92 10 1.0 V4 0.3291123
#> 93 10 1.0 V5 0.3468802
#> 94 10 1.0 V9 0.3918086
#> 95 10 1.0 V3 0.3755318
#> 96 10 1.0 V7 0.3779403
#> 97 10 1.0 V8 0.3709155
#> 98 10 1.0 V2 0.3741331
#> 99 10 1.0 V6 0.3986604
#> 100 10 1.0 V10 0.3726356