dhalfnormal: Half-normal, half-Student-t and half-Cauchy distributions.

Description Usage Arguments Details Value Author(s) References See Also Examples

View source: R/bayesmeta.R

Description

Half-normal, half-Student-t and half-Cauchy density, distribution, quantile functions and random number generation.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14

Arguments

x, q

quantile.

p

probability.

n

number of observations.

scale

scale parameter (>0).

df

degrees-of-freedom parameter (>0).

log

logical; if TRUE, logarithmic density will be returned.

Details

The half-normal distribution is simply a zero-mean normal distribution that is restricted to take only positive values. The scale parameter σ here corresponds to the underlying normal distribution's standard deviation: if X ~ Normal(0,sigma), then |X| ~ halfNormal(scale=sigma). Its mean is sigma*sqrt(2/pi), and its variance is sigma^2*(1-2/pi). Analogously, the half-t distribution is a truncated Student-t distribution with df degrees-of-freedom, and the half-Cauchy distribution is again a special case of the half-t distribution with df=1 degrees of freedom.

Note that (half-) Student-t and Cauchy distributions arise as continuous mixture distributions of (half-) normal distributions. If

Y|sigma ~ Normal(0,sigma^2)

where the standard deviation is sigma=sqrt(k/X) and X is drawn from a χ^2-distribution with k degrees of freedom, then the marginal distribution of Y is Student-t with k degrees of freedom.

Value

dhalfnormal()’ gives the density function, ‘phalfnormal()’ gives the cumulative distribution function (CDF), ‘qhalfnormal()’ gives the quantile function (inverse CDF), and ‘rhalfnormal()’ generates random deviates. For the ‘dhalft()’, ‘dhalfcauchy()’ and related function it works analogously.

Author(s)

Christian Roever [email protected]

References

A. Gelman. Prior distributions for variance parameters in hierarchical models. Bayesian Analysis, 1(3):515-534, 2006.

F. C. Leone, L. S. Nelson, R. B. Nottingham. The folded normal distribution. Technometrics, 3(4):543-550, 1961.

N. G. Polson, J. G. Scott. On the half-Cauchy prior for a global scale parameter. Bayesian Analysis, 7(4):887-902, 2012.

S. Psarakis, J. Panaretos. The folded t distribution. Communications in Statistics - Theory and Methods, 19(7):2717-2734, 1990.

See Also

dnorm, dt, dcauchy, dlomax, drayleigh, TurnerEtAlPrior, RhodesEtAlPrior, bayesmeta.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
#######################
# illustrate densities:
x <- seq(0,6,le=200)
plot(x, dhalfnormal(x), type="l", col="red", ylim=c(0,1),
     xlab=expression(tau), ylab=expression("probability density "*f(tau)))
lines(x, dhalft(x, df=3), col="green")
lines(x, dhalfcauchy(x), col="blue")
lines(x, dexp(x), col="cyan")
abline(h=0, v=0, col="grey")

# show log-densities (note the differing tail behaviour):
plot(x, dhalfnormal(x), type="l", col="red", ylim=c(0.001,1), log="y",
     xlab=expression(tau), ylab=expression("probability density "*f(tau)))
lines(x, dhalft(x, df=3), col="green")
lines(x, dhalfcauchy(x), col="blue")
lines(x, dexp(x), col="cyan")
abline(v=0, col="grey")

Example output

Loading required package: forestplot
Loading required package: grid
Loading required package: magrittr
Loading required package: checkmate

bayesmeta documentation built on Oct. 11, 2018, 5:04 p.m.