Skip to contents

Define scenarios in a table and simulateObservations(), run the bayesianTrajectoryWorkflow() model and compareTrajectories() for each scenario.

Usage

bayesianScenariosWorkflow(
  scns,
  simInitial,
  ePars = list(collarOnTime = 4, collarOffTime = 3, collarNumYears = 4),
  Rep = NULL,
  printProgress = FALSE,
  priors = "default",
  niters = formals(bboutools::bb_fit_survival)$niters,
  nthin = formals(bboutools::bb_fit_survival)$nthin,
  returnSamples = F,
  ...
)

Arguments

scns

data.frame. Parameters for the simulations. See getScenarioDefaults() for details.

simInitial

Initial simulation results, produced by calling trajectoriesFromNational(), trajectoriesFromBayesian(), or trajectoriesFromSummary()

ePars

list. Additional parameters passed on to simulateObservations()

Rep

integer. Optional. If specified, select specified replicate trajectory.

printProgress

logical. Should the scenario number and parameters be printed at each step?

priors

a list of model priors. If disturbance is NA, this should be list(priors_survival=c(...),priors_recruitment=c(...)); see bboutools::bb_priors_survival and bboutools::bb_priors_recruitment for details. If disturbance is not NA, see betaNationalPriors() for details.

niters

A whole number of the number of iterations per chain after thinning and burn-in.

nthin

integer. The number of the thinning rate.

returnSamples

logical. Optional. If true, return full results from bayesianTrajectoryWorkflow().

Value

A list similar to compareTrajectories() where tables for each scenario have been appended together. Plus an error log for any scenarios that failed to run.

Examples

scns <- expand.grid(
  obsYears =c(10, 20), collarCount = c(30, 300), cowMult = 2, collarInterval = 2,
  iAnthro = 0,
  obsAnthroSlope = 0, projAnthroSlope = 0, sQuaMntile = 0.9,
  rQuantile = 0.7, N0 = 1000
)

eParsIn <- list(collarOnTime = 4, collarOffTime = 4, collarNumYears = 3)
simsIn <- trajectoriesFromNational()
#> Updating cached initial simulations.
scResults <- bayesianScenariosWorkflow(scns, simsIn, eParsIn,
                       niters = 10)# only set to speed up example. Normally keep defaults.
#> Warning: requested year range: 2014 - 2058 does not match survival data year range:  2015 - 2024
#> Warning: missing years of recruitment data: 2014
#> Warning: requested year range: 2014 - 2058 does not match recruitment data year range:  2015 - 2025
#> Warning: missing years of recruitment data: 2014
#> Registered S3 method overwritten by 'mcmcr':
#>   method         from 
#>   as.mcmc.nlists nlist
#> Registered S3 method overwritten by 'rjags':
#>   method               from 
#>   as.mcmc.list.mcarray mcmcr
#> Compiling model graph
#>    Resolving undeclared variables
#>    Allocating nodes
#> Graph information:
#>    Observed stochastic nodes: 96
#>    Unobserved stochastic nodes: 492
#>    Total graph size: 2389
#> 
#> Initializing model
#> 
#> Warning: Adaptation incomplete
#> NOTE: Stopping adaptation
#> 
#> 
#> Compiling model graph
#>    Resolving undeclared variables
#>    Allocating nodes
#> Graph information:
#>    Observed stochastic nodes: 18
#>    Unobserved stochastic nodes: 211
#>    Total graph size: 680
#> 
#> Initializing model
#> 
#> Warning: Adaptation incomplete
#> NOTE: Stopping adaptation
#> 
#> 
#> Warning: requested year range: 2004 - 2058 does not match survival data year range:  2005 - 2024
#> Warning: missing years of recruitment data: 2004
#> Warning: requested year range: 2004 - 2058 does not match recruitment data year range:  2005 - 2025
#> Warning: missing years of recruitment data: 2004
#> Compiling model graph
#>    Resolving undeclared variables
#>    Allocating nodes
#> Graph information:
#>    Observed stochastic nodes: 216
#>    Unobserved stochastic nodes: 502
#>    Total graph size: 2909
#> 
#> Initializing model
#> 
#> Warning: Adaptation incomplete
#> NOTE: Stopping adaptation
#> 
#> 
#> Compiling model graph
#>    Resolving undeclared variables
#>    Allocating nodes
#> Graph information:
#>    Observed stochastic nodes: 38
#>    Unobserved stochastic nodes: 241
#>    Total graph size: 820
#> 
#> Initializing model
#> 
#> Warning: Adaptation incomplete
#> NOTE: Stopping adaptation
#> 
#> 
#> Warning: requested year range: 2014 - 2058 does not match survival data year range:  2015 - 2024
#> Warning: missing years of recruitment data: 2014
#> Warning: requested year range: 2014 - 2058 does not match recruitment data year range:  2015 - 2025
#> Warning: missing years of recruitment data: 2014
#> Compiling model graph
#>    Resolving undeclared variables
#>    Allocating nodes
#> Graph information:
#>    Observed stochastic nodes: 96
#>    Unobserved stochastic nodes: 492
#>    Total graph size: 2389
#> 
#> Initializing model
#> 
#> Warning: Adaptation incomplete
#> NOTE: Stopping adaptation
#> 
#> 
#> Compiling model graph
#>    Resolving undeclared variables
#>    Allocating nodes
#> Graph information:
#>    Observed stochastic nodes: 18
#>    Unobserved stochastic nodes: 211
#>    Total graph size: 680
#> 
#> Initializing model
#> 
#> Warning: Adaptation incomplete
#> NOTE: Stopping adaptation
#> 
#> 
#> Warning: The expected number of cows in composition survey exceeds population size. Adjusting cows in survey for consistency.
#> Warning: requested year range: 2004 - 2058 does not match survival data year range:  2005 - 2024
#> Warning: missing years of recruitment data: 2004
#> Warning: requested year range: 2004 - 2058 does not match recruitment data year range:  2005 - 2025
#> Warning: missing years of recruitment data: 2004
#> Compiling model graph
#>    Resolving undeclared variables
#>    Allocating nodes
#> Graph information:
#>    Observed stochastic nodes: 216
#>    Unobserved stochastic nodes: 502
#>    Total graph size: 2909
#> 
#> Initializing model
#> 
#> Warning: Adaptation incomplete
#> NOTE: Stopping adaptation
#> 
#> 
#> Compiling model graph
#>    Resolving undeclared variables
#>    Allocating nodes
#> Graph information:
#>    Observed stochastic nodes: 38
#>    Unobserved stochastic nodes: 241
#>    Total graph size: 820
#> 
#> Initializing model
#> 
#> Warning: Adaptation incomplete
#> NOTE: Stopping adaptation
#> 
#>