trunclognormalff: Truncated Log-normal Distribution Family Function

trunclognormalR Documentation

Truncated Log-normal Distribution Family Function

Description

Maximum likelihood estimate of the two–parameter lognormal distribution with lower/upper truncation.

Usage

 trunclognormal(lmeanlog = "identitylink", lsdlog = "loglink",
                min.support = 1e-6, max.support = Inf, zero = "sdlog") 

Arguments

lmeanlog, lsdlog, zero

Same as lognormal.

min.support, max.support

Positive lower and upper truncation limits (recycled). min.support enables LHS truncation; max.support enables RHS truncation (default is none).

Details

MLE of the two–parameter (univariate) lognormal distribution subject to lower/upper truncation. All response values are greater than min.support and lower than max.support.

Default values of min.support, max.suppport should effectively reproduce lognormal.

The truncated–lognormal density for a response Y is

f(y; \mu, \sigma) = f_N(y; \mu, \sigma) / [\Phi(\texttt{max.support}, \mu, \sigma) - \Phi(\texttt{min.support},\mu, \sigma) ],

where f_N is the ordinary lognormal density (see lognormal) and \Phi is the standard normal CDF.

The mean of Y, given by

\exp{(\mu + \sigma^2/2)} \cdot [\Phi(((\log(\texttt{max.support}) - \mu)/\sigma) - \sigma) - \Phi(((\log(\texttt{min.support}) - \mu)/\sigma) - \sigma) ] / \Delta \Phi(\mu,\sigma),

with \Delta \Phi(\mu, \sigma) = \Phi( (\log(\texttt{max.support}) - \mu)/\sigma ) - \Phi( (\log(\texttt{min.support}) - \mu)/\sigma ), are returned as the fitted values.

Value

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

Author(s)

Victor Miranda, Siqi (Vicky) Liu and Thomas W. Yee.

References

Nadarajah, S. and Kotz, S. (2003). R Programs for Computing Truncated Distributions. Journal of Statistical Software, Code Snippets, 16(2), 1–8.

Cohen, A.C. (1991) Truncated and Censored Samples: Theory and Applications, New York, USA. Marcel Dekker.

See Also

lognormal, uninormal, CommonVGAMffArguments, Lognormal.

Examples

##########
set.seed(10470923)
nn <- 3000

## Parameters
mysdlog   <- exp(-1.5)   # sdlog
LL   <- 3.5              # Lower bound
UL   <- 8.0              # Upper bound

## Truncated data
ldata2 <- data.frame(x2 = runif(nn))
ldata2 <- transform(ldata2, y1 = rtrunclnorm(nn, 1 + 1.5 * x2, mysdlog, 
                                             min.support = LL, max.support = UL))
# head(ldata2)
# hist(ldata2$y1, breaks = 22, col = "blue", xlim = c(0, 10))

##############################################################
# Fitting a truncated lognormal distribution - sd is intercept only
fit1 <- vglm(y1 ~ x2, trunclognormal(zero = "sdlog", min.support = LL, max.support = UL),
             data = ldata2, trace = TRUE)
coef(fit1, matrix = TRUE)
vcov(fit1)
             
##############################################################
# Fitting a truncated lognormal distribution - zero = NULL
fit2 <- vglm(y1 ~ x2, trunclognormal(zero = NULL, min.support = LL, max.support = UL),
             data = ldata2, trace = TRUE)
coef(fit2, matrix = TRUE)
vcov(fit2)

##############################################################
# Mimicking lognormal()
fit3 <- vglm(y1 ~ x2, trunclognormal(zero = "sdlog"),
             data = ldata2, trace = TRUE)
coef(fit3, mat = TRUE)

# Same as
fit3bis <- vglm(y1 ~ x2, lognormal(zero = "sdlog"),
                 data = ldata2, trace = TRUE)
coef(fit3bis, mat = TRUE)

VGAMextra documentation built on Nov. 2, 2023, 5:59 p.m.