effCont-helper function

Helper functions for continuous effectiveness distributions

Helper functions for continuous effectiveness distributions

These are functions to help in the creation and use of continuous effectiveness distributions.

cap(x, xmin = 1e-06, xmax = 1 - xmin) effContMean(qfun, abs.tol = 1e-06, subdivisions = 500) effContVar(qfun, mu, abs.tol = 1e-06, subdivisions = 500) effContTrunc(dfun, pfun, qfun, ...)

Arguments

  • x: a sample of effectiveness scores.
  • xmin: lowest value to cap scores.
  • xmax: highest value to cap scores.
  • qfun: a quantile function.
  • 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:

tdthe truncated density function.
tpthe truncated distribution function.
tqthe 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")

See Also

eff.cont.

  • Maintainer: Julián Urbano
  • License: MIT + file LICENSE
  • Last published: 2018-06-15