Description Usage Arguments Examples
For use with data for a single species.
1 2 3 4 5 6 7 8  fit_vb(dat, sex = c("female", "male", "all"), method = c("tmb", "mpd",
"mcmc"), downsample = Inf, chains = 4L, iter = 1000L,
cores = parallel::detectCores(), allow_slow_mcmc = FALSE,
est_method = median, min_samples = 50L, too_high_quantile = 1,
uniform_priors = FALSE, ageing_method_codes = NULL,
usability_codes = c(0, 1, 2, 6), check_convergence_tmb = TRUE,
tmb_inits = list(k = 0.5, linf = 40, log_sigma = log(0.1), t0 = 1),
...)

dat 
Input data frame. Should be from 
sex 
Either "male" or "female". 
method 

downsample 
If not 
chains 
Number of Stan chains. 
iter 
Number of Stan sampling iterations. 
cores 
Number of cores for Stan. 
allow_slow_mcmc 
Logical. If 
est_method 
If MCMC this defines how to summarize the posterior. Should
be a function such as 
min_samples 
The minimum number of fish before a model will be fit. 
too_high_quantile 
A quantile above which to discard weights and lengths. Can be useful for outliers. Defaults to including all data. 
uniform_priors 
Logical. If true then uniform priors will be used. 
ageing_method_codes 
A numeric vector of ageing method codes to filter
on. Defaults to 
usability_codes 
An optional vector of usability codes.
All usability codes not in this vector will be omitted.
Set to 
check_convergence_tmb 
Logical. 
tmb_inits 
A named list of initial parameter values for the TMB model. 
... 
Any other arguments to pass on to 
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26  # with `rstan::optimizing()` for the mode of the posterior density:
model_f < fit_vb(pop_samples, sex = "female")
model_m < fit_vb(pop_samples, sex = "male")
plot_vb(model_f, model_m)
model_f$model
model_f$predictions
# You can also fit both sexes combined if you want.
# Just note that you need to specify the colours explicitly in the plot.
model_all < fit_vb(pop_samples, sex = "all")
plot_vb(object_all = model_all, col = c("All" = "black"))
# with MCMC via Stan (slower):
x < fit_vb(pop_samples, method = "mcmc",
chains = 1, iter = 800, seed = 123) # just for a fast example
x$pars
x$predictions
x$data
x$model
posterior < rstan::extract(x$model)
hist(posterior$linf)
# If less than `min_samples`, fit_vb() returns an empty object that
# plot_vb() will correctly parse and produce an empty plot:
obj < fit_vb(pop_samples[1:2,])
plot_vb(obj, obj)

Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.