R Under development (unstable) (2025-10-28 r88973 ucrt) -- "Unsuffered Consequences" Copyright (C) 2025 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > > library("mlt") Loading required package: basefun Loading required package: variables > library("numDeriv") > > ### 10.1080/15598608.2013.772835 > ### rho = exp(logrho) > ### 1 = rho = exp(0) is identical to .Logistic > lg <- mlt:::.GammaFrailty(logrho = 0) > x <- -30:30 / 20 > p <- 1:99 / 100 > tol <- sqrt(.Machine$double.eps) > stopifnot(max(abs(lg$p(x) - mlt:::.Logistic()$p(x))) < tol) > > stopifnot(max(abs(lg$d(x) - mlt:::.Logistic()$d(x))) < tol) > > stopifnot(max(abs(lg$dd(x) - mlt:::.Logistic()$dd(x))) < tol) > > stopifnot(max(abs(lg$ddd(x) - mlt:::.Logistic()$ddd(x))) < tol) > > stopifnot(max(abs(lg$dd2d(x) - mlt:::.Logistic()$dd2d(x))) < tol) > > stopifnot(max(abs(lg$q(p) - mlt:::.Logistic()$q(p))) < tol) > > ### 0 = rho = exp(-infty) is identical to .MinExtrVal > tol <- (.Machine$double.eps)^(1 / 2.5) > lg <- mlt:::.GammaFrailty(logrho = -18) > stopifnot(max(abs(lg$p(x) - mlt:::.MinExtrVal()$p(x))) < tol) > > stopifnot(max(abs(lg$d(x) - mlt:::.MinExtrVal()$d(x))) < tol) > > stopifnot(max(abs(lg$dd(x) - mlt:::.MinExtrVal()$dd(x))) < tol) > > stopifnot(max(abs(lg$ddd(x) - mlt:::.MinExtrVal()$ddd(x))) < tol) > > stopifnot(max(abs(lg$dd2d(x) - mlt:::.MinExtrVal()$dd2d(x))) < tol) > > stopifnot(max(abs(lg$q(p) - mlt:::.MinExtrVal()$q(p))) < tol) > > ### logitalpha = logit(1) is identical to .MinExtrVal > tol <- (.Machine$double.eps)^(1 / 2.5) > lg <- mlt:::.PositiveStableFrailty(logitalpha = 50) > stopifnot(max(abs(lg$p(x) - mlt:::.MinExtrVal()$p(x))) < tol) > > stopifnot(max(abs(lg$d(x) - mlt:::.MinExtrVal()$d(x))) < tol) > > stopifnot(max(abs(lg$dd(x) - mlt:::.MinExtrVal()$dd(x))) < tol) > > stopifnot(max(abs(lg$ddd(x) - mlt:::.MinExtrVal()$ddd(x))) < tol) > > stopifnot(max(abs(lg$dd2d(x) - mlt:::.MinExtrVal()$dd2d(x))) < tol) > > stopifnot(max(abs(lg$q(p) - mlt:::.MinExtrVal()$q(p))) < tol) > > ### log.p in quantile > prb <- 1:9 / 10 > d <- eval(formals(mlt:::.distr)$which) > q1 <- sapply(d, function(w) mlt:::.distr(which = w)$q(prb)) > q2 <- sapply(d, function(w) mlt:::.distr(which = w)$q(log(prb), log.p = TRUE)) > stopifnot(isTRUE(all.equal(q1, q2))) > > x <- -20:20 + .5 > d1 <- sapply(d, function(w) grad(mlt:::.distr(which = w)$p, x)) > d2 <- sapply(d, function(w) mlt:::.distr(which = w)$d(x)) > stopifnot(isTRUE(all.equal(d1, d2))) > > d1 <- sapply(d, function(w) grad(mlt:::.distr(which = w)$d, x)) > d2 <- sapply(d, function(w) mlt:::.distr(which = w)$dd(x)) > stopifnot(isTRUE(all.equal(d1, d2))) > > d1 <- sapply(d, function(w) grad(mlt:::.distr(which = w)$dd, x)) > d2 <- sapply(d, function(w) mlt:::.distr(which = w)$ddd(x)) > stopifnot(isTRUE(all.equal(d1, d2))) > > prm <- -7:7 > q1 <- sapply(prm, function(p) mlt:::.GammaFrailty(p)$q(prb)) > q2 <- sapply(prm, function(p) mlt:::.GammaFrailty(p)$q(log(prb), log.p = TRUE)) > stopifnot(isTRUE(all.equal(q1, q2))) > > d1 <- sapply(prm, function(p) grad(mlt:::.GammaFrailty(p)$p, x)) > d2 <- sapply(prm, function(p) mlt:::.GammaFrailty(p)$d(x)) > stopifnot(isTRUE(all.equal(d1, d2))) > > d1 <- sapply(prm, function(p) grad(mlt:::.GammaFrailty(p)$d, x)) > d2 <- sapply(prm, function(p) mlt:::.GammaFrailty(p)$dd(x)) > stopifnot(isTRUE(all.equal(d1, d2))) > > d1 <- sapply(prm, function(p) grad(mlt:::.GammaFrailty(p)$dd, x)) > d2 <- sapply(prm, function(p) mlt:::.GammaFrailty(p)$ddd(x)) > stopifnot(isTRUE(all.equal(d1, d2))) > > q1 <- sapply(prm, function(p) mlt:::.InvGaussFrailty(p)$q(prb)) > q2 <- sapply(prm, function(p) mlt:::.InvGaussFrailty(p)$q(log(prb), log.p = TRUE)) > stopifnot(isTRUE(all.equal(q1, q2))) > > d1 <- sapply(prm, function(p) grad(mlt:::.InvGaussFrailty(p)$p, x)) > d2 <- sapply(prm, function(p) mlt:::.InvGaussFrailty(p)$d(x)) > stopifnot(isTRUE(all.equal(d1, d2))) > > d1 <- sapply(prm, function(p) grad(mlt:::.InvGaussFrailty(p)$d, x)) > d2 <- sapply(prm, function(p) mlt:::.InvGaussFrailty(p)$dd(x)) > stopifnot(isTRUE(all.equal(d1, d2))) > > d1 <- sapply(prm, function(p) grad(mlt:::.InvGaussFrailty(p)$dd, x)) > d2 <- sapply(prm, function(p) mlt:::.InvGaussFrailty(p)$ddd(x)) > stopifnot(isTRUE(all.equal(d1, d2))) > > q1 <- sapply(prm, function(p) mlt:::.PositiveStableFrailty(p)$q(prb)) > q2 <- sapply(prm, function(p) mlt:::.PositiveStableFrailty(p)$q(log(prb), log.p = TRUE)) > stopifnot(isTRUE(all.equal(q1, q2))) > > d1 <- sapply(prm, function(p) grad(mlt:::.PositiveStableFrailty(p)$p, x)) > d2 <- sapply(prm, function(p) mlt:::.PositiveStableFrailty(p)$d(x)) > stopifnot(isTRUE(all.equal(d1, d2))) > > d1 <- sapply(prm, function(p) grad(mlt:::.PositiveStableFrailty(p)$d, x)) > d2 <- sapply(prm, function(p) mlt:::.PositiveStableFrailty(p)$dd(x)) > stopifnot(isTRUE(all.equal(d1, d2))) > > d1 <- sapply(prm, function(p) grad(mlt:::.PositiveStableFrailty(p)$dd, x)) > d2 <- sapply(prm, function(p) mlt:::.PositiveStableFrailty(p)$ddd(x)) > stopifnot(isTRUE(all.equal(d1, d2))) > > > > proc.time() user system elapsed 1.09 0.18 1.26