dic.fit.mcmc: Fits the distribution to the passed-in data using MCMC as...

View source: R/dic.fit.mcmc.R

dic.fit.mcmcR Documentation

Fits the distribution to the passed-in data using MCMC as implemented in MCMCpack.

Description

Similar to dic.fit but uses MCMC instead of a direct likelihood optimization routine to fit the model. Currently, four distributions are supported: log-normal, gamma, Weibull, and Erlang. See Details for prior specification.

Usage

dic.fit.mcmc(
  dat,
  prior.par1 = NULL,
  prior.par2 = NULL,
  init.pars = c(1, 1),
  ptiles = c(0.05, 0.95, 0.99),
  verbose = 1000,
  burnin = 3000,
  n.samples = 5000,
  dist = "L",
  seed = NULL,
  ...
)

Arguments

dat

the data

prior.par1

vector of first prior parameters for each model parameter. If NULL then default parameters are used (as described in Details section).

prior.par2

vector of second prior parameters for each model parameter. If NULL then default parameters are used (as described in Details section).

init.pars

the initial parameter values (vector length = 2 )

ptiles

returned percentiles of the survival survival distribution

verbose

how often do you want a print out from MCMCpack on iteration number and M-H acceptance rate

burnin

number of burnin samples

n.samples

number of samples to draw from the posterior (after the burnin)

dist

distribution to be used (L for log-normal,W for weibull, G for Gamma, and E for erlang, off1G for 1 day right shifted gamma)

seed

seed for the random number generator for MCMC

...

additional parameters to MCMCmetrop1R

Details

The following models are used:

Log-normal model: f(x) = \frac{1}{x*\sigma \sqrt{2 * \pi}} exp\{-\frac{(\log x - \mu)^2}{2 * \sigma^2}\}

Log-normal Default Prior: \mu ~ N(0, 1000), log(\sigma) ~ N(0,1000)

Weibull model: f(x) = \frac{\alpha}{\beta}(\frac{x}{\beta})^{\alpha-1} exp\{-(\frac{x}{\beta})^{\alpha}\}

Weibull Default Prior Specification: log(\alpha) ~ N( 0, 1000), \beta ~ Gamma(0.001,0.001)

Gamma model: f(x) = \frac{1}{\theta^k \Gamma(k)} x^{k-1} exp\{-\frac{x}{\theta}\}

Gamma Default Prior Specification: p(k,\theta) \propto \frac{1}{\theta} * \sqrt{k*TriGamma(k)-1}

(Note: this is Jeffery's Prior when both parameters are unknown), and

Trigamma(x) = \frac{\partial}{\partial x^2} ln(\Gamma(x))

.)

Erlang model: f(x) = \frac{1}{\theta^k (k-1)!} x^{k-1} exp\{-\frac{x}{\theta}\}

Erlang Default Prior Specification: k \sim NBinom(100,1), log(\theta) \sim N(0,1000)

(Note: parameters in the negative binomial distribution above represent mean and size, respectively)

Value

a cd.fit.mcmc S4 object


nickreich/coarseDataTools documentation built on July 8, 2023, 12:24 a.m.