updatePrior | R Documentation |
bdm
modelThis function can be used to update the priors for r and ln(K).
updatePrior(object, ...) ## S3 method for class 'bdm' updatePrior(object, prior, ...)
object |
a |
... |
additional arguments to generic function |
prior |
a |
The bdm package by default assumes that the prior on r is log-normal and the prior for ln(K) is uniform. If the function is supplied with a prior
class object then it will extract the log-normal distribution parameters for r and use regular expression matching to update the model code. If the function is provided with a named list then it can be used to update the priors for r, ln(K) or the initial depletion x0, in a similar manner. See the examples for how the list arguments are specified.
By default this function only updates the model code. The model will need to be re-compiled before it is run for the changes to take effect.
Returns a bdm
object with updated model code.
# initialise default model mdl <- bdm() # update prior for r mdl <- updatePrior(mdl, list(par = 'r', meanlog = -1.1, sdlog = 0.1)) # update prior for logK mdl <- updatePrior(mdl, list(par = 'logK', min = 1, max = 100)) # update prior for initial depletion mdl <- updatePrior(mdl, list(par = 'x0', meanlog = log(0.8), sdlog = 0.01)) # check updates getr(mdl) getlogK(mdl) # update using a prior class # object library(lhm) # create object containing # vector of r values iter <- 100 mu <- 0.1 cv <- 0.2 sd <- sqrt(log(1+cv^2)) x <- rlnorm(iter,log(mu)-sd^2/2,sd) r <- prior(x) # update model mdl <- updatePrior(mdl, r) # check update mean(log(r)) getr(mdl)[['E[log(r)]']]
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.