Package 'truncdist'

Title: Truncated Random Variables
Description: A collection of tools to evaluate probability density functions, cumulative distribution functions, quantile functions and random numbers for truncated random variables. These functions are provided to also compute the expected value and variance. Nadarajah and Kotz (2006) developed most of the functions. QQ plots can be produced. All the probability functions in the stats, stats4 and evd packages are automatically available for truncation..
Authors: Frederick Novomestky <[email protected]>, Saralees Nadarajah <[email protected]>
Maintainer: Frederick Novomestky <[email protected]>
License: GPL (>= 2)
Version: 1.0-2
Built: 2024-12-15 07:33:55 UTC
Source: CRAN

Help Index


Probability density function of truncated random variables

Description

This function computes values for the probability density function of a truncated random variable.

Usage

dtrunc(x, spec, a = -Inf, b = Inf, ...)

Arguments

x

A numeric vector of quantile values

spec

a character value that specifies the underlying probability distribution

a

a numeric value for the lower bound of the random variable

b

a numeric value for the upper bound of the random variable

...

other arguments are are passed to the corresponding quantile function

Details

The R function is used to access the required probability density and cumulative distribution functions of the underlying unrestricted random variable.

Value

A vector of density function values.

Author(s)

Frederick Novomestky [email protected]

Saralees Nadarajah [email protected]

References

Nadarajah, S. and S. Kotz, 2006. R Programs for Computing Truncated Distributions, Journal of Statistical Software, 16, August 2006, http://www.jstatsoft.org/v16/c02

Examples

x <- seq( 0, 3, .1 )
pdf <- dtrunc( x, spec="norm", a=1, b=2 )

Expected value of a truncated random variable

Description

This function computes the expected value of a truncated random variable using numerical integration.

Usage

extrunc(spec, a = -Inf, b = Inf, ...)

Arguments

spec

a character value that specifies the underlying probability distribution

a

a numeric value for the lower bound of the random variable

b

a numeric value for the upper bound of the random variable

...

other arguments are are passed to the corresponding quantile function

Details

Numerical integration of the truncated density function is performed to compute the expected value.

Value

A numerical value for the expectation.

Author(s)

Frederick Novomestky [email protected]

Saralees Nadarajah [email protected]

References

Nadarajah, S. and S. Kotz, 2006. R Programs for Computing Truncated Distributions, Journal of Statistical Software, 16, August 2006, http://www.jstatsoft.org/v16/c02

See Also

dtrunc

Examples

mu <- extrunc( spec="norm",a=1, b=2 )

Cumulative distribution function of a truncated random variable

Description

This function compute values of the cumulative distribution function for truncated random variables.

Usage

ptrunc(q, spec, a = -Inf, b = Inf, ...)

Arguments

q

a numeric vector of quantile values

spec

a character value that specifies the underlying probability distribution

a

a numeric value for the lower bound of the random variable

b

a numeric value for the upper bound of the random variable

...

other arguments are are passed to the corresponding quantile function

Value

A vector of probability values.

Author(s)

Frederick Novomestky [email protected]

Saralees Nadarajah [email protected]

References

Nadarajah, S. and S. Kotz, 2006. R Programs for Computing Truncated Distributions, Journal of Statistical Software, 16, August 2006, http://www.jstatsoft.org/v16/c02

See Also

dtrunc

Examples

x <- seq( 0, 3, .1 )
cdf <- ptrunc( x, spec="norm", a=1, b=2 )

QQ Plot for a Truncated Random Variable

Description

This function produces a QQ plot of sample quantiles against theoretical quantiles for a truncated random variable.

Usage

qqtrunc(x, spec, a = -Inf, b = Inf, title = "Truncated Distribution Q-Q Plot", 
xlabel = "Theoretical Quantiles", ylabel = "Sample Quantiles", ...)

Arguments

x

a numeric vector of sample values

spec

a character value that specifies the underlying probability distribution

a

a numeric value for the lower bound of the random variable

b

a numeric value for the upper bound of the random variable

title

A character value for the chart title

xlabel

A character value for the horizon axis label

ylabel

A character value for the vertical axis label

...

other arguments are are passed to the corresponding quantile function

Value

A plot.

Author(s)

Frederick Novomestky [email protected]

Saralees Nadarajah [email protected]

References

Nadarajah, S. and S. Kotz, 2006. R Programs for Computing Truncated Distributions, Journal of Statistical Software, 16, August 2006, http://www.jstatsoft.org/v16/c02

See Also

qtrunc

Examples

x <- rtrunc( 500, spec="norm", a=1, b=2 )
qqtrunc( x, spec="norm", a=1, b=2 )

Quantitle Function for Truncated Random Variable

Description

This function evaluates the inverse of the cumulative distribution funciton for a truncated random variable or so the so called quantile function for a given vector of probabilities and the specified distribution.

Usage

qtrunc(p, spec, a = -Inf, b = Inf, ...)

Arguments

p

A vector of probabilities

spec

a character value that specifies the underlying probability distribution

a

a numeric value for the lower bound of the random variable

b

a numeric value for the upper bound of the random variable

...

other arguments are are passed to the corresponding quantile and distribution function

Value

A vector of quantile values in the range of the truncated random variable.

Author(s)

Frederick Novomestky [email protected]

Saralees Nadarajah [email protected]

References

Nadarajah, S. and S. Kotz, 2006. R Programs for Computing Truncated Distributions, Journal of Statistical Software, 16, August 2006, http://www.jstatsoft.org/v16/c02

Examples

p <- seq( .1, .9, .01 )
q <- qtrunc( p, spec="norm", a=1, b=2 )

Generate truncated random deviates

Description

This function generates n random deviates that are drawn from the specified truncated distribution.

Usage

rtrunc(n, spec, a = -Inf, b = Inf, ...)

Arguments

n

a positive integer for the number of random deviates generated

spec

a character value that specifies the underlying probability distribution

a

a numeric value for the lower bound of the random variable

b

a numeric value for the upper bound of the random variable

...

other arguments are are passed to the corresponding quantile function

Value

A vector with one or more random deviates.

Author(s)

Frederick Novomestky [email protected]

Saralees Nadarajah [email protected]

References

Nadarajah, S. and S. Kotz, 2006. R Programs for Computing Truncated Distributions, Journal of Statistical Software, 16, August 2006, http://www.jstatsoft.org/v16/c02

See Also

qtrunc

Examples

x <- rtrunc( 500, spec="norm", a=1, b=2 )

Variance of a truncated random variable

Description

This function estimates the variance of a truncated random variable using numerical integration.

Usage

vartrunc(spec, a = -Inf, b = Inf, ...)

Arguments

spec

a character value that specifies the underlying probability distribution

a

a numeric value for the lower bound of the random variable

b

a numeric value for the upper bound of the random variable

...

other arguments are are passed to the corresponding quantile function

Details

Numerical integration of the truncated density function is performed to compute the variance and the associated expected value.

Value

A numeric value.

Author(s)

Frederick Novomestky [email protected]

Saralees Nadarajah [email protected]

References

Nadarajah, S. and S. Kotz, 2006. R Programs for Computing Truncated Distributions, Journal of Statistical Software, 16, August 2006, http://www.jstatsoft.org/v16/c02

See Also

extrunc, dtrunc

Examples

var <- vartrunc( spec="norm", a=1, b=2 )