posnormal.RdFits a positive (univariate) normal distribution.
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.
See CommonVGAMffArguments for more information.
gmean and gsd
currently operate on a multiplicative scale, on the sample mean
and the sample standard deviation, respectively.
Optional initial values for \(\mu\) and \(\sigma\).
A NULL means a value is computed internally.
See CommonVGAMffArguments for more information.
See CommonVGAMffArguments for more information.
The fact that these arguments are supported results in
default constraint matrices being a permutation of the
identity matrix (effectively trivial constraints).
See CommonVGAMffArguments for information.
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)}. $$ This family function handles multiple responses.
An object of class "vglmff"
(see vglmff-class).
The object is used by modelling functions
such as vglm,
and vgam.
The response variable for this family function is the same as
uninormal except positive values are required.
Reasonably good initial values are needed.
The distribution of the reciprocal of a positive normal random variable is known as an alpha distribution.
It is recommended that trace = TRUE be used to monitor
convergence; sometimes the estimated mean is -Inf and the
estimated mean standard deviation is Inf, especially
when the sample size is small.
Under- or over-flow may occur if the data is ill-conditioned.
pdata <- data.frame(Mean = 1.0, SD = exp(1.0))
pdata <- transform(pdata, y = rposnorm(n <- 1000, m = Mean, sd = SD))
if (FALSE) with(pdata, hist(y, prob = TRUE, border = "blue",
main = paste("posnorm(m =", Mean[1], ", sd =", round(SD[1], 2),")"))) # \dontrun{}
fit <- vglm(y ~ 1, posnormal, data = pdata, trace = TRUE)
#> Iteration 1: loglikelihood = -1861.6716
#> Iteration 2: loglikelihood = -1861.2365
#> Iteration 3: loglikelihood = -1861.2363
#> Iteration 4: loglikelihood = -1861.2363
coef(fit, matrix = TRUE)
#> mean loglink(sd)
#> (Intercept) 1.217719 0.9496246
(Cfit <- Coef(fit))
#> mean sd
#> 1.217719 2.584739
mygrid <- with(pdata, seq(min(y), max(y), len = 200))
if (FALSE) lines(mygrid, dposnorm(mygrid, Cfit[1], Cfit[2]), col = "red") # \dontrun{}