pnorMix {nor1mix}R Documentation

Normal Mixture Cumulative Distribution and Quantiles

Description

Compute cumulative probabilities or quantiles (the inverse) for a normal mixture specified as norMix object.

Usage

pnorMix(q, obj, lower.tail = TRUE, log.p = FALSE)

qnorMix(p, obj, lower.tail = TRUE, log.p = FALSE,
        tol = .Machine$double.eps^0.25, maxiter = 1000)

Arguments

obj an object of class norMix.
p numeric vector of probabilities.
q numeric vector of quantiles
lower.tail logical; if TRUE (default), probabilities are P[X <= x], otherwise, P[X > x].
log.p logical; if TRUE, probabilities p are given as log(p).
tol, maxiter determine the root finding algorithm, see uniroot.

Details

Whereas the distribution function pnorMix is the trivial sum of weighted normal probabilities (pnorm), its inverse is currently computed numerically using uniroot to find q such that pnorMix(obj, q) == p.

Value

a numeric vector of the same length as p or q, respectively.

Author(s)

First version by Erik Jørgensen Erik.Jorgensen@agrsci.dk.

See Also

dnorMix for the density function.

Examples

MW.nm3 # the "strange skew" one
plot(MW.nm3)
## now the cumlative :
x <- seq(-4,4, length=1001)
plot(x, pnorMix(x, MW.nm3), type="l", col=2)
## and some of its inverse :
pp <- seq(.1, .9, by=.1)
plot(qnorMix(pp, MW.nm3), pp)

## The "true" median of a normal mixture:
median.norMix <- function(x) qnorMix(1/2, x)
median.norMix(MW.nm3) ## -2.32

[Package nor1mix version 1.0-7 Index]