Learn R Programming

VGAM (version 0.9-1)

posnormal1: Positive Normal Distribution Family Function

Description

Fits a positive (univariate) normal distribution.

Usage

posnormal1(lmean = "identity", lsd = "loge",
           imean = NULL, isd = NULL, nsimEIM = 100, zero = NULL)

Arguments

lmean, lsd
Link functions for the mean and standard deviation parameters of the usual univariate normal distribution. They are $\mu$ and $\sigma$ respectively. See Links for more choices.
imean, isd
Optional initial values for $\mu$ and $\sigma$. A NULL means a value is computed internally.
nsimEIM
See CommonVGAMffArguments for more information.
zero
An integer-valued vector specifying which linear/additive predictors are modelled as intercepts only. The values must be from the set {1,2} corresponding respectively to $\mu$, $\sigma$. If zero = NULL then all linear/additive predict

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.

Details

The positive normal distribution is the ordinary normal distribution but with the probability of zero or less being zero. The rest of the probability density function is scaled up. Hence the probability density function can be written $$f(y) = \frac{1}{\sqrt{2\pi} \sigma} \exp\left( -\frac12 (y-\mu)^2 / \sigma^2 \right) / \left[ 1-\Phi(-\mu/ \sigma) \right]$$ where $\Phi()$ is the cumulative distribution function of a standard normal (pnorm). Equivalently, this is $$f(y) = \frac{1}{\sigma} \frac{\phi((y-\mu) / \sigma)}{ 1-\Phi(-\mu/ \sigma)}.$$ where $\phi()$ is the probability density function of a standard normal distribution (dnorm).

The mean of $Y$ is $$E(Y) = \mu + \sigma \frac{\phi(-\mu/ \sigma)}{ 1-\Phi(-\mu/ \sigma)}.$$

References

Documentation accompanying the VGAM package at http://www.stat.auckland.ac.nz/~yee contains further information and examples.

See Also

normal1, tobit.

Examples

Run this code
pdata <- data.frame(m = 1.0, SD = exp(1.0))
pdata <- transform(pdata, y = rposnorm(n <- 1000, m = m, sd = SD))

with(pdata, hist(y, prob = TRUE, border = "blue",
         main = paste("posnorm(m =", m[1], ", sd =", round(SD[1], 2),")")))
fit <- vglm(y ~ 1, fam = posnormal1, pdata, trace = TRUE)
coef(fit, matrix = TRUE)
(Cfit <- Coef(fit))
mygrid <- with(pdata, seq(min(y), max(y), len = 200)) # Add the fit to the histogram
lines(mygrid, dposnorm(mygrid, Cfit[1], Cfit[2]), col = "red")

Run the code above in your browser using DataLab