rtnorm: Simulate Random Left-Truncated Normal Distribution

Description Usage Arguments Details Value Examples

View source: R/rtnorm.R

Description

This function is used to generate random samples from left-truncated normal distribution with specified mean and variance.

Usage

1
rtnorm(n, mu, sd, a)

Arguments

n

Numeric scalar representing the number of observations. Must be greater than or equal to 1.

mu

Mean value of the underlying normal random variable

sd

Standard deviation of underlying normal random variable

a

Numeric vector indicating the left-truncation value.

Details

Our goal is to draw samples from the left truncated normal random variable Y_{i}^{*}. We define this distribution as

Y_{i}^{*}\sim TN(μ, σ^{2}, a)

Sampling is performed by first drawing from a random variable Z with a uniform distribution on the interval [0, 1] to generate cumulative density probabilities, p. Then the inverse density function of the truncated normal random variable is applied to generate our desired truncated normal observations.

This inverse truncated normal function is shown below:

Y_{i}^{*}=Φ^{-1}\Bigg\{p\times\bigg[1-Φ\big(\frac{a-μ}{σ}\big)\bigg] + Φ\big(\frac{a-μ}{σ}\big)\Bigg\}\timesσ+μ,

where p represents the probabilities sampled from the uniform distribution.

Notes

Value

Returns a vector of samples drawn from the left truncated normal distribution equal to length n.

Examples

1
2
#zero truncated normal data with mean 0.5 and standard deviation 1
y_star <- rtnorm(n = 100, mu = 0.5, sd = 1, a = 0)

williazo/tcensReg documentation built on July 24, 2020, 1:39 a.m.