abs.tol: absolute accuracy requested, passed to integrate.
subdivisions: the maximum number of subintervals, passed to integrate.
mu: the expected value of the distribution (see effContMean).
dfun: a density function.
pfun: a distribution function.
...: additional arguments passed to other functions, if any.
Returns
cap: the original vector, but censored.
effContMean: the estimate of the expected value.
effContVar: the estimate of the variance.
effContTrunc: a list with components:
td
the truncated density function.
tp
the truncated distribution function.
tq
the truncated quantile function.
Details
cap caps (censor) a variable from below and above.
effContMean computes the expected value of a distribution by numerical integration of the given quantile function.
effContVar computes the variance of a distribution by numerical integration of the given quantile function.
effContTrun computes the density, distribution and quantile functions of the distribution resulting from truncating a given distribution between 0 and 1.
Examples
cap(c(0,.5,1))effContMean(function(p) qnorm(p, mean =4))effContMean(function(p) qbeta(p,1,2))effContVar(function(p) qnorm(p, mean =2, sd =4),2)effContVar(function(p) qbeta(p,1,2),1/3)tr <- effContTrunc(dnorm, pnorm, qnorm, mean =.8, sd =.3)x01 <- seq(0,1,.01)plot(x01, tr$d(x01), type ="l")plot(x01, tr$p(x01), type ="l")plot(x01, tr$q(x01), type ="l")