View source: R/demographicRates.R
demographicRates | R Documentation |
Apply sampled coefficients to disturbance covariates to
calculate expected recruitment and survival.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
}
)
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 |
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 |
predInterval |
numeric vector with length 2. The default 95% interval
is ( |
transformFns |
list of functions used to transform demographic rates.
The default is |
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 |
transformFn |
function used to transform demographic rates. |
First the mean recruitment (\mu^R_t
) and survival
(\mu^S_t
) are calculated from the sampled coefficients and provided
disturbance covariates according to the beta regression models estimated by
Johnson et al. (2020):
log(\mu^R_t)=\dot{\beta^R_0}+\dot{\beta^R_a}A_t+\dot{\beta}^R_fF_t
log(\mu^S_t)=\dot{\beta^S_0}+\dot{\beta^S_a}A_t
Then each replicate population is assigned to a quantile (if useQuantiles = TRUE
) of the Beta distributed expected recruitment \bar{R}_t
and
survival \bar{S}_t
where \phi^R
and \phi^S
are the
precisions of the Beta distributed errors:
\bar{R}_t \sim \text{Beta}(\mu^R_t,\phi^R)
\bar{S}_t \sim (46\times \text{Beta}(\mu^S_t,\phi^S)-0.5)/45)
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 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
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)
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)
# return one row per replicate * scenario
sampleRates(distScen, cfSamps$coefSamples, cfSamps$coefValues,
"Johnson", "recruitment", ignorePrecision = TRUE,
returnSample = TRUE)
# 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)))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.