# truncnormalff: Truncated normal Distribution Family Function In VGAMextra: Additions and Extensions of the 'VGAM' Package

 truncnormal R Documentation

## Truncated normal Distribution Family Function

### Description

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

### Usage

 truncnormal(lmean = "identitylink", lsd = "loglink",
min.support = -Inf, max.support = Inf, zero = "sd")


### Arguments

 lmean, lsd Link functions applied to mean and standard deviation/variance. min.support, max.support Vector of lower and upper truncation limits (recycled). min.support enables LHS truncation and max.support enables RHS truncation. The default imply no truncation (mimicks uninormal). zero See CommonVGAMffArguments for more information.

### Details

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

The truncated–normal density for a response Y is

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

where f is the probability density function of standard normal distribution and \Phi is the standard normal CDF.

The mean of Y, given by

 \mu + [\varphi(\texttt{min.support}) + \varphi(\texttt{max.support})/\Delta \Phi(\mu,\sigma)]\cdot \sigma, 

with \Delta \Phi(\mu, \sigma) = \Phi((\texttt{max.support} - \mu)/\sigma ) - \Phi( (\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)

Siqi (Vicky) Liu, Victor Miranda, 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.

uninormal, CommonVGAMffArguments.

### Examples

nn <- 2000
set.seed(14290909)

## Parameters
mysd <- exp(1.0)   # sd
LL   <- -0.5       # Lower bound
UL   <-  8.0       # Upper bound

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

##############################################################
# Fitting a truncated normal distribution - sd is intercept only
fit1 <- vglm(y1 ~ x2, truncnormal(zero = "sd", 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, truncnormal(zero = NULL, min.support = LL, max.support = UL),
data = ldata2, trace = TRUE)
coef(fit2, matrix = TRUE)
vcov(fit2)

##############################################################
# Mimicking uninormal()
fit3 <- vglm(y1 ~ x2, truncnormal(zero = "sd"),
data = ldata2, trace = TRUE)
coef(fit3, mat = TRUE)

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



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