Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

foldnormUC

The Folded-Normal Distribution


Description

Density, distribution function, quantile function and random generation for the (generalized) folded-normal distribution.

Usage

dfoldnorm(x, mean = 0, sd = 1, a1 = 1, a2 = 1, log = FALSE)
pfoldnorm(q, mean = 0, sd = 1, a1 = 1, a2 = 1,
          lower.tail = TRUE, log.p = FALSE)
qfoldnorm(p, mean = 0, sd = 1, a1 = 1, a2 = 1,
          lower.tail = TRUE, log.p = FALSE, ...)
rfoldnorm(n, mean = 0, sd = 1, a1 = 1, a2 = 1)

Arguments

x, q

vector of quantiles.

p

vector of probabilities.

n

number of observations. Same as rnorm.

mean, sd

see rnorm.

a1, a2

see foldnormal.

log

Logical. If TRUE then the log density is returned.

lower.tail, log.p

Same meaning as in pnorm or qnorm.

...

Arguments that can be passed into uniroot.

Details

See foldnormal, the VGAM family function for estimating the parameters, for the formula of the probability density function and other details.

Value

dfoldnorm gives the density, pfoldnorm gives the distribution function, qfoldnorm gives the quantile function, and rfoldnorm generates random deviates.

Author(s)

T. W. Yee and Kai Huang. Suggestions from Mauricio Romero led to improvements in qfoldnorm().

See Also

Examples

## Not run: 
m <- 1.5; SD <- exp(0)
x <- seq(-1, 4, len = 501)
plot(x, dfoldnorm(x, m = m, sd = SD), type = "l", ylim = 0:1, las = 1,
     ylab = paste("foldnorm(m = ", m, ", sd = ",
                  round(SD, digits = 3), ")"),
     main = "Blue is density, orange is cumulative distribution function",
     sub = "Purple lines are the 10,20,...,90 percentiles", col = "blue")
abline(h = 0, col = "gray50")
lines(x, pfoldnorm(x, m = m, sd = SD), col = "orange")
probs <- seq(0.1, 0.9, by = 0.1)
Q <- qfoldnorm(probs, m = m, sd = SD)
lines(Q, dfoldnorm(Q, m, SD), col = "purple", lty = 3, type = "h")
lines(Q, pfoldnorm(Q, m, SD), col = "purple", lty = 3, type = "h")
abline(h = probs, col = "purple", lty = 3)
max(abs(pfoldnorm(Q, m = m, sd = SD) - probs))  # Should be 0

## End(Not run)

VGAM

Vector Generalized Linear and Additive Models

v1.1-5
GPL-3
Authors
Thomas Yee [aut, cre], Cleve Moler [ctb] (author of several LINPACK routines)
Initial release
2021-01-13

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.