makehamUC.RdDensity, cumulative distribution function, quantile function and random generation for the Makeham distribution.
dmakeham(x, scale = 1, shape, epsilon = 0, log = FALSE)
pmakeham(q, scale = 1, shape, epsilon = 0, lower.tail = TRUE,
log.p = FALSE)
qmakeham(p, scale = 1, shape, epsilon = 0, lower.tail = TRUE,
log.p = FALSE)
rmakeham(n, scale = 1, shape, epsilon = 0)vector of quantiles.
vector of probabilities.
number of observations.
Same as in runif.
Logical.
If log = TRUE then the logarithm of the density is
returned.
positive scale and shape parameters.
another parameter. Must be non-negative. See below.
dmakeham gives the density,
pmakeham gives the cumulative distribution function,
qmakeham gives the quantile function, and
rmakeham generates random deviates.
See makeham for details.
The default value of epsilon = 0 corresponds
to the Gompertz distribution.
The function pmakeham uses lambertW.
Jodra, P. (2009). A closed-form expression for the quantile function of the Gompertz-Makeham distribution. Mathematics and Computers in Simulation, 79, 3069–3075.
probs <- seq(0.01, 0.99, by = 0.01)
Shape <- exp(-1); Scale <- exp(1); eps = Epsilon <- exp(-1)
max(abs(pmakeham(qmakeham(probs, sca = Scale, Shape, eps = Epsilon),
sca = Scale, Shape, eps = Epsilon) - probs)) # Should be 0
#> [1] 5.551115e-16
if (FALSE) x <- seq(-0.1, 2.0, by = 0.01);
plot(x, dmakeham(x, sca = Scale, Shape, eps = Epsilon), type = "l",
main = "Blue is density, orange is the CDF",
sub = "Purple lines are the 10,20,...,90 percentiles",
col = "blue", las = 1, ylab = "")
#> Error in h(simpleError(msg, call)): error in evaluating the argument 'x' in selecting a method for function 'plot': object 'x' not found
abline(h = 0, col = "blue", lty = 2)
#> Error in int_abline(a = a, b = b, h = h, v = v, untf = untf, ...): plot.new has not been called yet
lines(x, pmakeham(x, sca = Scale, Shape, eps = Epsilon), col = "orange")
#> Error: object 'x' not found
probs <- seq(0.1, 0.9, by = 0.1)
Q <- qmakeham(probs, sca = Scale, Shape, eps = Epsilon)
lines(Q, dmakeham(Q, sca = Scale, Shape, eps = Epsilon),
col = "purple", lty = 3, type = "h")
#> Error in plot.xy(xy.coords(x, y), type = type, ...): plot.new has not been called yet
pmakeham(Q, sca = Scale, Shape, eps = Epsilon) - probs # Should be all 0
#> [1] -4.163336e-17 5.551115e-17 5.551115e-17 -1.110223e-16 0.000000e+00
#> [6] 1.110223e-16 4.440892e-16 -5.551115e-16 -1.110223e-16
abline(h = probs, col = "purple", lty = 3) # \dontrun{}
#> Error in int_abline(a = a, b = b, h = h, v = v, untf = untf, ...): plot.new has not been called yet