Simulates random draws from the posterior distribution of GAM coefficients using a Metropolis Hastings algorithm.

# S3 method for narwsim
augment(obj, n = 1e+05, bc.range = c(0.05, find_maxBC()), ...)

Arguments

obj

An object of class narwsim, as returned by narw.

n

Integer. Defaults to 100,000. Number of posterior samples to draw.

bc.range

Numeric vector of length 2. Range (minimum, maximum) of body conditions used for model predictions.

...

Additional arguments passed to gam.mh.

Value

The original narwsim object, augmented with posterior samples (list element named post).

Note

In many cases, a Gaussian approximation to the posterior of the model coefficients is largely accurate, and samples generated from it can be treated as samples from the posterior for the coefficients. In other cases, however, this approximation can become poor and it may be useful to simulate from the posterior using a Metropolis Hastings sampler. A simple approach to this alternates fixed proposals, based on the Gaussian approximation to the posterior, with random walk proposals, based on a shrunken version of the approximate posterior covariance matrix. Fixed proposals often promote rapid mixing, while the random walk component ensures that the chain does not become stuck in regions for which the fixed Gaussian proposal density is much lower than the posterior density. The gam.mh function implements this, and is harnessed here.

The function reports the acceptance rate of the two samplers. As a general rule, the random walk acceptance probability should not be higher than ca. 0.25. If it is, the rw.scale argument can be used to increase the factor by which the posterior covariance matrix is scaled.

Author

Phil J. Bouchet ............................... '............................... ------------------------------------------------------------ ------------------------------------------------------------

Examples

if (FALSE) {
library(narwind)
m <- narw(10000)
plot(m)
}