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
a list of model priors. If disturbance is NA, this should be list(priors_survival=c(...),priors_recruitment=c(...)); see
bboutools::bb_priors_survivalandbboutools::bb_priors_recruitmentfor details. If disturbance is not NA, seebetaNationalPriors()for details.- startYear, endYear
year defining the beginning of the observation period and the end of the projection period.
- N0
Number or vector of numbers. Initial population size for one or more sample populations. If NA then population growth rate is $_t=S_t*(1+cR_t)/s$.
- returnSamples
logical. If F returns only summaries. If T 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
A whole number of the number of iterations per chain after thinning and burn-in.
- nthin
integer. The number of the thinning rate.
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
See also
Caribou demography functions:
bayesianScenariosWorkflow(),
betaNationalPriors(),
caribouPopGrowth(),
compareTrajectories(),
compositionBiasCorrection(),
convertTrajectories(),
dataFromSheets(),
demographicProjectionApp(),
estimateBayesianRates(),
estimateNationalRate(),
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: requested year range: 1986 - 2016 does not match recruitment data year range: 1990 - 2016
#> Warning: missing years of recruitment data: 1986, 1987, 1988, 1989
#> Warning: no non-missing arguments to max; returning -Inf
str(mod, max.level = 2)
#> List of 4
#> $ result :List of 4
#> ..$ summary :'data.frame': 300 obs. of 8 variables:
#> ..$ surv_data :'data.frame': 363 obs. of 8 variables:
#> ..$ recruit_data:'data.frame': 30 obs. of 8 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.198
#> ..$ R_sd : num 0.0856
#> ..$ R_iv_mean : num 0.325
#> ..$ R_iv_shape : num 14.9
#> ..$ R_bar_lower : num 0.172
#> ..$ R_bar_upper : num 0.225
#> ..$ S_bar : num 0.872
#> ..$ S_sd : num 0.167
#> ..$ S_iv_mean : num 0.318
#> ..$ S_iv_shape : num 2.48
#> ..$ S_bar_lower : num 0.835
#> ..$ S_bar_upper : num 0.908
#> ..$ N0 : logi NA
#> ..$ nCollarYears : int NA
#> ..$ nSurvYears : int 31
#> ..$ nCowsAllYears : int NA
#> ..$ nRecruitYears : int 31
#> $ parList:List of 5
#> ..$ Rbar:'data.frame': 27 obs. of 7 variables:
#> ..$ Sbar:'data.frame': 27 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)
#> Compiling model graph
#> Resolving undeclared variables
#> Allocating nodes
#> Graph information:
#> Observed stochastic nodes: 10
#> Unobserved stochastic nodes: 33
#> Total graph size: 665
#>
#> Initializing model
#>
#> Compiling model graph
#> Resolving undeclared variables
#> Allocating nodes
#> Graph information:
#> Observed stochastic nodes: 20
#> Unobserved stochastic nodes: 79
#> Total graph size: 694
#>
#> Initializing model
#>
#> Warning: no non-missing arguments to max; returning -Inf
# }