ML_stan: Bayesian mean length estimator

Description Usage Arguments Value Note See Also Examples

Description

Bayesian mean length estimator

Usage

1
2
3
ML_stan(MLZ_data, MLZ_prior, prior_only = FALSE, chains = 2,
  iter = 60000, warmup = 10000, thin = 20, seed = 20,
  cores = chains, ...)

Arguments

MLZ_data

An object with mean length data. Slots Year, MeanLength, ss, and Lc are used.

MLZ_prior

An object with describing model structure (including priors and the number of change points).

prior_only

Logical. If TRUE, only the priors will be sampled in the MCMC.

chains

The number of MCMC chains.

iter

The number of MCMC iterations.

warmup

The number of warmup iterations.

thin

The number for which each thin-th iteration in the chain is saved.

seed

Integer for random number generation.

cores

The number of cores for running the chains in parallel.

...

Other arguments to pass to rstan::sampling.

Value

An object of class stanfit.

Note

By default, uses the No U-Turn Sampling algorithm for MCMC sampling. The default settings for the number of total iterations (iter), warmup iterations (warmup), and thinning (thin) are much more conservative than the rstan defaults. More iterations and thinning may still be needed. Always check for convergence.

See Also

stan MLZ_data MLZ_prior plot,stanfit,stanfit-method

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
## Not run:  
# Create MLZ_data object with mean length data 
# Use utility functions in MLZ package
library(MLZ)
data(Goosefish)

# Create an object with priors for a model with 2 change points in mortality (ncp = 2)
default_priors <- new("MLZ_prior", ncp = 2)

# Run the MCMC (calls rstan::sampling)
res <- ML_stan(Goosefish, default_priors)

# All generics for stanfit object from rstan package are available.
stan_trace(res)
stan_dens(res, separate_chains = TRUE)

# Test priors only
res2 <- ML_stan(Goosefish, default_priors, prior_only = TRUE)
stan_dens(res2, separate_chains = TRUE)

## End(Not run)

quang-huynh/MLZBayes documentation built on May 12, 2019, 6:16 p.m.