samplePosteriorDist {optimalThreshold} | R Documentation |
Sample in the posterior distribution of the parameters of a given theoretical distribution.
Description
The samplePosteriorDist
function samples the parameters of a given theoretical distribution using explicit posterior distribution (if it exists), or a Markov Chain Monte Carlo (MCMC) algorithm when the posterior distribution is unknown. See details to know on what kind of S4 objects this function could be applied.
Usage
samplePosteriorDist(object, K, ...)
## S4 method for signature 'fitNormalDist'
samplePosteriorDist(object, K, n)
## S4 method for signature 'fitLogNormalDist'
samplePosteriorDist(object, K, n)
## S4 method for signature 'fitGammaDist'
samplePosteriorDist(object, K, do.pb, seed)
## S4 method for signature 'fitStudentDist'
samplePosteriorDist(object, K, do.pb, seed)
## S4 method for signature 'fitLogisticDist'
samplePosteriorDist(object, K, do.pb, seed)
Arguments
object |
A distribution object. |
K |
A numerical value indicating the length of the sample. |
... |
other parameters passed to methods. |
n |
number of MCMC chains. |
do.pb |
Indicates whther progressing bar or not |
seed |
seed for the random number generator. Integer. |
Details
This method can be applied to the S4 distribution objects that are supported in the optimalThreshold
package: fitNormalDist
, fitLogNormalDist
, fitGammaDist
, fitStudentDist
, and fitLogisticDist
. These methods are applied internally, and you have no need to use it outside of the main function optThresEst
. See below to have details on the expression of the samplePosteriorDist
function according to the type of distribution.
Normal distribution: a noninformative prior is used for the parameters of the normal distribution (
mu
=\mu
, andsd
=\sigma
). The\sigma^2
parameter is sampled from an inverse Chi-squared distribution, and the\mu
parameter is sampled from a normal distribution with known variance. So, sampling in the posterior distribution of\mu
and\sigma
does not involve an MCMC algorithm (see References for more details and justification).Log-normal distribution: a noninformative prior is used for the parameters of the log-normal distribution (
mu
=\mu
, andsd
=\sigma
). The\sigma^2
parameter is sampled from an inverse Chi-squared distribution, and the\mu
parameter is sampled from a normal distribution with known variance. So, sampling in the posterior distribution of\mu
and\sigma
does not involve an MCMC algorithm (see References for more details and justification).Gamma distribution: a noninformative prior is used for the parameters of the gamma distribution (
shape
=\alpha
, andscale
=\beta
). The parameters are sampled using an adaptive rejection sampling (ARS) algorithm. The\beta
parameter is sampled at the first iteration from an inverse gamma distribution using the initial value of the\alpha
parameter provided by the user. Then the ARS algorithm is performed to sample\alpha
from its posterior distribution (see References for more details and justification).Scaled t distribution: a vague prior is used for the parameters of the scaled t distribution as a default. However, the user can write its own JAGS model to use different priors (see the
fit
function for more details). Sampling from the posterior distribution of the parameters of a scaled t distribution requires JAGS to be installed.Logistic distribution: a vague prior is used for the parameters of the logistic distribution as a default. However, the user can write its own JAGS model to use different priors (see the
fit
function for more details). Sampling from the posterior distribution of the parameters of a logistic distribution requires JAGS to be installed.
Value
Returns an object of class list.
References
Gelman, A, et al. 2014. Bayesian Data Analysis. 3rd edition, CRC Press, Boca Raton, section 2.8. Sook, Y, and Oh, M. Bayesian estimation of the two-parameter Gamma distribution. Communications in Statistics - Simulation and Computation. 2006; 35: 285-293.