gamgam: Gamma sampling distribution with a gamma distribution of...

Description Usage Arguments Value Source References See Also Examples

Description

Define the posterior distribution function for π (θ | t ), with a gamma prior distribution π ( θ; α, β ) and a gamma sampling distribution with known shape parameter a and unknown rate parameterθ.

Usage

1
gamgam(t, a = 1, shape, rate, scale = 1/rate)

Arguments

t

a sample data from a gamma distribution with shape a and rate θ ( t > 0 ).

a

the known shape parameter of the gamma sampling distribution (a > 0).

shape

the shape parameter of the prior gamma distribution for unknown θ (α > 0).

rate

the rate parameter of the prior gamma distribution for unknown θ (β > 0).

scale

equals 1 / rate ( > 0).

Value

An object of class "g12post" is returned.

prior

the prior distribution for unknown θ , i.e. the gamma(α,β) distribution.

likelihood

the likelihood function of t given θ, i.e. the f(t | θ) distribution.

posterior

the posterior distribution of θ given t.

theta

the unknown rate parameter of the gamma sampling distribution t π ( θ; α, β ).

pri.shape

the shape parameter of the gamma distribution for prior.

pri.rate

the rate parameter of the gamma distribution for prior.

pos.shape

the shape parameter of the gamma distribution for posterior.

pos.rate

the rate parameter of the gamma distribution for posterior.

model

the prior and likelihood type to produce the posterior.

Source

For theory details, based on STATG012 slides 5 Example 5.4 from Moodle at UCL.

References

Fink, D. 1997. A Compendium of Conjugate Priors. Weblink.

See Also

summary.g12post for summararies of prior and posterior distribution.

plot.g12post for plots of prior and posterior distribution.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
## an exponential distribution with a gamma prior, similiar
## as Example 5.4 from slides 6
## generate a sample of 10 observations from an exponential distribution
x <- rexp(10)
## find the posterior density and summary it
gam <- gamgam(x, a = 1, 4, 2)
summary(gam)

## generate a sample of 50 observations from a gamma distribution with a = 2
y <- rgamma(10, shape = 2)
## find the posterior density and plot it
ex <- gamgam(y, a = 2, 4, 2)
plot(ex, leg_pos = "center" , box.lty=0)

yijin71/statg012 documentation built on May 23, 2019, 4:04 p.m.