50% off | Unlimited Data & AI Learning
Get 50% off unlimited learning

VGAM (version 1.1-3)

foldnormal: Folded Normal Distribution Family Function

Description

Fits a (generalized) folded (univariate) normal distribution.

Usage

foldnormal(lmean = "identitylink", lsd = "loglink", imean = NULL, isd = NULL,
           a1 = 1, a2 = 1, nsimEIM = 500, imethod = 1, zero = NULL)

Arguments

lmean, lsd

Link functions for the mean and standard deviation parameters of the usual univariate normal distribution. They are μ and σ respectively. See Links for more choices.

imean, isd

Optional initial values for μ and σ. A NULL means a value is computed internally. See CommonVGAMffArguments.

a1, a2

Positive weights, called a1 and a2 below. Each must be of length 1.

nsimEIM, imethod, zero

Value

An object of class "vglmff" (see vglmff-class). The object is used by modelling functions such as vglm and vgam.

Warning

Under- or over-flow may occur if the data is ill-conditioned. It is recommended that several different initial values be used to help avoid local solutions.

Details

If a random variable has an ordinary univariate normal distribution then the absolute value of that random variable has an ordinary folded normal distribution. That is, the sign has not been recorded; only the magnitude has been measured.

More generally, suppose X is normal with mean mean and standard deviation sd. Let Y=max(a1X,a2X) where a1 and a2 are positive weights. This means that Y=a1X for X>0, and Y=a2X for X<0. Then Y is said to have a generalized folded normal distribution. The ordinary folded normal distribution corresponds to the special case a1=a2=1.

The probability density function of the ordinary folded normal distribution can be written dnorm(y, mean, sd) + dnorm(y, -mean, sd) for y0. By default, mean and log(sd) are the linear/additive predictors. Having mean=0 and sd=1 results in the half-normal distribution. The mean of an ordinary folded normal distribution is E(Y)=σ2/πexp(μ2/(2σ2))+μ[12Φ(μ/σ)] and these are returned as the fitted values. Here, Φ() is the cumulative distribution function of a standard normal (pnorm).

References

Lin, P. C. (2005). Application of the generalized folded-normal distribution to the process capability measures. International Journal of Advanced Manufacturing Technology, 26, 825--830.

Johnson, N. L. (1962). The folded normal distribution: accuracy of estimation by maximum likelihood. Technometrics, 4, 249--256.

See Also

rfoldnorm, uninormal, dnorm, skewnormal.

Examples

Run this code
# NOT RUN {
 m <-  2; SD <- exp(1)
fdata <- data.frame(y = rfoldnorm(n <- 1000, m = m, sd = SD))
hist(with(fdata, y), prob = TRUE, main = paste("foldnormal(m = ", m,
     ", sd = ", round(SD, 2), ")"))
fit <- vglm(y ~ 1, foldnormal, data = fdata, trace = TRUE)
coef(fit, matrix = TRUE)
(Cfit <- Coef(fit))
# Add the fit to the histogram:
mygrid <- with(fdata, seq(min(y), max(y), len = 200))
lines(mygrid, dfoldnorm(mygrid, Cfit[1], Cfit[2]), col = "orange")
# }

Run the code above in your browser using DataLab