dic.fit.mcmc {coarseDataTools} R 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:
L o g − n o r m a l m o d e l : f ( x ) = 1 x ∗ σ 2 ∗ π e x p { − ( log x − μ ) 2 2 ∗ σ 2 } Log-normal model: f(x) = \frac{1}{x*\sigma \sqrt{2 * \pi}} exp\{-\frac{(\log x - \mu)^2}{2 * \sigma^2}\} L o g − n or ma l m o d e l : f ( x ) = x ∗ σ 2 ∗ π 1 e x p { − 2 ∗ σ 2 ( l o g x − μ ) 2 }
L o g − n o r m a l D e f a u l t P r i o r : μ N ( 0 , 1000 ) , l o g ( σ ) N ( 0 , 1000 ) Log-normal Default Prior: \mu ~ N(0, 1000), log(\sigma) ~ N(0,1000) L o g − n or ma l De f a u ltP r i or : μ N ( 0 , 1000 ) , l o g ( σ ) N ( 0 , 1000 )
W e i b u l l m o d e l : f ( x ) = α β ( x β ) α − 1 e x p { − ( x β ) α } Weibull model: f(x) = \frac{\alpha}{\beta}(\frac{x}{\beta})^{\alpha-1} exp\{-(\frac{x}{\beta})^{\alpha}\} W e ib u ll m o d e l : f ( x ) = β α ( β x ) α − 1 e x p { − ( β x ) α }
W e i b u l l D e f a u l t P r i o r S p e c i f i c a t i o n : l o g ( α ) N ( 0 , 1000 ) , β G a m m a ( 0.001 , 0.001 ) Weibull Default Prior Specification: log(\alpha) ~ N( 0, 1000), \beta ~ Gamma(0.001,0.001) W e ib u ll De f a u ltP r i or Sp ec i f i c a t i o n : l o g ( α ) N ( 0 , 1000 ) , β G amma ( 0.001 , 0.001 )
G a m m a m o d e l : f ( x ) = 1 θ k Γ ( k ) x k − 1 e x p { − x θ } Gamma model: f(x) = \frac{1}{\theta^k \Gamma(k)} x^{k-1} exp\{-\frac{x}{\theta}\} G ammam o d e l : f ( x ) = θ k Γ ( k ) 1 x k − 1 e x p { − θ x }
G a m m a D e f a u l t P r i o r S p e c i f i c a t i o n : p ( k , θ ) ∝ 1 θ ∗ k ∗ T r i G a m m a ( k ) − 1 Gamma Default Prior Specification: p(k,\theta) \propto \frac{1}{\theta} * \sqrt{k*TriGamma(k)-1} G amma De f a u ltP r i or Sp ec i f i c a t i o n : p ( k , θ ) ∝ θ 1 ∗ k ∗ T r i G amma ( k ) − 1
(Note: this is Jeffery's Prior when both parameters are unknown), and
T r i g a m m a ( x ) = ∂ ∂ x 2 l n ( Γ ( x ) ) Trigamma(x) = \frac{\partial}{\partial x^2} ln(\Gamma(x)) T r i g amma ( x ) = ∂ x 2 ∂ l n ( Γ ( x ))
.)
E r l a n g m o d e l : f ( x ) = 1 θ k ( k − 1 ) ! x k − 1 e x p { − x θ } Erlang model: f(x) = \frac{1}{\theta^k (k-1)!} x^{k-1} exp\{-\frac{x}{\theta}\} E r l an g m o d e l : f ( x ) = θ k ( k − 1 )! 1 x k − 1 e x p { − θ x }
E r l a n g D e f a u l t P r i o r S p e c i f i c a t i o n : k ∼ N B i n o m ( 100 , 1 ) , l o g ( θ ) ∼ N ( 0 , 1000 ) Erlang Default Prior Specification: k \sim NBinom(100,1), log(\theta) \sim N(0,1000) E r l an g De f a u ltP r i or Sp ec i f i c a t i o n : k ∼ NB in o m ( 100 , 1 ) , l o g ( θ ) ∼ N ( 0 , 1000 )
(Note: parameters in the negative binomial distribution above represent mean and size, respectively)
Value
a cd.fit.mcmc S4 object
[Package
coarseDataTools version 0.6-6
Index ]