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 |
This function computes values for the probability density function of a truncated random variable.
dtrunc(x, spec, a = -Inf, b = Inf, ...)
dtrunc(x, spec, a = -Inf, b = Inf, ...)
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 |
The R
function is used to access the required probability density and cumulative
distribution functions of the underlying unrestricted random variable.
A vector of density function values.
Frederick Novomestky [email protected]
Saralees Nadarajah [email protected]
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
x <- seq( 0, 3, .1 ) pdf <- dtrunc( x, spec="norm", a=1, b=2 )
x <- seq( 0, 3, .1 ) pdf <- dtrunc( x, spec="norm", a=1, b=2 )
This function computes the expected value of a truncated random variable using numerical integration.
extrunc(spec, a = -Inf, b = Inf, ...)
extrunc(spec, a = -Inf, b = Inf, ...)
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 |
Numerical integration of the truncated density function is performed to compute the expected value.
A numerical value for the expectation.
Frederick Novomestky [email protected]
Saralees Nadarajah [email protected]
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
mu <- extrunc( spec="norm",a=1, b=2 )
mu <- extrunc( spec="norm",a=1, b=2 )
This function compute values of the cumulative distribution function for truncated random variables.
ptrunc(q, spec, a = -Inf, b = Inf, ...)
ptrunc(q, spec, a = -Inf, b = Inf, ...)
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 |
A vector of probability values.
Frederick Novomestky [email protected]
Saralees Nadarajah [email protected]
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
x <- seq( 0, 3, .1 ) cdf <- ptrunc( x, spec="norm", a=1, b=2 )
x <- seq( 0, 3, .1 ) cdf <- ptrunc( x, spec="norm", a=1, b=2 )
This function produces a QQ plot of sample quantiles against theoretical quantiles for a truncated random variable.
qqtrunc(x, spec, a = -Inf, b = Inf, title = "Truncated Distribution Q-Q Plot", xlabel = "Theoretical Quantiles", ylabel = "Sample Quantiles", ...)
qqtrunc(x, spec, a = -Inf, b = Inf, title = "Truncated Distribution Q-Q Plot", xlabel = "Theoretical Quantiles", ylabel = "Sample Quantiles", ...)
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 |
A plot.
Frederick Novomestky [email protected]
Saralees Nadarajah [email protected]
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
x <- rtrunc( 500, spec="norm", a=1, b=2 ) qqtrunc( x, spec="norm", a=1, b=2 )
x <- rtrunc( 500, spec="norm", a=1, b=2 ) qqtrunc( x, spec="norm", a=1, b=2 )
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.
qtrunc(p, spec, a = -Inf, b = Inf, ...)
qtrunc(p, spec, a = -Inf, b = Inf, ...)
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 |
A vector of quantile values in the range of the truncated random variable.
Frederick Novomestky [email protected]
Saralees Nadarajah [email protected]
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
p <- seq( .1, .9, .01 ) q <- qtrunc( p, spec="norm", a=1, b=2 )
p <- seq( .1, .9, .01 ) q <- qtrunc( p, spec="norm", a=1, b=2 )
This function generates n random deviates that are drawn from the specified truncated distribution.
rtrunc(n, spec, a = -Inf, b = Inf, ...)
rtrunc(n, spec, a = -Inf, b = Inf, ...)
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 |
A vector with one or more random deviates.
Frederick Novomestky [email protected]
Saralees Nadarajah [email protected]
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
x <- rtrunc( 500, spec="norm", a=1, b=2 )
x <- rtrunc( 500, spec="norm", a=1, b=2 )
This function estimates the variance of a truncated random variable using numerical integration.
vartrunc(spec, a = -Inf, b = Inf, ...)
vartrunc(spec, a = -Inf, b = Inf, ...)
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 |
Numerical integration of the truncated density function is performed to compute the variance and the associated expected value.
A numeric value.
Frederick Novomestky [email protected]
Saralees Nadarajah [email protected]
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
var <- vartrunc( spec="norm", a=1, b=2 )
var <- vartrunc( spec="norm", a=1, b=2 )