Bayesian population model for boreal caribou
Source:R/bayesianTrajectoryWorkflow.R
bayesianTrajectoryWorkflow.RdBayesian population model for boreal caribou
Usage
bayesianTrajectoryWorkflow(
surv_data = bboudata::bbousurv_a,
recruit_data = bboudata::bbourecruit_a,
disturbance = NULL,
priors = "default",
startYear = NULL,
endYear = NULL,
N0 = NA,
returnSamples = F,
inputList = list(),
niters = formals(bboutools::bb_fit_survival)$niters,
nthin = formals(bboutools::bb_fit_survival)$nthin,
...
)Arguments
- surv_data
either a path to a csv file or a survival data table in bboutools format.
- recruit_data
either a path to a csv file or a recruitment data table in bboutools format.
- disturbance
either a path to a csv file or a dataframe containing the columns "Anthro","Fire_excl_anthro", and "Year".
- priors
list. Optional. If disturbance is NULL, this should be list(priors_survival=c(...),priors_recruitment=c(...)); see
bboutools::bb_priors_survival()andbboutools::bb_priors_recruitment()for details. If disturbance is not NULL, seebetaNationalPriors()for details.- startYear, endYear
year defining the beginning of the observation period and the end of the projection period.
- N0
number or dataframe. Optional. Initial population size(s). If NA (default) then population growth rate is \(\lambda_t=S_t*(1+cR_t)/s\). If a data frame N0 column is required, and PopulationName column is required if there is more than one row. Additional (optional) variation columns will be used by
addN0Variation().- returnSamples
logical. If FALSE returns only summaries. If TRUE returns example trajectories.
- inputList
an optional list of inputs with names matching the above. If an argument is included in this list it will override the named argument.
- niters
integer. The number of iterations per chain after thinning and burn-in.
- nthin
integer. The number of the thinning rate.
- ...
Other parameters passed on to
bboutools::bb_fit_survival()andbboutools::bb_fit_recruitment().
Value
a list with elements:
result: a list of model results:
summary: a data.frame
samples: a tibble providing the full range of MCMC trajectories from the model. It is in a long format where "Amount" gives the value for each metric in Anthro, Fire_excl_anthro, c, survival, recruitment, X, N, lambda, Sbar, Rbar, Xbar, Nbar, and lambda_bar, with a row for each combination of "MetricTypeID", "Replicate", "Year" and "LambdaPercentile"
surv_data: a data.frame
recruit_data: a tibble
popInfo: a data.frame
inData: a list of data that is used as input to the jags model:
survDataIn: survival data
disturbanceIn: disturbance data
recruitDataIn: composition data
Interpretation of Years
Throughout the package a year is treated as the calendar year only if it is in a table that also contains a month column. In all other contexts year is treated as the caribou year which is the annual demographic cycle of caribou, measured from one calving season to the next. By default, April is set as the start of the caribou year.
See also
Caribou demography functions:
addMissingYears(),
addN0Variation(),
bayesianScenariosWorkflow(),
betaNationalPriors(),
caribouPopGrowth(),
compareTrajectories(),
compositionBiasCorrection(),
convertTrajectories(),
dataFromSheets(),
demographicProjectionApp(),
estimateBayesianRates(),
estimateNationalRate(),
getCaribouYear(),
getNationalCoefficients(),
getScenarioDefaults(),
plotCompareTrajectories(),
plotSurvivalSeries(),
plotTrajectories(),
popGrowthTableJohnsonECCC,
simulateObservations(),
trajectoriesFromBayesian(),
trajectoriesFromNational(),
trajectoriesFromSummary(),
trajectoriesFromSummaryForApp()
Examples
# \donttest{
# Note these examples take a long time to run!
# Using observed survival, recruitment and disturbance data
mod <- bayesianTrajectoryWorkflow(
surv_data = bboudata::bbousurv_a,
recruit_data = bboudata::bbourecruit_a,
disturbance = NULL
)
#> Warning: missing years of recruitment data: 1985, 1986, 1987, 1988
str(mod, max.level = 2)
#> List of 4
#> $ result :List of 4
#> ..$ summary :'data.frame': 320 obs. of 8 variables:
#> ..$ surv_data :'data.frame': 384 obs. of 9 variables:
#> ..$ recruit_data:'data.frame': 32 obs. of 9 variables:
#> ..$ popInfo :'data.frame': 3000 obs. of 4 variables:
#> $ inData :List of 1
#> ..$ disturbanceIn: NULL
#> $ parTab :'data.frame': 1 obs. of 18 variables:
#> ..$ PopulationName: chr "A"
#> ..$ R_bar : num 0.188
#> ..$ R_sd : num 0.087
#> ..$ R_iv_mean : num 0.341
#> ..$ R_iv_shape : num 16.8
#> ..$ R_bar_lower : num 0.163
#> ..$ R_bar_upper : num 0.215
#> ..$ S_bar : num 0.871
#> ..$ S_sd : num 0.162
#> ..$ S_iv_mean : num 0.315
#> ..$ S_iv_shape : num 2.78
#> ..$ S_bar_lower : num 0.835
#> ..$ S_bar_upper : num 0.906
#> ..$ N0 : logi NA
#> ..$ nCollarYears : num NA
#> ..$ nSurvYears : int 32
#> ..$ nCowsAllYears : num NA
#> ..$ nRecruitYears : int 32
#> $ parList:List of 5
#> ..$ Rbar:'data.frame': 32 obs. of 7 variables:
#> ..$ Sbar:'data.frame': 32 obs. of 7 variables:
#> ..$ Siv :'data.frame': 1 obs. of 2 variables:
#> ..$ Riv :'data.frame': 1 obs. of 2 variables:
#> ..$ type: chr "bbou"
# Using simulated observation data
scns <- getScenarioDefaults(projYears = 10, obsYears = 10,
obsAnthroSlope = 1, projAnthroSlope = 5,
collarCount = 20, cowMult = 5)
simO <- simulateObservations(scns)
out <- bayesianTrajectoryWorkflow(surv_data = simO$simSurvObs, recruit_data = simO$simRecruitObs,
disturbance = simO$simDisturbance,
startYear = 2014)
# }