# dist.Inverse.Gamma: Inverse Gamma Distribution In LaplacesDemon: Complete Environment for Bayesian Inference

## Description

This is the density function and random generation from the inverse gamma distribution.

## Usage

 ```1 2``` ```dinvgamma(x, shape=1, scale=1, log=FALSE) rinvgamma(n, shape=1, scale=1) ```

## Arguments

 `n` This is the number of draws from the distribution. `x` This is the scalar location to evaluate density. `shape` This is the scalar shape parameter alpha, which defaults to one. `scale` This is the scalar scale parameter beta, which defaults to one. `log` Logical. If `log=TRUE`, then the logarithm of the density is returned.

## Details

• Application: Continuous Univariate

• Density: p(theta) = (beta^alpha / Gamma(alpha)) * theta^(-(alpha + 1)) * exp(-beta / theta), theta > 0

• Inventor: Unknown (to me, anyway)

• Notation 1: theta ~ G^-1(alpha, beta)

• Notation 2: p(theta) = G^-1(theta | alpha, beta)

• Parameter 1: shape alpha > 0

• Parameter 2: scale beta > 0

• Mean: E(theta) = beta / (alpha - 1), for alpha > 1

• Variance: var(theta) = beta^2 / ((alpha - 1)^2 * (alpha - 2)), alpha > 2

• Mode: mode(theta) = beta / (alpha + 1)

The inverse-gamma is the conjugate prior distribution for the normal or Gaussian variance, and has been traditionally specified as a vague prior in that application. The density is always finite; its integral is finite if alpha > 0. Prior information decreases as alpha, beta -> 0.

These functions are similar to those in the `MCMCpack` package.

## Value

`dinvgamma` gives the density and `rinvgamma` generates random deviates. The parameterization is consistent with the Gamma Distribution in the stats package.

`dgamma`, `dnorm`, `dnormp`, and `dnormv`.

## Examples

 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13``` ```library(LaplacesDemon) x <- dinvgamma(4.3, 1.1) x <- rinvgamma(10, 3.3) #Plot Probability Functions x <- seq(from=0.1, to=20, by=0.1) plot(x, dinvgamma(x,1,1), ylim=c(0,1), type="l", main="Probability Function", ylab="density", col="red") lines(x, dinvgamma(x,1,0.6), type="l", col="green") lines(x, dinvgamma(x,0.6,1), type="l", col="blue") legend(2, 0.9, expression(paste(alpha==1, ", ", beta==1), paste(alpha==1, ", ", beta==0.6), paste(alpha==0.6, ", ", beta==1)), lty=c(1,1,1), col=c("red","green","blue")) ```

### Example output

```
```

LaplacesDemon documentation built on Dec. 23, 2017, 5:13 p.m.