Version: | 1.0-2 |
Date: | 2016-08-29 |
Author: | Frederick Novomestky <fn334@nyu.edu>, Saralees Nadarajah <saralees.nadarajah@manchester.ac.uk> |
Maintainer: | Frederick Novomestky <fnovomes@poly.edu> |
Depends: | R (≥ 2.0.1), stats4,evd |
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.. |
Title: | Truncated Random Variables |
License: | GPL-2 | GPL-3 [expanded from: GPL (≥ 2)] |
NeedsCompilation: | no |
Packaged: | 2016-08-29 20:20:23 UTC; fred |
Repository: | CRAN |
Date/Publication: | 2016-08-30 01:27:43 |
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 fnovomes@poly.edu
Saralees Nadarajah saralees.nadarajah@manchester.ac.uk
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 fn334@nyu.edu
Saralees Nadarajah saralees.nadarajah@manchester.ac.uk
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
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 fn334@nyu.edu
Saralees Nadarajah saralees.nadarajah@manchester.ac.uk
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
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 fn334@nyu.edu
Saralees Nadarajah saralees.nadarajah@manchester.ac.uk
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
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 fn334@nyu.edu
Saralees Nadarajah saralees.nadarajah@manchester.ac.uk
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 fn334@nyu.edu
Saralees Nadarajah saralees.nadarajah@manchester.ac.uk
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
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 fn334@nyu.edu
Saralees Nadarajah saralees.nadarajah@manchester.ac.uk
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
Examples
var <- vartrunc( spec="norm", a=1, b=2 )