Description Usage Arguments Details Value
Run a multispecies occupancy model on trawl data. The model is multi-year, and there are two basic versions; first one is a 'static' model for which no temporal process is explicitly modelled (the years are 'stacked'). The second is a 'dynamic' model that includes persistence and colonization parameters as processes that facilitate the state transition between years. Each of these models can be run in either JAGS or Stan. Both models accept covariates for the detection and presence processes, and both sets of covariates can be modelled as random variables, constants (varying, but known precisely), or a mixture of the two.
1 2 3 4 5 6 7 8 9 10 | run_msom(reg = c("ai", "ebs", "gmex", "goa", "neus", "newf", "ngulf", "sa",
"sgulf", "shelf", "wcann", "wctri"), regX.a1, params_out = c("params",
"params_main", "params_random", "params_latent", "custom"),
custom_params = NULL, model_type = c("Dynamic", "Static"), n0 = 50,
chains = 4, cores = parallel::detectCores()/2, iter, thin = max(1,
floor((iter/2)/200)), language = c("JAGS", "Stan"), test = FALSE,
test_sub = list(stratum = 4, year = 3, spp = 10), seed = 1337,
pre_save = FALSE, save_dir = ".",
model_dir = file.path(system.file(package = "trawlDiversity"),
tolower(language)), compiled_model = NULL, ...)
|
reg |
character, region name |
regX.a1 |
optional data set formatted according to output from |
params_out |
character vector specifying category of parameters to report in output; if custom, points to |
custom_params |
possible characters specifying custom parameters, potentially indexed; see Details |
model_type |
type of model. Currently both are multiyear. 'Dynamic' includes terms for persistence and colonization (species-specific), whereas 'Static' simply 'stacks' the years. |
n0 |
integer indicating the number of species to use in data augmentation; defaults to 50, is passed to |
chains |
integer number of chains, default is 4 |
cores |
integer number of cores for parallel processes; default is half of avaialble cores |
iter |
number of iterations; the default depends on |
thin |
Integer, thinning rate. Default is set to yield 200 draws from the posterior, or if that is not possible, thinning rate is 1 and draws will be |
language |
character indicating the language to be used — JAGS or Stan |
test |
Logical, whether to do this run as a 'test' run. Default is FALSE. If TRUE, fewer iterations are run (unless overridden by non-default), and the data set is subsetted |
test_sub |
a named list with elements 'stratum', 'year', and 'spp'. Each element should be an integer indicating the number of levels to select for each of those dimensions. Used for subsetting when |
seed |
integer random number seed |
pre_save |
Logical; if TRUE (default) saves a workspace image before running the model |
save_dir |
Character string indicating the location of the directory to save the intermediate image; default is current directory |
model_dir |
Character string indicating the location of the model file; default is selected automatically based on |
compiled_model |
Only used when language="Stan"; a Stan model compiled using |
... |
arguments passed to |
Both params_out
and custom_params
must find matches in the output of msom_params
. For all parameters, use 'params'; main-effect parameters specified via 'params_main'; random-effect parameters via 'params_random'. Latent stochastic nodes/ parameters via 'params_latent'. Additional flexibility offered by specifying 'custom', which will add manually specified parameters from custom_params
.
Returns a named list of length two. The first element, 'out', contains a JAGS or Stan model object. The second element is a named character vector containing potential file names or prefixes to file names. These names contain collapsed information related to the model run settings, time, file paths, etc.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.