R Under development (unstable) (2025-11-17 r89032 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("tram") Loading required package: mlt Loading required package: basefun Loading required package: variables Loading required package: mvtnorm > library("multcomp") Loading required package: survival Loading required package: TH.data Loading required package: MASS Attaching package: 'TH.data' The following object is masked from 'package:MASS': geyser > > m <- BoxCox(dist ~ speed, data = cars) > m$negative [1] TRUE > coef(m) speed 0.3059938 > nd <- data.frame(speed = as.double(1:5 * 5)) > > PI(m, newdata = nd) [,1] [,2] [,3] [,4] [,5] [1,] 0.8603407 0.9847564 0.9994139 0.9999925 1 > lp15 <- c(predict(m, newdata = data.frame(speed = 15))) > PI(m, newdata = nd, reference = lp15) [,1] [,2] [,3] [,4] [,5] [1,] 0.01524358 0.1396593 0.5 0.8603407 0.9847564 > PI(m, newdata = nd, reference = nd[3,,drop = FALSE]) [,1] [,2] [,3] [,4] [,5] [1,] 0.01524358 0.1396593 0.5 0.8603407 0.9847564 > PI(m, newdata = nd, reference = nd) 1 2 3 4 2 0.8603407 3 0.9847564 0.8603407 4 0.9994139 0.9847564 0.8603407 5 0.9999925 0.9994139 0.9847564 0.8603407 > > F <- m$model$todistr$p > Q <- m$model$todistr$q > f <- function(p, b) F(Q(p) - b) > lp <- predict(m, newdata = nd, type = "lp") > integrate(f, lower = 0, upper = 1, b = lp[2] - lp[1]) 0.1396592 with absolute error < 0.00012 > > OVL(m, newdata = nd) [,1] [,2] [,3] [,4] [,5] [1,] 0.4442808 0.1260244 0.02173579 0.002213829 0.0001308133 > lp15 <- c(predict(m, newdata = data.frame(speed = 15))) > OVL(m, newdata = nd, reference = lp15) [,1] [,2] [,3] [,4] [,5] [1,] 0.1260244 0.4442808 1 0.4442808 0.1260244 > OVL(m, newdata = nd, reference = nd[3,,drop = FALSE]) [,1] [,2] [,3] [,4] [,5] [1,] 0.1260244 0.4442808 1 0.4442808 0.1260244 > OVL(m, newdata = nd, reference = nd) 1 2 3 4 2 0.444280785 3 0.126024411 0.444280785 4 0.021735792 0.126024411 0.444280785 5 0.002213829 0.021735792 0.126024411 0.444280785 > > d <- m$model$todistr$d > Q <- m$model$todistr$q > f <- function(p, b) pmin(1, d(Q(p) - b) / d(Q(p))) > lp <- predict(m, newdata = nd, type = "lp") > integrate(f, lower = 0, upper = 1, b = lp[2] - lp[1]) 0.4442814 with absolute error < 8.4e-05 > > m <- Colr(dist ~ speed, data = cars) > m$negative [1] FALSE > coef(m) speed -0.5297381 > nd <- data.frame(speed = as.double(1:5 * 5)) > > PI(m, newdata = nd) [,1] [,2] [,3] [,4] [,5] [1,] 0.859135 0.9782508 0.9975389 0.9997597 0.9999783 > lp15 <- c(predict(m, newdata = data.frame(speed = 15))) > PI(m, newdata = nd, reference = lp15) [,1] [,2] [,3] [,4] [,5] [1,] 0.02174923 0.140865 0.5 0.859135 0.9782508 > PI(m, newdata = nd, reference = nd[3,,drop = FALSE]) [,1] [,2] [,3] [,4] [,5] [1,] 0.02174923 0.140865 0.5 0.859135 0.9782508 > PI(m, newdata = nd, reference = nd) 1 2 3 4 2 0.8591350 3 0.9782508 0.8591350 4 0.9975389 0.9782508 0.8591350 5 0.9997597 0.9975389 0.9782508 0.8591350 > > F <- m$model$todistr$p > Q <- m$model$todistr$q > f <- function(p, b) F(Q(p) + b) > lp <- predict(m, newdata = nd, type = "lp") > integrate(f, lower = 0, upper = 1, b = lp[2] - lp[1]) 0.140865 with absolute error < 9.4e-05 > > > OVL(m, newdata = nd) [,1] [,2] [,3] [,4] [,5] [1,] 0.4201925 0.1321395 0.03693743 0.009959524 0.002658723 > lp15 <- c(predict(m, newdata = data.frame(speed = 15))) > OVL(m, newdata = nd, reference = lp15) [,1] [,2] [,3] [,4] [,5] [1,] 0.1321395 0.4201925 1 0.4201925 0.1321395 > OVL(m, newdata = nd, reference = nd[3,,drop = FALSE]) [,1] [,2] [,3] [,4] [,5] [1,] 0.1321395 0.4201925 1 0.4201925 0.1321395 > OVL(m, newdata = nd, reference = nd) 1 2 3 4 2 0.420192533 3 0.132139533 0.420192533 4 0.036937428 0.132139533 0.420192533 5 0.009959524 0.036937428 0.132139533 0.420192533 > > d <- m$model$todistr$d > Q <- m$model$todistr$q > f <- function(p, b) pmin(1, d(Q(p) + b) / d(Q(p))) > lp <- predict(m, newdata = nd, type = "lp") > integrate(f, lower = 0, upper = 1, b = lp[2] - lp[1]) 0.4201909 with absolute error < 8.9e-05 > > > m <- Coxph(dist ~ speed, data = cars) > m$negative [1] FALSE > coef(m) speed -0.2781254 > nd <- data.frame(speed = as.double(1:5 * 5)) > > PI(m, newdata = nd) [,1] [,2] [,3] [,4] [,5] [1,] 0.8006923 0.9416544 0.984811 0.9961755 0.9990453 > lp15 <- c(predict(m, newdata = data.frame(speed = 15))) > PI(m, newdata = nd, reference = lp15) [,1] [,2] [,3] [,4] [,5] [1,] 0.05834563 0.1993077 0.5 0.8006923 0.9416544 > PI(m, newdata = nd, reference = nd[3,,drop = FALSE]) [,1] [,2] [,3] [,4] [,5] [1,] 0.05834563 0.1993077 0.5 0.8006923 0.9416544 > PI(m, newdata = nd, reference = nd) 1 2 3 4 2 0.8006923 3 0.9416544 0.8006923 4 0.9848110 0.9416544 0.8006923 5 0.9961755 0.9848110 0.9416544 0.8006923 > > F <- m$model$todistr$p > Q <- m$model$todistr$q > f <- function(p, b) F(Q(p) + b) > lp <- predict(m, newdata = nd, type = "lp") > integrate(f, lower = 0, upper = 1, b = lp[2] - lp[1]) 0.1993077 with absolute error < 2.2e-16 > > > OVL(m, newdata = nd) [,1] [,2] [,3] [,4] [,5] [1,] 0.5262693 0.2193864 0.07770965 0.02496709 0.007578244 > lp15 <- c(predict(m, newdata = data.frame(speed = 15))) > OVL(m, newdata = nd, reference = lp15) [,1] [,2] [,3] [,4] [,5] [1,] 0.2193864 0.5262693 1 0.5262693 0.2193864 > OVL(m, newdata = nd, reference = nd[3,,drop = FALSE]) [,1] [,2] [,3] [,4] [,5] [1,] 0.2193864 0.5262693 1 0.5262693 0.2193864 > OVL(m, newdata = nd, reference = nd) 1 2 3 4 2 0.52626927 3 0.21938642 0.52626927 4 0.07770965 0.21938642 0.52626927 5 0.02496709 0.07770965 0.21938642 0.52626927 > > d <- m$model$todistr$d > Q <- m$model$todistr$q > f <- function(p, b) pmin(1, d(Q(p) + b) / d(Q(p))) > lp <- predict(m, newdata = nd, type = "lp") > integrate(f, lower = 0, upper = 1, b = lp[2] - lp[1]) 0.5262692 with absolute error < 1.3e-05 > > > m <- Lehmann(dist ~ speed, data = cars) > m$negative [1] TRUE > coef(m) speed 0.3486759 > nd <- data.frame(speed = as.double(1:5 * 5)) > > PI(m, newdata = nd) [,1] [,2] [,3] [,4] [,5] [1,] 0.8511158 0.9703087 0.9946757 0.9990645 0.9998362 > lp15 <- c(predict(m, newdata = data.frame(speed = 15))) > PI(m, newdata = nd, reference = lp15) [,1] [,2] [,3] [,4] [,5] [1,] 0.02969132 0.1488842 0.5 0.8511158 0.9703087 > PI(m, newdata = nd, reference = nd[3,,drop = FALSE]) [,1] [,2] [,3] [,4] [,5] [1,] 0.02969132 0.1488842 0.5 0.8511158 0.9703087 > PI(m, newdata = nd, reference = nd) 1 2 3 4 2 0.8511158 3 0.9703087 0.8511158 4 0.9946757 0.9703087 0.8511158 5 0.9990645 0.9946757 0.9703087 0.8511158 > > F <- m$model$todistr$p > Q <- m$model$todistr$q > f <- function(p, b) F(Q(p) - b) > lp <- predict(m, newdata = nd, type = "lp") > integrate(f, lower = 0, upper = 1, b = lp[2] - lp[1]) 0.1488842 with absolute error < 5.7e-15 > > > OVL(m, newdata = nd) [,1] [,2] [,3] [,4] [,5] [1,] 0.4298802 0.1316324 0.03295825 0.007444731 0.001590555 > lp15 <- c(predict(m, newdata = data.frame(speed = 15))) > OVL(m, newdata = nd, reference = lp15) [,1] [,2] [,3] [,4] [,5] [1,] 0.1316324 0.4298802 1 0.4298802 0.1316324 > OVL(m, newdata = nd, reference = nd[3,,drop = FALSE]) [,1] [,2] [,3] [,4] [,5] [1,] 0.1316324 0.4298802 1 0.4298802 0.1316324 > OVL(m, newdata = nd, reference = nd) 1 2 3 4 2 0.429880208 3 0.131632372 0.429880208 4 0.032958249 0.131632372 0.429880208 5 0.007444731 0.032958249 0.131632372 0.429880208 > > d <- m$model$todistr$d > Q <- m$model$todistr$q > f <- function(p, b) pmin(1, d(Q(p) - b) / d(Q(p))) > lp <- predict(m, newdata = nd, type = "lp") > integrate(f, lower = 0, upper = 1, b = lp[2] - lp[1]) 0.4298796 with absolute error < 8e-05 > > OVL(m, newdata = nd) [,1] [,2] [,3] [,4] [,5] [1,] 0.4298802 0.1316324 0.03295825 0.007444731 0.001590555 > OVL(m, newdata = nd, conf.level = .95) Estimate lwr upr 1 0.429880208 0.3195347036 0.56348429 2 0.131632372 0.0626460732 0.26059831 3 0.032958249 0.0097367882 0.10414840 4 0.007444731 0.0013661293 0.03792029 5 0.001590555 0.0001815124 0.01304557 attr(,"conf.level") [1] 0.95 attr(,"calpha") [1] 1.960371 > > lp15 <- c(predict(m, newdata = data.frame(speed = 15))) > OVL(m, newdata = nd, reference = lp15) [,1] [,2] [,3] [,4] [,5] [1,] 0.1316324 0.4298802 1 0.4298802 0.1316324 > OVL(m, newdata = nd, reference = lp15, conf.level = .95) Estimate lwr upr 1 0.1239285626 5.770966e-02 0.25051630 2 0.0308307221 8.910322e-03 0.09958496 3 0.0069411137 1.246156e-03 0.03614028 4 0.0014800955 1.652543e-04 0.01240826 5 0.0003051263 2.118117e-05 0.00411399 attr(,"conf.level") [1] 0.95 attr(,"calpha") [1] 1.960371 > > OVL(m, newdata = nd[-3,,drop = FALSE], reference = nd[3,,drop = FALSE]) [,1] [,2] [,3] [,4] [1,] 0.1316324 0.4298802 0.4298802 0.1316324 > OVL(m, newdata = nd[-3,,drop = FALSE], reference = nd[3,,drop = FALSE], conf.level = .95) Estimate lwr upr 3-1 0.1316324 0.06264718 0.2605944 3-2 0.4298802 0.31953697 0.5634810 3-4 0.4298802 0.31953697 0.5634810 3-5 0.1316324 0.06264718 0.2605944 attr(,"conf.level") [1] 0.95 attr(,"calpha") [1] 1.960326 > > OVL(m, newdata = nd, reference = nd) 1 2 3 4 2 0.429880208 3 0.131632372 0.429880208 4 0.032958249 0.131632372 0.429880208 5 0.007444731 0.032958249 0.131632372 0.429880208 > OVL(m, newdata = nd, reference = nd, conf.level = .95) Estimate lwr upr 1-2 0.429880208 0.319535191 0.56348358 1-3 0.131632372 0.062646310 0.26059748 2-3 0.429880208 0.319535191 0.56348358 1-4 0.032958249 0.009736848 0.10414784 2-4 0.131632372 0.062646310 0.26059748 3-4 0.429880208 0.319535191 0.56348358 1-5 0.007444731 0.001366141 0.03791999 2-5 0.032958249 0.009736848 0.10414784 3-5 0.131632372 0.062646310 0.26059748 4-5 0.429880208 0.319535191 0.56348358 attr(,"conf.level") [1] 0.95 attr(,"calpha") [1] 1.960362 > > OVL(m, newdata = nd, reference = nd, conf.level = .95, + calpha = univariate_calpha()) Estimate lwr upr 1-2 0.429880208 0.319555197 0.56345424 1-3 0.131632372 0.062656040 0.26056336 2-3 0.429880208 0.319555197 0.56345424 1-4 0.032958249 0.009739304 0.10412457 2-4 0.131632372 0.062656040 0.26056336 3-4 0.429880208 0.319555197 0.56345424 1-5 0.007444731 0.001366617 0.03790786 2-5 0.032958249 0.009739304 0.10412457 3-5 0.131632372 0.062656040 0.26056336 4-5 0.429880208 0.319555197 0.56345424 attr(,"conf.level") [1] 0.95 attr(,"calpha") [1] 1.959964 > OVL(m, newdata = nd, reference = nd, conf.level = .95, + calpha = adjusted_calpha()) Estimate lwr upr 1-2 0.429880208 0.319535191 0.56348358 1-3 0.131632372 0.062646310 0.26059748 2-3 0.429880208 0.319535191 0.56348358 1-4 0.032958249 0.009736848 0.10414784 2-4 0.131632372 0.062646310 0.26059748 3-4 0.429880208 0.319535191 0.56348358 1-5 0.007444731 0.001366141 0.03791999 2-5 0.032958249 0.009736848 0.10414784 3-5 0.131632372 0.062646310 0.26059748 4-5 0.429880208 0.319535191 0.56348358 attr(,"conf.level") [1] 0.95 attr(,"calpha") [1] 1.960362 > > proc.time() user system elapsed 1.68 0.25 1.92