Description Usage Arguments Details Value References Examples
This function computes values for the probability density function of a truncated random variable. It was originally implemented in package truncdist and slightly modified to return zeros in case that the trunction interval [a, b] is not inside the support of the density function.
1 |
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 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.
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
1 2 3 4 5 6 7 8 9 | x <- seq(0, 3, 0.1)
dtrunc(x, spec = "norm", a = 1, b = 2)
curve(dtrunc(x, spec = "norm", a = -Inf, b = 1), -10, 2)
## Not run:
# different results for intervals outside the support of the density function:
truncdist::dtrunc(x, spec = "norm", a = 20, b = 30) # gives error
momcalc::dtrunc(x, spec = "norm", a = 20, b = 30) # gives only a warning
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.