Sample expected survival and recruitment rates
Source: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.
Usage
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
}
)
Arguments
- covTable
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.
- popGrowthPars
list. Coefficient values and (optionally) quantiles returned by
demographicCoefficients
.- ignorePrecision
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.
- returnSample
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.
- useQuantiles
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
. IfuseQuantiles != 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. IfuseQuantiles != FALSE
and popGrowthPars contains quantiles, those quantiles will be used. IfuseQuantiles = TRUE
and popGrowthPars does not contain quantiles, replicate populations will be assigned to quantiles in the default range of 0.025 and 0.975. IfuseQuantiles = 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.- predInterval
numeric vector with length 2. The default 95% interval is (
c(0.025,0.975)
). Only relevant whenreturnSample = TRUE
andquantilesToUse = NULL
.- transformFns
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.- coefSamples
matrix. Bootstrapped coefficients with one row per replicate and one column per coefficient
- coefValues
data.table. One row table with expected values for each coefficient
- modelVersion
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.
- resVar
character. Response variable, typically "femaleSurvival" or "recruitment"
- quantilesToUse
numeric vector of length
coefSamples
. SeeuseQuantiles
.- transformFn
function used to transform demographic rates.
Value
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
Details
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)
References
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
See also
Caribou demography functions:
bbouMakeSummaryTable()
,
caribouBayesianPM()
,
caribouPopGrowth()
,
caribouPopSimMCMC()
,
compositionBiasCorrection()
,
demographicCoefficients()
,
demographicProjectionApp()
,
doSim()
,
getBBNationalInformativePriors()
,
getOutputTables()
,
getPriors()
,
getScenarioDefaults()
,
getSimsInitial()
,
getSimsNational()
,
plotRes()
,
popGrowthTableJohnsonECCC
,
runScnSet()
,
simulateObservations()
Examples
# 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.04654963 0.7905754 0.9495346
#> 2 0 20 20 0.8757906 0.04654963 0.7905754 0.9495346
#> 3 0 40 40 0.8757906 0.04654963 0.7905754 0.9495346
#> 4 0 60 60 0.8757906 0.04654963 0.7905754 0.9495346
#> 5 20 0 20 0.8617131 0.04798871 0.7774838 0.9404459
#> 6 20 20 40 0.8617131 0.04798871 0.7774838 0.9404459
#> 7 20 40 60 0.8617131 0.04798871 0.7774838 0.9404459
#> 8 20 60 80 0.8617131 0.04798871 0.7774838 0.9404459
#> 9 40 0 40 0.8478591 0.04935903 0.7647304 0.9312088
#> 10 40 20 60 0.8478591 0.04935903 0.7647304 0.9312088
#> 11 40 40 80 0.8478591 0.04935903 0.7647304 0.9312088
#> 12 40 60 100 0.8478591 0.04935903 0.7647304 0.9312088
#> 13 60 0 60 0.8342249 0.05066770 0.7522892 0.9218652
#> 14 60 20 80 0.8342249 0.05066770 0.7522892 0.9218652
#> 15 60 40 100 0.8342249 0.05066770 0.7522892 0.9218652
#> 16 60 60 120 0.8342249 0.05066770 0.7522892 0.9218652
#> 17 80 0 80 0.8208071 0.05192020 0.7401389 0.9124479
#> 18 80 20 100 0.8208071 0.05192020 0.7401389 0.9124479
#> 19 80 40 120 0.8208071 0.05192020 0.7401389 0.9124479
#> 20 80 60 140 0.8208071 0.05192020 0.7401389 0.9124479
#> R_bar R_stdErr R_PIlow R_PIhigh
#> 1 0.35951478 0.11920267 0.162882200 0.5599421
#> 2 0.30574618 0.11919356 0.123790687 0.5222821
#> 3 0.26001915 0.11823614 0.093065035 0.4872649
#> 4 0.22113100 0.11629038 0.069040792 0.4547491
#> 5 0.25589195 0.10371652 0.092520403 0.4375893
#> 6 0.21762106 0.10210155 0.068616491 0.4086753
#> 7 0.18507391 0.09993783 0.050071393 0.3818779
#> 8 0.15739448 0.09722493 0.035831780 0.3570503
#> 9 0.18213629 0.08912585 0.049745529 0.3439634
#> 10 0.15489621 0.08673396 0.035583219 0.3219282
#> 11 0.13173012 0.08405138 0.024858020 0.3015147
#> 12 0.11202872 0.08108984 0.016876476 0.2826000
#> 13 0.12963921 0.07592356 0.024672438 0.2726261
#> 14 0.11025053 0.07324690 0.016739889 0.2558214
#> 15 0.09376159 0.07044207 0.010970183 0.2402352
#> 16 0.07973872 0.06752219 0.006892490 0.2257712
#> 17 0.09227334 0.06426040 0.010872872 0.2181332
#> 18 0.07847305 0.06158255 0.006824966 0.2052430
#> 19 0.06673672 0.05887561 0.004069388 0.1932587
#> 20 0.05675565 0.05614990 0.002279365 0.1821068
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.02739765 0.3343804 0.4128846
#> 2 0.2 0.3832760 0.02735340 0.3338204 0.4121826
#> 3 0.3 0.3827015 0.02730928 0.3332612 0.4114818
#> 4 0.4 0.3821279 0.02726530 0.3327030 0.4107821
#> 5 0.5 0.3815551 0.02722145 0.3321458 0.4100837
#> 6 0.6 0.3809832 0.02717773 0.3315895 0.4093865
#> 7 0.7 0.3804122 0.02713414 0.3310341 0.4086904
#> 8 0.8 0.3798420 0.02709068 0.3304796 0.4079956
#> 9 0.9 0.3792726 0.02704735 0.3299261 0.4073019
#> 10 1.0 0.3787041 0.02700416 0.3293735 0.4066094
# 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.3744903
#> 2 1 0.1 V5 0.3996555
#> 3 1 0.1 V9 0.3561267
#> 4 1 0.1 V3 0.3654873
#> 5 1 0.1 V4 0.4074972
#> 6 1 0.1 V8 0.3306614
#> 7 1 0.1 V2 0.4144487
#> 8 1 0.1 V6 0.3471904
#> 9 1 0.1 V7 0.3924705
#> 10 1 0.1 V10 0.3680859
#> 11 2 0.2 V7 0.3919006
#> 12 2 0.2 V8 0.3300911
#> 13 2 0.2 V9 0.3555947
#> 14 2 0.2 V10 0.3674978
#> 15 2 0.2 V1 0.3739467
#> 16 2 0.2 V5 0.3990626
#> 17 2 0.2 V2 0.4137289
#> 18 2 0.2 V3 0.3649560
#> 19 2 0.2 V4 0.4068563
#> 20 2 0.2 V6 0.3466655
#> 21 3 0.3 V4 0.4062165
#> 22 3 0.3 V5 0.3984707
#> 23 3 0.3 V3 0.3644255
#> 24 3 0.3 V7 0.3913315
#> 25 3 0.3 V8 0.3295218
#> 26 3 0.3 V9 0.3550635
#> 27 3 0.3 V6 0.3461413
#> 28 3 0.3 V10 0.3669105
#> 29 3 0.3 V1 0.3734040
#> 30 3 0.3 V2 0.4130104
#> 31 4 0.4 V1 0.3728620
#> 32 4 0.4 V9 0.3545332
#> 33 4 0.4 V3 0.3638957
#> 34 4 0.4 V4 0.4055776
#> 35 4 0.4 V5 0.3978796
#> 36 4 0.4 V2 0.4122931
#> 37 4 0.4 V6 0.3456180
#> 38 4 0.4 V7 0.3907632
#> 39 4 0.4 V8 0.3289535
#> 40 4 0.4 V10 0.3663242
#> 41 5 0.5 V8 0.3283862
#> 42 5 0.5 V9 0.3540036
#> 43 5 0.5 V10 0.3657389
#> 44 5 0.5 V1 0.3723208
#> 45 5 0.5 V5 0.3972894
#> 46 5 0.5 V2 0.4115771
#> 47 5 0.5 V3 0.3633667
#> 48 5 0.5 V4 0.4049398
#> 49 5 0.5 V6 0.3450954
#> 50 5 0.5 V7 0.3901957
#> 51 6 0.6 V4 0.4043029
#> 52 6 0.6 V5 0.3967000
#> 53 6 0.6 V7 0.3896291
#> 54 6 0.6 V8 0.3278199
#> 55 6 0.6 V9 0.3534748
#> 56 6 0.6 V6 0.3445736
#> 57 6 0.6 V10 0.3651544
#> 58 6 0.6 V1 0.3717804
#> 59 6 0.6 V2 0.4108623
#> 60 6 0.6 V3 0.3628385
#> 61 7 0.7 V1 0.3712408
#> 62 7 0.7 V3 0.3623111
#> 63 7 0.7 V4 0.4036671
#> 64 7 0.7 V5 0.3961116
#> 65 7 0.7 V9 0.3529468
#> 66 7 0.7 V6 0.3440526
#> 67 7 0.7 V7 0.3890632
#> 68 7 0.7 V8 0.3272545
#> 69 7 0.7 V2 0.4101488
#> 70 7 0.7 V10 0.3645710
#> 71 8 0.8 V9 0.3524196
#> 72 8 0.8 V10 0.3639884
#> 73 8 0.8 V1 0.3707020
#> 74 8 0.8 V5 0.3955240
#> 75 8 0.8 V2 0.4094365
#> 76 8 0.8 V3 0.3617844
#> 77 8 0.8 V4 0.4030323
#> 78 8 0.8 V8 0.3266901
#> 79 8 0.8 V6 0.3435324
#> 80 8 0.8 V7 0.3884982
#> 81 9 0.9 V5 0.3949373
#> 82 9 0.9 V7 0.3879341
#> 83 9 0.9 V8 0.3261267
#> 84 9 0.9 V9 0.3518932
#> 85 9 0.9 V6 0.3430130
#> 86 9 0.9 V10 0.3634068
#> 87 9 0.9 V1 0.3701639
#> 88 9 0.9 V2 0.4087255
#> 89 9 0.9 V3 0.3612585
#> 90 9 0.9 V4 0.4023984
#> 91 10 1.0 V1 0.3696267
#> 92 10 1.0 V4 0.4017656
#> 93 10 1.0 V5 0.3943514
#> 94 10 1.0 V9 0.3513675
#> 95 10 1.0 V3 0.3607333
#> 96 10 1.0 V7 0.3873707
#> 97 10 1.0 V8 0.3255642
#> 98 10 1.0 V2 0.4080156
#> 99 10 1.0 V6 0.3424944
#> 100 10 1.0 V10 0.3628261
# 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.3744903
#> 2 1 0.1 V5 0.3996555
#> 3 1 0.1 V9 0.3561267
#> 4 1 0.1 V3 0.3654873
#> 5 1 0.1 V4 0.4074972
#> 6 1 0.1 V8 0.3306614
#> 7 1 0.1 V2 0.4144487
#> 8 1 0.1 V6 0.3471904
#> 9 1 0.1 V7 0.3924705
#> 10 1 0.1 V10 0.3680859
#> 11 2 0.2 V7 0.3919006
#> 12 2 0.2 V8 0.3300911
#> 13 2 0.2 V9 0.3555947
#> 14 2 0.2 V10 0.3674978
#> 15 2 0.2 V1 0.3739467
#> 16 2 0.2 V5 0.3990626
#> 17 2 0.2 V2 0.4137289
#> 18 2 0.2 V3 0.3649560
#> 19 2 0.2 V4 0.4068563
#> 20 2 0.2 V6 0.3466655
#> 21 3 0.3 V4 0.4062165
#> 22 3 0.3 V5 0.3984707
#> 23 3 0.3 V3 0.3644255
#> 24 3 0.3 V7 0.3913315
#> 25 3 0.3 V8 0.3295218
#> 26 3 0.3 V9 0.3550635
#> 27 3 0.3 V6 0.3461413
#> 28 3 0.3 V10 0.3669105
#> 29 3 0.3 V1 0.3734040
#> 30 3 0.3 V2 0.4130104
#> 31 4 0.4 V1 0.3728620
#> 32 4 0.4 V9 0.3545332
#> 33 4 0.4 V3 0.3638957
#> 34 4 0.4 V4 0.4055776
#> 35 4 0.4 V5 0.3978796
#> 36 4 0.4 V2 0.4122931
#> 37 4 0.4 V6 0.3456180
#> 38 4 0.4 V7 0.3907632
#> 39 4 0.4 V8 0.3289535
#> 40 4 0.4 V10 0.3663242
#> 41 5 0.5 V8 0.3283862
#> 42 5 0.5 V9 0.3540036
#> 43 5 0.5 V10 0.3657389
#> 44 5 0.5 V1 0.3723208
#> 45 5 0.5 V5 0.3972894
#> 46 5 0.5 V2 0.4115771
#> 47 5 0.5 V3 0.3633667
#> 48 5 0.5 V4 0.4049398
#> 49 5 0.5 V6 0.3450954
#> 50 5 0.5 V7 0.3901957
#> 51 6 0.6 V4 0.4043029
#> 52 6 0.6 V5 0.3967000
#> 53 6 0.6 V7 0.3896291
#> 54 6 0.6 V8 0.3278199
#> 55 6 0.6 V9 0.3534748
#> 56 6 0.6 V6 0.3445736
#> 57 6 0.6 V10 0.3651544
#> 58 6 0.6 V1 0.3717804
#> 59 6 0.6 V2 0.4108623
#> 60 6 0.6 V3 0.3628385
#> 61 7 0.7 V1 0.3712408
#> 62 7 0.7 V3 0.3623111
#> 63 7 0.7 V4 0.4036671
#> 64 7 0.7 V5 0.3961116
#> 65 7 0.7 V9 0.3529468
#> 66 7 0.7 V6 0.3440526
#> 67 7 0.7 V7 0.3890632
#> 68 7 0.7 V8 0.3272545
#> 69 7 0.7 V2 0.4101488
#> 70 7 0.7 V10 0.3645710
#> 71 8 0.8 V9 0.3524196
#> 72 8 0.8 V10 0.3639884
#> 73 8 0.8 V1 0.3707020
#> 74 8 0.8 V5 0.3955240
#> 75 8 0.8 V2 0.4094365
#> 76 8 0.8 V3 0.3617844
#> 77 8 0.8 V4 0.4030323
#> 78 8 0.8 V8 0.3266901
#> 79 8 0.8 V6 0.3435324
#> 80 8 0.8 V7 0.3884982
#> 81 9 0.9 V5 0.3949373
#> 82 9 0.9 V7 0.3879341
#> 83 9 0.9 V8 0.3261267
#> 84 9 0.9 V9 0.3518932
#> 85 9 0.9 V6 0.3430130
#> 86 9 0.9 V10 0.3634068
#> 87 9 0.9 V1 0.3701639
#> 88 9 0.9 V2 0.4087255
#> 89 9 0.9 V3 0.3612585
#> 90 9 0.9 V4 0.4023984
#> 91 10 1.0 V1 0.3696267
#> 92 10 1.0 V4 0.4017656
#> 93 10 1.0 V5 0.3943514
#> 94 10 1.0 V9 0.3513675
#> 95 10 1.0 V3 0.3607333
#> 96 10 1.0 V7 0.3873707
#> 97 10 1.0 V8 0.3255642
#> 98 10 1.0 V2 0.4080156
#> 99 10 1.0 V6 0.3424944
#> 100 10 1.0 V10 0.3628261