Last updated on 2026-08-02 13:49:48 CEST.
| Flavor | Version | Tinstall | Tcheck | Ttotal | Status | Flags |
|---|---|---|---|---|---|---|
| r-devel-linux-x86_64-debian-clang | 1.4-4 | 12.16 | 1420.46 | 1432.62 | ERROR | |
| r-devel-linux-x86_64-debian-gcc | 1.4-4 | 8.57 | 955.80 | 964.37 | ERROR | |
| r-devel-linux-x86_64-fedora-clang | 1.4-4 | 20.00 | 1388.29 | 1408.29 | ERROR | |
| r-devel-linux-x86_64-fedora-gcc | 1.4-4 | 8.00 | 942.81 | 950.81 | ERROR | |
| r-devel-windows-x86_64 | 1.4-4 | 13.00 | 460.00 | 473.00 | OK | --no-vignettes |
| r-patched-linux-x86_64 | 1.4-4 | 11.83 | 1413.03 | 1424.86 | ERROR | |
| r-release-linux-x86_64 | 1.4-4 | 11.47 | 1413.64 | 1425.11 | ERROR | |
| r-release-macos-arm64 | 1.4-4 | 3.00 | 360.00 | 363.00 | OK | |
| r-release-macos-x86_64 | 1.4-4 | 8.00 | 1703.00 | 1711.00 | OK | |
| r-release-windows-x86_64 | 1.4-4 | 16.00 | 534.00 | 550.00 | OK | --no-vignettes |
| r-oldrel-macos-arm64 | 1.4-4 | 3.00 | 346.00 | 349.00 | OK | |
| r-oldrel-macos-x86_64 | 1.4-4 | 8.00 | 1622.00 | 1630.00 | OK | |
| r-oldrel-windows-x86_64 | 1.4-4 | 18.00 | 724.00 | 742.00 | OK |
Version: 1.4-4
Check: examples
Result: ERROR
Running examples in ‘tram-Ex.R’ failed
The error most likely occurred in:
> base::assign(".ptime", proc.time(), pos = "CheckExEnv")
> ### Name: tram-methods
> ### Title: Methods for Stratified Linear Transformation Models
> ### Aliases: as.mlt.tram model.frame.tram model.matrix.tram
> ### model.matrix.stram coef.tram coef.Lm coef.Survreg vcov.tram
> ### logLik.tram estfun.tram predict.tram predict.stram residuals.tram
> ### plot.tram plot.ROCtram PI PI.tram PI.default OVL OVL.tram OVL.default
> ### TV TV.tram TV.default L1 L1.tram L1.default ROC ROC.tram ROC.default
>
> ### ** Examples
>
>
> data("BostonHousing2", package = "mlbench")
>
> ### fit non-normal Box-Cox type linear model with two
> ### baseline functions (for houses near and off Charles River)
> BC_BH_2 <- BoxCox(cmedv | 0 + chas ~ crim + zn + indus + nox +
+ rm + age + dis + rad + tax + ptratio + b + lstat,
+ data = BostonHousing2)
> logLik(BC_BH_2)
'log Lik.' -1334.509 (df=26)
>
> ### classical likelihood inference
> summary(BC_BH_2)
(Stratified) Non-normal (Box-Cox-Type) Linear Regression Model
Call:
BoxCox(formula = cmedv | 0 + chas ~ crim + zn + indus + nox +
rm + age + dis + rad + tax + ptratio + b + lstat, data = BostonHousing2)
Coefficients:
Estimate Std. Error z value Pr(>|z|)
crim -0.0467906 0.0074130 -6.312 2.76e-10 ***
zn 0.0061513 0.0029332 2.097 0.036 *
indus 0.0140681 0.0131135 1.073 0.283
nox -4.9487919 0.8464110 -5.847 5.01e-09 ***
rm 0.4368418 0.0948225 4.607 4.09e-06 ***
age -0.0016568 0.0028368 -0.584 0.559
dis -0.2991249 0.0437646 -6.835 8.21e-12 ***
rad 0.0811888 0.0142694 5.690 1.27e-08 ***
tax -0.0037180 0.0008041 -4.624 3.76e-06 ***
ptratio -0.2184113 0.0285718 -7.644 2.11e-14 ***
b 0.0026673 0.0005776 4.618 3.87e-06 ***
lstat -0.1669453 0.0123199 -13.551 < 2e-16 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Log-Likelihood:
-1334.509 (df = 26)
Likelihood-ratio Test: Chisq = 817.2314 on 12 degrees of freedom; p = < 2.2e-16
>
> ### coefficients of the linear predictor
> coef(BC_BH_2)
crim zn indus nox rm age
-0.046790563 0.006151332 0.014068066 -4.948791933 0.436841809 -0.001656839
dis rad tax ptratio b lstat
-0.299124862 0.081188783 -0.003717984 -0.218411314 0.002667338 -0.166945349
>
> ### plot linear predictor (mean of _transformed_ response)
> ### vs. observed values
> plot(predict(BC_BH_2, type = "lp"), BostonHousing2$cmedv)
>
> ### all coefficients
> coef(BC_BH_2, with_baseline = TRUE)
Bs1(cmedv):chas0 Bs2(cmedv):chas0 Bs3(cmedv):chas0 Bs4(cmedv):chas0
-13.299892745 -11.572055177 -11.572055179 -4.413500468
Bs5(cmedv):chas0 Bs6(cmedv):chas0 Bs7(cmedv):chas0 Bs1(cmedv):chas1
-2.922815888 -2.922815896 -2.176114273 -17.466541536
Bs2(cmedv):chas1 Bs3(cmedv):chas1 Bs4(cmedv):chas1 Bs5(cmedv):chas1
-17.466541536 -8.197577847 -4.375130082 -4.375130049
Bs6(cmedv):chas1 Bs7(cmedv):chas1 crim zn
-4.375130134 -3.375504890 -0.046790563 0.006151332
indus nox rm age
0.014068066 -4.948791933 0.436841809 -0.001656839
dis rad tax ptratio
-0.299124862 0.081188783 -0.003717984 -0.218411314
b lstat
0.002667338 -0.166945349
>
> ### compute predicted median along with 10% and 90% quantile for the first
> ### observations
> predict(BC_BH_2, newdata = BostonHousing2[1:3,], type = "quantile",
+ prob = c(.1, .5, .9))
prob [,1] [,2] [,3]
0.1 22.77239 19.83903 23.39704
0.5 27.98349 23.65863 29.08549
0.9 38.50440 29.55907 41.48202
>
> ### plot the predicted density for these observations
> plot(BC_BH_2, newdata = BostonHousing2[1:3, -1],
+ which = "distribution", type = "density", K = 1000)
>
> ### evaluate the two baseline transformations, with confidence intervals
> nd <- model.frame(BC_BH_2)[1:2, -1]
> nd$chas <- factor(c("0", "1"))
> library("colorspace")
> col <- diverge_hcl(2, h = c(246, 40), c = 96, l = c(65, 90))
> fill <- diverge_hcl(2, h = c(246, 40), c = 96, l = c(65, 90), alpha = .3)
> plot(BC_BH_2, which = "baseline only", newdata = nd, col = col,
+ confidence = "interval", fill = fill, lwd = 2,
+ xlab = "Median Value", ylab = expression(h[Y]))
> legend("bottomright", lty = 1, col = col,
+ title = "Near Charles River", legend = c("no", "yes"), bty = "n")
>
> ### cars data; with quantile functions
> plot(dist ~ speed, data = cars)
> m <- Colr(dist ~ speed, data = cars)
> q <- predict(as.mlt(m), newdata = data.frame(speed = s <- 7:20),
+ type = "quantile", prob = c(1, 5, 9) / 10)
> lines(s, q[1,])
> lines(s, q[2,])
> lines(s, q[3,])
>
> nd <- data.frame(speed = s <- as.double(1:5 * 5))
>
> # Prob(dist at speed s > dist at speed 0)
> # speed 0 is reference, not a good choice here
> PI(m, newdata = nd)
[,1] [,2] [,3] [,4] [,5]
[1,] 0.8593495 0.978335 0.9975546 0.9997618 0.9999786
>
> # Prob(dist at speed s > dist at speed 15)
> lp15 <- c(predict(m, newdata = data.frame(speed = 15)))
> PI(m, newdata = nd, reference = lp15)
[,1] [,2] [,3] [,4] [,5]
[1,] 0.02166504 0.1406505 0.5 0.8593495 0.978335
> PI(m, newdata = nd, reference = nd[3,,drop = FALSE])
[,1] [,2] [,3] [,4] [,5]
[1,] 0.02166504 0.1406505 0.5 0.8593495 0.978335
>
> # Prob(dist at speed s' > dist at speed s)
> PI(m, newdata = nd, reference = nd)
1 2 3 4
2 0.8593495
3 0.9783350 0.8593495
4 0.9975546 0.9783350 0.8593495
5 0.9997618 0.9975546 0.9783350 0.8593495
> # essentially:
> lp <- predict(m, newdata = nd)
> PI(object = dist(lp))
1 2 3 4
2 0.8593495
3 0.9783350 0.8593495
4 0.9975546 0.9783350 0.8593495
5 0.9997618 0.9975546 0.9783350 0.8593495
> # same, with simultaneous confidence intervals
> PI(m, newdata = nd, reference = nd, conf.level = .95)
Estimate lwr upr
1-2 0.8593495 0.7811056 0.9141291
1-3 0.9783350 0.9324841 0.9937147
2-3 0.8593495 0.7811056 0.9141291
1-4 0.9975546 0.9835574 0.9996740
2-4 0.9783350 0.9324841 0.9937147
3-4 0.8593495 0.7811056 0.9141291
1-5 0.9997618 0.9965137 0.9999854
2-5 0.9975546 0.9835574 0.9996740
3-5 0.9783350 0.9324841 0.9937147
4-5 0.8593495 0.7811056 0.9141291
attr(,"conf.level")
[1] 0.95
attr(,"calpha")
[1] 1.960362
>
> # plot ROC curves + confidence bands
> # compare speed 20 and 25 to speed 15
> plot(ROC(m, newdata = nd[4:5,,drop = FALSE],
+ reference = nd[3,,drop = FALSE],
+ conf.level = 0.95))
>
> # Overlap of conditional densities at speed s' and s
> OVL(m, newdata = nd, reference = nd)
1 2 3 4
2 0.419779466
3 0.131832586 0.419779466
4 0.036802262 0.131832586 0.419779466
5 0.009910296 0.036802262 0.131832586 0.419779466
>
> ### ROC analysis (takes too long for CRAN Windows)
> if (require("mlbench") && .Platform$OS.type != "windows") {
+
+ layout(matrix(1:4, nrow = 2))
+ data("PimaIndiansDiabetes2", package = "mlbench")
+ dia <- sort(unique(PimaIndiansDiabetes2$diabetes))
+ nd <- data.frame(diabetes = dia,
+ age = 29, mass = 32) ### median values
+
+ ### unconditional ROC analysis: glucose tolerance test
+ m0 <- Colr(glucose ~ diabetes, data = PimaIndiansDiabetes2)
+ # ROC curve + confidence band
+ plot(ROC(m0, newdata = nd[2,,drop = FALSE], conf.level = .95))
+ # Wald interval for AUC
+ PI(m0, newdata = nd[2,,drop = FALSE], conf.level = .95)
+ # score interval for AUC
+ PI(-c(coef(m0), score_test(m0)$conf.int[2:1]))
+
+ ### adjusted ROC analysis for age and mass
+ m1 <- Colr(glucose ~ diabetes + age + mass, data = PimaIndiansDiabetes2)
+ # ROC curve + confidence band (this is the same for all ages /
+ # masses)
+ plot(ROC(m1, newdata = nd[2,,drop = FALSE],
+ reference = nd[1,,drop = FALSE],
+ conf.level = .95))
+ # Wald interval for adjusted AUC
+ PI(m1, newdata = nd[2,,drop = FALSE], reference = nd[1,,drop = FALSE],
+ conf.level = .95)
+ # Score interval for adjusted AUC
+ PI(-c(coef(m1)[1], score_test(m1, names(coef(m1))[1])$conf.int[2:1]))
+
+ ### conditional ROC analysis: AUC regression ~ age + mass
+ m2 <- Colr(glucose ~ diabetes * (age + mass), data = PimaIndiansDiabetes2)
+ # ROC curve for a person with age = 29 and mass = 32
+ plot(ROC(m2, newdata = nd[2,,drop = FALSE],
+ reference = nd[1,,drop = FALSE],
+ conf.level = .95))
+ # AUC for persons ages 21:81, all with mass = 32
+ nd1 <- data.frame(diabetes = nd[1,"diabetes"], age = 21:81, mass = 32)
+ nd2 <- data.frame(diabetes = nd[2,"diabetes"], age = 21:81, mass = 32)
+ auc <- PI(m2, newdata = nd2, reference = nd1, one2one = TRUE,
+ conf.level = 0.95)
+ plot(nd1$age, auc[, "Estimate"], xlab = "Age (in years)", ylab =
+ "AUC", ylim = c(0, 1), type = "l")
+ lines(nd1$age, auc[, "lwr"], lty = 3)
+ lines(nd1$age, auc[, "upr"], lty = 3)
+ }
Loading required package: mlbench
Warning in data("PimaIndiansDiabetes2", package = "mlbench") :
data set ‘PimaIndiansDiabetes2’ not found
Error: object 'PimaIndiansDiabetes2' not found
Execution halted
Examples with CPU (user + system) or elapsed time > 5s
user system elapsed
mmlt 7.260 0.035 9.830
perm_test 6.017 0.093 8.714
score_test 5.902 0.047 7.869
Coxph 5.552 0.054 7.007
mtram 3.283 0.009 5.223
Flavor: r-devel-linux-x86_64-debian-clang
Version: 1.4-4
Check: examples
Result: ERROR
Running examples in ‘tram-Ex.R’ failed
The error most likely occurred in:
> base::assign(".ptime", proc.time(), pos = "CheckExEnv")
> ### Name: tram-methods
> ### Title: Methods for Stratified Linear Transformation Models
> ### Aliases: as.mlt.tram model.frame.tram model.matrix.tram
> ### model.matrix.stram coef.tram coef.Lm coef.Survreg vcov.tram
> ### logLik.tram estfun.tram predict.tram predict.stram residuals.tram
> ### plot.tram plot.ROCtram PI PI.tram PI.default OVL OVL.tram OVL.default
> ### TV TV.tram TV.default L1 L1.tram L1.default ROC ROC.tram ROC.default
>
> ### ** Examples
>
>
> data("BostonHousing2", package = "mlbench")
>
> ### fit non-normal Box-Cox type linear model with two
> ### baseline functions (for houses near and off Charles River)
> BC_BH_2 <- BoxCox(cmedv | 0 + chas ~ crim + zn + indus + nox +
+ rm + age + dis + rad + tax + ptratio + b + lstat,
+ data = BostonHousing2)
> logLik(BC_BH_2)
'log Lik.' -1334.509 (df=26)
>
> ### classical likelihood inference
> summary(BC_BH_2)
(Stratified) Non-normal (Box-Cox-Type) Linear Regression Model
Call:
BoxCox(formula = cmedv | 0 + chas ~ crim + zn + indus + nox +
rm + age + dis + rad + tax + ptratio + b + lstat, data = BostonHousing2)
Coefficients:
Estimate Std. Error z value Pr(>|z|)
crim -0.0467906 0.0074130 -6.312 2.76e-10 ***
zn 0.0061513 0.0029332 2.097 0.036 *
indus 0.0140681 0.0131135 1.073 0.283
nox -4.9487919 0.8464110 -5.847 5.01e-09 ***
rm 0.4368418 0.0948225 4.607 4.09e-06 ***
age -0.0016568 0.0028368 -0.584 0.559
dis -0.2991249 0.0437646 -6.835 8.21e-12 ***
rad 0.0811888 0.0142694 5.690 1.27e-08 ***
tax -0.0037180 0.0008041 -4.624 3.76e-06 ***
ptratio -0.2184113 0.0285718 -7.644 2.11e-14 ***
b 0.0026673 0.0005776 4.618 3.87e-06 ***
lstat -0.1669453 0.0123199 -13.551 < 2e-16 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Log-Likelihood:
-1334.509 (df = 26)
Likelihood-ratio Test: Chisq = 817.2314 on 12 degrees of freedom; p = < 2.2e-16
>
> ### coefficients of the linear predictor
> coef(BC_BH_2)
crim zn indus nox rm age
-0.046790563 0.006151332 0.014068066 -4.948791933 0.436841809 -0.001656839
dis rad tax ptratio b lstat
-0.299124862 0.081188783 -0.003717984 -0.218411314 0.002667338 -0.166945349
>
> ### plot linear predictor (mean of _transformed_ response)
> ### vs. observed values
> plot(predict(BC_BH_2, type = "lp"), BostonHousing2$cmedv)
>
> ### all coefficients
> coef(BC_BH_2, with_baseline = TRUE)
Bs1(cmedv):chas0 Bs2(cmedv):chas0 Bs3(cmedv):chas0 Bs4(cmedv):chas0
-13.299892745 -11.572055177 -11.572055179 -4.413500468
Bs5(cmedv):chas0 Bs6(cmedv):chas0 Bs7(cmedv):chas0 Bs1(cmedv):chas1
-2.922815888 -2.922815896 -2.176114273 -17.466541536
Bs2(cmedv):chas1 Bs3(cmedv):chas1 Bs4(cmedv):chas1 Bs5(cmedv):chas1
-17.466541536 -8.197577847 -4.375130082 -4.375130049
Bs6(cmedv):chas1 Bs7(cmedv):chas1 crim zn
-4.375130134 -3.375504890 -0.046790563 0.006151332
indus nox rm age
0.014068066 -4.948791933 0.436841809 -0.001656839
dis rad tax ptratio
-0.299124862 0.081188783 -0.003717984 -0.218411314
b lstat
0.002667338 -0.166945349
>
> ### compute predicted median along with 10% and 90% quantile for the first
> ### observations
> predict(BC_BH_2, newdata = BostonHousing2[1:3,], type = "quantile",
+ prob = c(.1, .5, .9))
prob [,1] [,2] [,3]
0.1 22.77239 19.83903 23.39704
0.5 27.98349 23.65863 29.08549
0.9 38.50440 29.55907 41.48202
>
> ### plot the predicted density for these observations
> plot(BC_BH_2, newdata = BostonHousing2[1:3, -1],
+ which = "distribution", type = "density", K = 1000)
>
> ### evaluate the two baseline transformations, with confidence intervals
> nd <- model.frame(BC_BH_2)[1:2, -1]
> nd$chas <- factor(c("0", "1"))
> library("colorspace")
> col <- diverge_hcl(2, h = c(246, 40), c = 96, l = c(65, 90))
> fill <- diverge_hcl(2, h = c(246, 40), c = 96, l = c(65, 90), alpha = .3)
> plot(BC_BH_2, which = "baseline only", newdata = nd, col = col,
+ confidence = "interval", fill = fill, lwd = 2,
+ xlab = "Median Value", ylab = expression(h[Y]))
> legend("bottomright", lty = 1, col = col,
+ title = "Near Charles River", legend = c("no", "yes"), bty = "n")
>
> ### cars data; with quantile functions
> plot(dist ~ speed, data = cars)
> m <- Colr(dist ~ speed, data = cars)
> q <- predict(as.mlt(m), newdata = data.frame(speed = s <- 7:20),
+ type = "quantile", prob = c(1, 5, 9) / 10)
> lines(s, q[1,])
> lines(s, q[2,])
> lines(s, q[3,])
>
> nd <- data.frame(speed = s <- as.double(1:5 * 5))
>
> # Prob(dist at speed s > dist at speed 0)
> # speed 0 is reference, not a good choice here
> PI(m, newdata = nd)
[,1] [,2] [,3] [,4] [,5]
[1,] 0.8593495 0.978335 0.9975546 0.9997618 0.9999786
>
> # Prob(dist at speed s > dist at speed 15)
> lp15 <- c(predict(m, newdata = data.frame(speed = 15)))
> PI(m, newdata = nd, reference = lp15)
[,1] [,2] [,3] [,4] [,5]
[1,] 0.02166504 0.1406505 0.5 0.8593495 0.978335
> PI(m, newdata = nd, reference = nd[3,,drop = FALSE])
[,1] [,2] [,3] [,4] [,5]
[1,] 0.02166504 0.1406505 0.5 0.8593495 0.978335
>
> # Prob(dist at speed s' > dist at speed s)
> PI(m, newdata = nd, reference = nd)
1 2 3 4
2 0.8593495
3 0.9783350 0.8593495
4 0.9975546 0.9783350 0.8593495
5 0.9997618 0.9975546 0.9783350 0.8593495
> # essentially:
> lp <- predict(m, newdata = nd)
> PI(object = dist(lp))
1 2 3 4
2 0.8593495
3 0.9783350 0.8593495
4 0.9975546 0.9783350 0.8593495
5 0.9997618 0.9975546 0.9783350 0.8593495
> # same, with simultaneous confidence intervals
> PI(m, newdata = nd, reference = nd, conf.level = .95)
Estimate lwr upr
1-2 0.8593495 0.7811056 0.9141291
1-3 0.9783350 0.9324841 0.9937147
2-3 0.8593495 0.7811056 0.9141291
1-4 0.9975546 0.9835574 0.9996740
2-4 0.9783350 0.9324841 0.9937147
3-4 0.8593495 0.7811056 0.9141291
1-5 0.9997618 0.9965137 0.9999854
2-5 0.9975546 0.9835574 0.9996740
3-5 0.9783350 0.9324841 0.9937147
4-5 0.8593495 0.7811056 0.9141291
attr(,"conf.level")
[1] 0.95
attr(,"calpha")
[1] 1.960362
>
> # plot ROC curves + confidence bands
> # compare speed 20 and 25 to speed 15
> plot(ROC(m, newdata = nd[4:5,,drop = FALSE],
+ reference = nd[3,,drop = FALSE],
+ conf.level = 0.95))
>
> # Overlap of conditional densities at speed s' and s
> OVL(m, newdata = nd, reference = nd)
1 2 3 4
2 0.419779466
3 0.131832586 0.419779466
4 0.036802262 0.131832586 0.419779466
5 0.009910296 0.036802262 0.131832586 0.419779466
>
> ### ROC analysis (takes too long for CRAN Windows)
> if (require("mlbench") && .Platform$OS.type != "windows") {
+
+ layout(matrix(1:4, nrow = 2))
+ data("PimaIndiansDiabetes2", package = "mlbench")
+ dia <- sort(unique(PimaIndiansDiabetes2$diabetes))
+ nd <- data.frame(diabetes = dia,
+ age = 29, mass = 32) ### median values
+
+ ### unconditional ROC analysis: glucose tolerance test
+ m0 <- Colr(glucose ~ diabetes, data = PimaIndiansDiabetes2)
+ # ROC curve + confidence band
+ plot(ROC(m0, newdata = nd[2,,drop = FALSE], conf.level = .95))
+ # Wald interval for AUC
+ PI(m0, newdata = nd[2,,drop = FALSE], conf.level = .95)
+ # score interval for AUC
+ PI(-c(coef(m0), score_test(m0)$conf.int[2:1]))
+
+ ### adjusted ROC analysis for age and mass
+ m1 <- Colr(glucose ~ diabetes + age + mass, data = PimaIndiansDiabetes2)
+ # ROC curve + confidence band (this is the same for all ages /
+ # masses)
+ plot(ROC(m1, newdata = nd[2,,drop = FALSE],
+ reference = nd[1,,drop = FALSE],
+ conf.level = .95))
+ # Wald interval for adjusted AUC
+ PI(m1, newdata = nd[2,,drop = FALSE], reference = nd[1,,drop = FALSE],
+ conf.level = .95)
+ # Score interval for adjusted AUC
+ PI(-c(coef(m1)[1], score_test(m1, names(coef(m1))[1])$conf.int[2:1]))
+
+ ### conditional ROC analysis: AUC regression ~ age + mass
+ m2 <- Colr(glucose ~ diabetes * (age + mass), data = PimaIndiansDiabetes2)
+ # ROC curve for a person with age = 29 and mass = 32
+ plot(ROC(m2, newdata = nd[2,,drop = FALSE],
+ reference = nd[1,,drop = FALSE],
+ conf.level = .95))
+ # AUC for persons ages 21:81, all with mass = 32
+ nd1 <- data.frame(diabetes = nd[1,"diabetes"], age = 21:81, mass = 32)
+ nd2 <- data.frame(diabetes = nd[2,"diabetes"], age = 21:81, mass = 32)
+ auc <- PI(m2, newdata = nd2, reference = nd1, one2one = TRUE,
+ conf.level = 0.95)
+ plot(nd1$age, auc[, "Estimate"], xlab = "Age (in years)", ylab =
+ "AUC", ylim = c(0, 1), type = "l")
+ lines(nd1$age, auc[, "lwr"], lty = 3)
+ lines(nd1$age, auc[, "upr"], lty = 3)
+ }
Loading required package: mlbench
Warning in data("PimaIndiansDiabetes2", package = "mlbench") :
data set ‘PimaIndiansDiabetes2’ not found
Error: object 'PimaIndiansDiabetes2' not found
Execution halted
Flavor: r-devel-linux-x86_64-debian-gcc
Version: 1.4-4
Check: for new files in some other directories
Result: NOTE
Found the following files/directories:
‘~/tmp/scratch/Rtmp04pH8q’ ‘~/tmp/scratch/Rtmp09QrAj’
‘~/tmp/scratch/Rtmp0BrvqK’ ‘~/tmp/scratch/Rtmp0daHrP’
‘~/tmp/scratch/Rtmp0erPxs’ ‘~/tmp/scratch/Rtmp0fzKrk’
‘~/tmp/scratch/Rtmp0o8PML’ ‘~/tmp/scratch/Rtmp0v1MuX’
‘~/tmp/scratch/Rtmp14FuYZ’ ‘~/tmp/scratch/Rtmp15fQ5f’
‘~/tmp/scratch/Rtmp1HmatE’ ‘~/tmp/scratch/Rtmp1J4g3M’
‘~/tmp/scratch/Rtmp1JLecB’ ‘~/tmp/scratch/Rtmp1hoHbJ’
‘~/tmp/scratch/Rtmp1sp34M’ ‘~/tmp/scratch/Rtmp2MKz1h’
‘~/tmp/scratch/Rtmp2Q3BCr’ ‘~/tmp/scratch/Rtmp2wJy0i’
‘~/tmp/scratch/Rtmp3RVROo’ ‘~/tmp/scratch/Rtmp4TrT2q’
‘~/tmp/scratch/Rtmp4eUuhq’ ‘~/tmp/scratch/Rtmp53R4zC’
‘~/tmp/scratch/Rtmp6HCINt’ ‘~/tmp/scratch/Rtmp6HvWTf’
‘~/tmp/scratch/Rtmp6JBqB0’ ‘~/tmp/scratch/Rtmp6Z4TvQ’
‘~/tmp/scratch/Rtmp7OmCnQ’ ‘~/tmp/scratch/Rtmp7V216M’
‘~/tmp/scratch/Rtmp7hqpVN’ ‘~/tmp/scratch/Rtmp8biRod’
‘~/tmp/scratch/Rtmp8y6mfw’ ‘~/tmp/scratch/Rtmp9Ho68a’
‘~/tmp/scratch/Rtmp9cCkUI’ ‘~/tmp/scratch/Rtmp9oMzgJ’
‘~/tmp/scratch/RtmpAcliM0’ ‘~/tmp/scratch/RtmpAhPThd’
‘~/tmp/scratch/RtmpArv6AL’ ‘~/tmp/scratch/RtmpAwMg6z’
‘~/tmp/scratch/RtmpBRibLN’ ‘~/tmp/scratch/RtmpCFGxlJ’
‘~/tmp/scratch/RtmpCWEXa9’ ‘~/tmp/scratch/RtmpCh8u3n’
‘~/tmp/scratch/RtmpCmrQVw’ ‘~/tmp/scratch/RtmpCnYTqT’
‘~/tmp/scratch/RtmpEc78Xb’ ‘~/tmp/scratch/RtmpEgELHR’
‘~/tmp/scratch/RtmpEtLCyZ’ ‘~/tmp/scratch/RtmpFCKXMZ’
‘~/tmp/scratch/RtmpFZRSbz’ ‘~/tmp/scratch/RtmpFnoHdO’
‘~/tmp/scratch/RtmpFqwPAP’ ‘~/tmp/scratch/RtmpG4KTbk’
‘~/tmp/scratch/RtmpGJMmMu’ ‘~/tmp/scratch/RtmpGYVzoR’
‘~/tmp/scratch/RtmpGpDzPd’ ‘~/tmp/scratch/RtmpGr14Xq’
‘~/tmp/scratch/RtmpHifeXG’ ‘~/tmp/scratch/RtmpI0C0DD’
‘~/tmp/scratch/RtmpI10rAw’ ‘~/tmp/scratch/RtmpI1QGPI’
‘~/tmp/scratch/RtmpIqUuI2’ ‘~/tmp/scratch/RtmpJN6yWb’
‘~/tmp/scratch/RtmpJOSGjV’ ‘~/tmp/scratch/RtmpJvwUvA’
‘~/tmp/scratch/RtmpKCWdR8’ ‘~/tmp/scratch/RtmpKo8Pnh’
‘~/tmp/scratch/RtmpM2kTx7’ ‘~/tmp/scratch/RtmpN7IGfL’
‘~/tmp/scratch/RtmpNNaL9k’ ‘~/tmp/scratch/RtmpNTFb8e’
‘~/tmp/scratch/RtmpOUvhmc’ ‘~/tmp/scratch/RtmpObFj3R’
‘~/tmp/scratch/RtmpOglEC3’ ‘~/tmp/scratch/RtmpOiM0L1’
‘~/tmp/scratch/RtmpOn0RMi’ ‘~/tmp/scratch/RtmpPCUztr’
‘~/tmp/scratch/RtmpPIZCqe’ ‘~/tmp/scratch/RtmpPStulG’
‘~/tmp/scratch/RtmpPmO4Zn’ ‘~/tmp/scratch/RtmpPngdkV’
‘~/tmp/scratch/RtmpQKpZAi’ ‘~/tmp/scratch/RtmpQP17M4’
‘~/tmp/scratch/RtmpQSxfVH’ ‘~/tmp/scratch/RtmpQeJn3d’
‘~/tmp/scratch/RtmpQiSlWF’ ‘~/tmp/scratch/RtmpRSEBsQ’
‘~/tmp/scratch/RtmpSFqNen’ ‘~/tmp/scratch/RtmpT9cVSi’
‘~/tmp/scratch/RtmpTR0Ggj’ ‘~/tmp/scratch/RtmpTTu0iF’
‘~/tmp/scratch/RtmpTgmc3y’ ‘~/tmp/scratch/RtmpTxpxqg’
‘~/tmp/scratch/RtmpU606qS’ ‘~/tmp/scratch/RtmpU6FftL’
‘~/tmp/scratch/RtmpUATEzQ’ ‘~/tmp/scratch/RtmpULu83R’
‘~/tmp/scratch/RtmpUbDTSi’ ‘~/tmp/scratch/RtmpV8rKVt’
‘~/tmp/scratch/RtmpVHLq1V’ ‘~/tmp/scratch/RtmpVLYQQ7’
‘~/tmp/scratch/RtmpVjCgdS’ ‘~/tmp/scratch/RtmpW2PanA’
‘~/tmp/scratch/RtmpW5G9WB’ ‘~/tmp/scratch/RtmpX4FlXu’
‘~/tmp/scratch/RtmpX79Zr8’ ‘~/tmp/scratch/RtmpX8fP82’
‘~/tmp/scratch/RtmpXD3B5X’ ‘~/tmp/scratch/RtmpXSynhl’
‘~/tmp/scratch/RtmpY5Z9C2’ ‘~/tmp/scratch/RtmpY5hN3Y’
‘~/tmp/scratch/RtmpY9DhbC’ ‘~/tmp/scratch/RtmpYA1JrH’
‘~/tmp/scratch/RtmpYGqaVk’ ‘~/tmp/scratch/RtmpYO0bYo’
‘~/tmp/scratch/RtmpYaMMNa’ ‘~/tmp/scratch/RtmpYbbCY6’
‘~/tmp/scratch/RtmpYnlY6v’ ‘~/tmp/scratch/RtmpYqXabH’
‘~/tmp/scratch/RtmpYtP1uV’ ‘~/tmp/scratch/RtmpYtTyYo’
‘~/tmp/scratch/RtmpZWCBzx’ ‘~/tmp/scratch/RtmpaMYGQ3’
‘~/tmp/scratch/RtmpaUM07I’ ‘~/tmp/scratch/RtmpaeNRVN’
‘~/tmp/scratch/Rtmpb3f08U’ ‘~/tmp/scratch/RtmpbJZngH’
‘~/tmp/scratch/RtmpcF9snz’ ‘~/tmp/scratch/RtmpcLLtuK’
‘~/tmp/scratch/RtmpcZ8Dlz’ ‘~/tmp/scratch/RtmpcjZEEM’
‘~/tmp/scratch/RtmpdNSkzD’ ‘~/tmp/scratch/RtmpdnbAuT’
‘~/tmp/scratch/RtmpdwWlgz’ ‘~/tmp/scratch/Rtmpe6Ykby’
‘~/tmp/scratch/RtmpenKHms’ ‘~/tmp/scratch/RtmpenozMi’
‘~/tmp/scratch/RtmpfAt80p’ ‘~/tmp/scratch/RtmpfVInW1’
‘~/tmp/scratch/RtmpgHaKfK’ ‘~/tmp/scratch/RtmpgNEUaN’
‘~/tmp/scratch/RtmpgOsCm5’ ‘~/tmp/scratch/RtmpgiACzp’
‘~/tmp/scratch/Rtmpgp1hRM’ ‘~/tmp/scratch/RtmpgqJKiI’
‘~/tmp/scratch/RtmphC3tIu’ ‘~/tmp/scratch/RtmphRsDrm’
‘~/tmp/scratch/RtmphiEisr’ ‘~/tmp/scratch/RtmpiHlj7a’
‘~/tmp/scratch/RtmpiHxtY5’ ‘~/tmp/scratch/RtmpiQV5Tz’
‘~/tmp/scratch/RtmpiSZqcU’ ‘~/tmp/scratch/RtmpiY6eFo’
‘~/tmp/scratch/RtmpihSCsl’ ‘~/tmp/scratch/RtmpingZHD’
‘~/tmp/scratch/RtmpiyLsyr’ ‘~/tmp/scratch/RtmpjbGFGn’
‘~/tmp/scratch/RtmpjbS4xY’ ‘~/tmp/scratch/RtmpjjOGRa’
‘~/tmp/scratch/RtmpjtIIPQ’ ‘~/tmp/scratch/Rtmpk5h4RB’
‘~/tmp/scratch/RtmpkCBl0y’ ‘~/tmp/scratch/RtmpkEZMq1’
‘~/tmp/scratch/RtmpkSf0z6’ ‘~/tmp/scratch/Rtmpkt2Vi5’
‘~/tmp/scratch/RtmplJO9cP’ ‘~/tmp/scratch/RtmplNqnWL’
‘~/tmp/scratch/Rtmpm2sS8i’ ‘~/tmp/scratch/RtmpmZ5aPe’
‘~/tmp/scratch/RtmpmbegcC’ ‘~/tmp/scratch/RtmpmtHr0w’
‘~/tmp/scratch/RtmpmuYtos’ ‘~/tmp/scratch/Rtmpnoxs5o’
‘~/tmp/scratch/RtmpnzDUM5’ ‘~/tmp/scratch/RtmpnzQPuN’
‘~/tmp/scratch/RtmpoBQ1Gt’ ‘~/tmp/scratch/RtmpoBmnJX’
‘~/tmp/scratch/RtmpoGec9n’ ‘~/tmp/scratch/RtmpoP3Gyu’
‘~/tmp/scratch/Rtmpoikoeh’ ‘~/tmp/scratch/Rtmpp3lvhY’
‘~/tmp/scratch/Rtmpp629u0’ ‘~/tmp/scratch/Rtmpp9nQXP’
‘~/tmp/scratch/RtmppISiaK’ ‘~/tmp/scratch/RtmppdfV1U’
‘~/tmp/scratch/RtmpqAzsRB’ ‘~/tmp/scratch/RtmpqHi3L0’
‘~/tmp/scratch/RtmpqN73QB’ ‘~/tmp/scratch/RtmpqQvit0’
‘~/tmp/scratch/RtmpqU6LP7’ ‘~/tmp/scratch/Rtmpqn6fXa’
‘~/tmp/scratch/Rtmpr6dHQ5’ ‘~/tmp/scratch/RtmprgZsRn’
‘~/tmp/scratch/Rtmps8RyAE’ ‘~/tmp/scratch/RtmpsCPEfv’
‘~/tmp/scratch/RtmpsCgBms’ ‘~/tmp/scratch/RtmpsGJin1’
‘~/tmp/scratch/RtmpsiLp4N’ ‘~/tmp/scratch/RtmpsmZyqP’
‘~/tmp/scratch/RtmpsxLIsz’ ‘~/tmp/scratch/RtmptctyT3’
‘~/tmp/scratch/RtmptkwsEz’ ‘~/tmp/scratch/Rtmpu9Mxsf’
‘~/tmp/scratch/Rtmpudf0vS’ ‘~/tmp/scratch/Rtmpv2z7U4’
‘~/tmp/scratch/RtmpvAAnIw’ ‘~/tmp/scratch/Rtmpw8b0in’
‘~/tmp/scratch/RtmpwCJjj5’ ‘~/tmp/scratch/RtmpwLlMLT’
‘~/tmp/scratch/Rtmpx611DP’ ‘~/tmp/scratch/RtmpxyrEDd’
‘~/tmp/scratch/RtmpyALnC5’ ‘~/tmp/scratch/RtmpyaxECu’
‘~/tmp/scratch/Rtmpyum71O’ ‘~/tmp/scratch/RtmpyxmAin’
‘~/tmp/scratch/RtmpyxsHlb’ ‘~/tmp/scratch/Rtmpz4ao0O’
‘~/tmp/scratch/RtmpzVTdmE’ ‘~/tmp/scratch/RtmpzWRf3E’
‘~/tmp/scratch/RtmpzhRaqP’ ‘~/tmp/scratch/RtmpznzCD1’
‘~/tmp/scratch/ccwstOEa.s’
‘~/tmp/scratch/quarto-session97692de4c2a73770’
‘~/tmp/scratch/xvfb-run.0cVqSi’ ‘~/tmp/scratch/xvfb-run.2bVKS6’
‘~/tmp/scratch/xvfb-run.2e7TyL’ ‘~/tmp/scratch/xvfb-run.2gzplf’
‘~/tmp/scratch/xvfb-run.31LEfM’ ‘~/tmp/scratch/xvfb-run.3hrDMu’
‘~/tmp/scratch/xvfb-run.6OqWPv’ ‘~/tmp/scratch/xvfb-run.7mcPZ0’
‘~/tmp/scratch/xvfb-run.9WC6ti’ ‘~/tmp/scratch/xvfb-run.A7DLMj’
‘~/tmp/scratch/xvfb-run.AyAi6q’ ‘~/tmp/scratch/xvfb-run.CiOVTK’
‘~/tmp/scratch/xvfb-run.GLkn6Z’ ‘~/tmp/scratch/xvfb-run.GXlwnb’
‘~/tmp/scratch/xvfb-run.HU65Dr’ ‘~/tmp/scratch/xvfb-run.IgAPUm’
‘~/tmp/scratch/xvfb-run.KLH3yu’ ‘~/tmp/scratch/xvfb-run.KsWybj’
‘~/tmp/scratch/xvfb-run.L1ho5k’ ‘~/tmp/scratch/xvfb-run.Lxup6y’
‘~/tmp/scratch/xvfb-run.MeskVO’ ‘~/tmp/scratch/xvfb-run.NjL6np’
‘~/tmp/scratch/xvfb-run.NlO1sv’ ‘~/tmp/scratch/xvfb-run.OBzeVi’
‘~/tmp/scratch/xvfb-run.OG8mjr’ ‘~/tmp/scratch/xvfb-run.PqdWJc’
‘~/tmp/scratch/xvfb-run.Q2tDh6’ ‘~/tmp/scratch/xvfb-run.Qf6P09’
‘~/tmp/scratch/xvfb-run.RAiYqR’ ‘~/tmp/scratch/xvfb-run.Rzj1cV’
‘~/tmp/scratch/xvfb-run.SuPi8U’ ‘~/tmp/scratch/xvfb-run.T0jIXx’
‘~/tmp/scratch/xvfb-run.UIYyO0’ ‘~/tmp/scratch/xvfb-run.V4VIcU’
‘~/tmp/scratch/xvfb-run.XLRreW’ ‘~/tmp/scratch/xvfb-run.ZZTJYa’
‘~/tmp/scratch/xvfb-run.aFw8U7’ ‘~/tmp/scratch/xvfb-run.aX1FiD’
‘~/tmp/scratch/xvfb-run.bW8J0a’ ‘~/tmp/scratch/xvfb-run.c72OvL’
‘~/tmp/scratch/xvfb-run.d3J2EB’ ‘~/tmp/scratch/xvfb-run.d9MKPz’
‘~/tmp/scratch/xvfb-run.dwmOJc’ ‘~/tmp/scratch/xvfb-run.effkfm’
‘~/tmp/scratch/xvfb-run.g9yIyq’ ‘~/tmp/scratch/xvfb-run.gIIAkZ’
‘~/tmp/scratch/xvfb-run.hC9CEv’ ‘~/tmp/scratch/xvfb-run.i0Y8Te’
‘~/tmp/scratch/xvfb-run.i2xOY3’ ‘~/tmp/scratch/xvfb-run.iQSe0A’
‘~/tmp/scratch/xvfb-run.k8xlzr’ ‘~/tmp/scratch/xvfb-run.kbn9KL’
‘~/tmp/scratch/xvfb-run.kxtJu2’ ‘~/tmp/scratch/xvfb-run.l9mlPx’
‘~/tmp/scratch/xvfb-run.lBa1aY’ ‘~/tmp/scratch/xvfb-run.lHvVPQ’
‘~/tmp/scratch/xvfb-run.lIUebU’ ‘~/tmp/scratch/xvfb-run.ltny8f’
‘~/tmp/scratch/xvfb-run.nF0IRu’ ‘~/tmp/scratch/xvfb-run.nHVnNV’
‘~/tmp/scratch/xvfb-run.nUyiNo’ ‘~/tmp/scratch/xvfb-run.nia8Km’
‘~/tmp/scratch/xvfb-run.oH2yEL’ ‘~/tmp/scratch/xvfb-run.ojRGqp’
‘~/tmp/scratch/xvfb-run.pg712k’ ‘~/tmp/scratch/xvfb-run.plmypg’
‘~/tmp/scratch/xvfb-run.puX4sd’ ‘~/tmp/scratch/xvfb-run.qF1jrb’
‘~/tmp/scratch/xvfb-run.qZhdix’ ‘~/tmp/scratch/xvfb-run.qdUI5K’
‘~/tmp/scratch/xvfb-run.rGSGa3’ ‘~/tmp/scratch/xvfb-run.sSWSV3’
‘~/tmp/scratch/xvfb-run.uBly2x’ ‘~/tmp/scratch/xvfb-run.v4zt3f’
‘~/tmp/scratch/xvfb-run.vLdOgy’ ‘~/tmp/scratch/xvfb-run.vT3qRS’
‘~/tmp/scratch/xvfb-run.vlY57Y’ ‘~/tmp/scratch/xvfb-run.vyOgP7’
‘~/tmp/scratch/xvfb-run.yMj8dT’
Flavor: r-devel-linux-x86_64-debian-gcc
Version: 1.4-4
Check: examples
Result: ERROR
Running examples in ‘tram-Ex.R’ failed
The error most likely occurred in:
> ### Name: tram-methods
> ### Title: Methods for Stratified Linear Transformation Models
> ### Aliases: as.mlt.tram model.frame.tram model.matrix.tram
> ### model.matrix.stram coef.tram coef.Lm coef.Survreg vcov.tram
> ### logLik.tram estfun.tram predict.tram predict.stram residuals.tram
> ### plot.tram plot.ROCtram PI PI.tram PI.default OVL OVL.tram OVL.default
> ### TV TV.tram TV.default L1 L1.tram L1.default ROC ROC.tram ROC.default
>
> ### ** Examples
>
>
> data("BostonHousing2", package = "mlbench")
>
> ### fit non-normal Box-Cox type linear model with two
> ### baseline functions (for houses near and off Charles River)
> BC_BH_2 <- BoxCox(cmedv | 0 + chas ~ crim + zn + indus + nox +
+ rm + age + dis + rad + tax + ptratio + b + lstat,
+ data = BostonHousing2)
> logLik(BC_BH_2)
'log Lik.' -1334.509 (df=26)
>
> ### classical likelihood inference
> summary(BC_BH_2)
(Stratified) Non-normal (Box-Cox-Type) Linear Regression Model
Call:
BoxCox(formula = cmedv | 0 + chas ~ crim + zn + indus + nox +
rm + age + dis + rad + tax + ptratio + b + lstat, data = BostonHousing2)
Coefficients:
Estimate Std. Error z value Pr(>|z|)
crim -0.0467934 0.0074130 -6.312 2.75e-10 ***
zn 0.0061493 0.0029332 2.096 0.036 *
indus 0.0140691 0.0131135 1.073 0.283
nox -4.9491733 0.8464083 -5.847 5.00e-09 ***
rm 0.4367871 0.0948227 4.606 4.10e-06 ***
age -0.0016582 0.0028369 -0.585 0.559
dis -0.2991522 0.0437647 -6.835 8.17e-12 ***
rad 0.0811965 0.0142694 5.690 1.27e-08 ***
tax -0.0037180 0.0008041 -4.624 3.76e-06 ***
ptratio -0.2184276 0.0285718 -7.645 2.09e-14 ***
b 0.0026670 0.0005776 4.618 3.88e-06 ***
lstat -0.1669550 0.0123199 -13.552 < 2e-16 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Log-Likelihood:
-1334.509 (df = 26)
Likelihood-ratio Test: Chisq = 817.2315 on 12 degrees of freedom; p = < 2.2e-16
>
> ### coefficients of the linear predictor
> coef(BC_BH_2)
crim zn indus nox rm age
-0.046793449 0.006149300 0.014069126 -4.949173280 0.436787052 -0.001658226
dis rad tax ptratio b lstat
-0.299152155 0.081196511 -0.003718004 -0.218427636 0.002667027 -0.166954986
>
> ### plot linear predictor (mean of _transformed_ response)
> ### vs. observed values
> plot(predict(BC_BH_2, type = "lp"), BostonHousing2$cmedv)
>
> ### all coefficients
> coef(BC_BH_2, with_baseline = TRUE)
Bs1(cmedv):chas0 Bs2(cmedv):chas0 Bs3(cmedv):chas0 Bs4(cmedv):chas0
-13.300866929 -11.573644227 -11.573644227 -4.413426081
Bs5(cmedv):chas0 Bs6(cmedv):chas0 Bs7(cmedv):chas0 Bs1(cmedv):chas1
-2.925484258 -2.925484252 -2.174967260 -17.446835508
Bs2(cmedv):chas1 Bs3(cmedv):chas1 Bs4(cmedv):chas1 Bs5(cmedv):chas1
-17.446835508 -8.223809772 -4.372511980 -4.372511983
Bs6(cmedv):chas1 Bs7(cmedv):chas1 crim zn
-4.372511985 -3.374958920 -0.046793449 0.006149300
indus nox rm age
0.014069126 -4.949173280 0.436787052 -0.001658226
dis rad tax ptratio
-0.299152155 0.081196511 -0.003718004 -0.218427636
b lstat
0.002667027 -0.166954986
>
> ### compute predicted median along with 10% and 90% quantile for the first
> ### observations
> predict(BC_BH_2, newdata = BostonHousing2[1:3,], type = "quantile",
+ prob = c(.1, .5, .9))
prob [,1] [,2] [,3]
0.1 22.77287 19.83914 23.39759
0.5 27.98502 23.65909 29.08732
0.9 38.50992 29.56087 41.48885
>
> ### plot the predicted density for these observations
> plot(BC_BH_2, newdata = BostonHousing2[1:3, -1],
+ which = "distribution", type = "density", K = 1000)
>
> ### evaluate the two baseline transformations, with confidence intervals
> nd <- model.frame(BC_BH_2)[1:2, -1]
> nd$chas <- factor(c("0", "1"))
> library("colorspace")
> col <- diverge_hcl(2, h = c(246, 40), c = 96, l = c(65, 90))
> fill <- diverge_hcl(2, h = c(246, 40), c = 96, l = c(65, 90), alpha = .3)
> plot(BC_BH_2, which = "baseline only", newdata = nd, col = col,
+ confidence = "interval", fill = fill, lwd = 2,
+ xlab = "Median Value", ylab = expression(h[Y]))
> legend("bottomright", lty = 1, col = col,
+ title = "Near Charles River", legend = c("no", "yes"), bty = "n")
>
> ### cars data; with quantile functions
> plot(dist ~ speed, data = cars)
> m <- Colr(dist ~ speed, data = cars)
> q <- predict(as.mlt(m), newdata = data.frame(speed = s <- 7:20),
+ type = "quantile", prob = c(1, 5, 9) / 10)
> lines(s, q[1,])
> lines(s, q[2,])
> lines(s, q[3,])
>
> nd <- data.frame(speed = s <- as.double(1:5 * 5))
>
> # Prob(dist at speed s > dist at speed 0)
> # speed 0 is reference, not a good choice here
> PI(m, newdata = nd)
[,1] [,2] [,3] [,4] [,5]
[1,] 0.8593495 0.978335 0.9975546 0.9997618 0.9999786
>
> # Prob(dist at speed s > dist at speed 15)
> lp15 <- c(predict(m, newdata = data.frame(speed = 15)))
> PI(m, newdata = nd, reference = lp15)
[,1] [,2] [,3] [,4] [,5]
[1,] 0.02166504 0.1406505 0.5 0.8593495 0.978335
> PI(m, newdata = nd, reference = nd[3,,drop = FALSE])
[,1] [,2] [,3] [,4] [,5]
[1,] 0.02166504 0.1406505 0.5 0.8593495 0.978335
>
> # Prob(dist at speed s' > dist at speed s)
> PI(m, newdata = nd, reference = nd)
1 2 3 4
2 0.8593495
3 0.9783350 0.8593495
4 0.9975546 0.9783350 0.8593495
5 0.9997618 0.9975546 0.9783350 0.8593495
> # essentially:
> lp <- predict(m, newdata = nd)
> PI(object = dist(lp))
1 2 3 4
2 0.8593495
3 0.9783350 0.8593495
4 0.9975546 0.9783350 0.8593495
5 0.9997618 0.9975546 0.9783350 0.8593495
> # same, with simultaneous confidence intervals
> PI(m, newdata = nd, reference = nd, conf.level = .95)
Estimate lwr upr
1-2 0.8593495 0.7811056 0.9141291
1-3 0.9783350 0.9324841 0.9937147
2-3 0.8593495 0.7811056 0.9141291
1-4 0.9975546 0.9835574 0.9996740
2-4 0.9783350 0.9324841 0.9937147
3-4 0.8593495 0.7811056 0.9141291
1-5 0.9997618 0.9965137 0.9999854
2-5 0.9975546 0.9835574 0.9996740
3-5 0.9783350 0.9324841 0.9937147
4-5 0.8593495 0.7811056 0.9141291
attr(,"conf.level")
[1] 0.95
attr(,"calpha")
[1] 1.960362
>
> # plot ROC curves + confidence bands
> # compare speed 20 and 25 to speed 15
> plot(ROC(m, newdata = nd[4:5,,drop = FALSE],
+ reference = nd[3,,drop = FALSE],
+ conf.level = 0.95))
>
> # Overlap of conditional densities at speed s' and s
> OVL(m, newdata = nd, reference = nd)
1 2 3 4
2 0.419779466
3 0.131832586 0.419779466
4 0.036802262 0.131832586 0.419779466
5 0.009910296 0.036802262 0.131832586 0.419779466
>
> ### ROC analysis (takes too long for CRAN Windows)
> if (require("mlbench") && .Platform$OS.type != "windows") {
+
+ layout(matrix(1:4, nrow = 2))
+ data("PimaIndiansDiabetes2", package = "mlbench")
+ dia <- sort(unique(PimaIndiansDiabetes2$diabetes))
+ nd <- data.frame(diabetes = dia,
+ age = 29, mass = 32) ### median values
+
+ ### unconditional ROC analysis: glucose tolerance test
+ m0 <- Colr(glucose ~ diabetes, data = PimaIndiansDiabetes2)
+ # ROC curve + confidence band
+ plot(ROC(m0, newdata = nd[2,,drop = FALSE], conf.level = .95))
+ # Wald interval for AUC
+ PI(m0, newdata = nd[2,,drop = FALSE], conf.level = .95)
+ # score interval for AUC
+ PI(-c(coef(m0), score_test(m0)$conf.int[2:1]))
+
+ ### adjusted ROC analysis for age and mass
+ m1 <- Colr(glucose ~ diabetes + age + mass, data = PimaIndiansDiabetes2)
+ # ROC curve + confidence band (this is the same for all ages /
+ # masses)
+ plot(ROC(m1, newdata = nd[2,,drop = FALSE],
+ reference = nd[1,,drop = FALSE],
+ conf.level = .95))
+ # Wald interval for adjusted AUC
+ PI(m1, newdata = nd[2,,drop = FALSE], reference = nd[1,,drop = FALSE],
+ conf.level = .95)
+ # Score interval for adjusted AUC
+ PI(-c(coef(m1)[1], score_test(m1, names(coef(m1))[1])$conf.int[2:1]))
+
+ ### conditional ROC analysis: AUC regression ~ age + mass
+ m2 <- Colr(glucose ~ diabetes * (age + mass), data = PimaIndiansDiabetes2)
+ # ROC curve for a person with age = 29 and mass = 32
+ plot(ROC(m2, newdata = nd[2,,drop = FALSE],
+ reference = nd[1,,drop = FALSE],
+ conf.level = .95))
+ # AUC for persons ages 21:81, all with mass = 32
+ nd1 <- data.frame(diabetes = nd[1,"diabetes"], age = 21:81, mass = 32)
+ nd2 <- data.frame(diabetes = nd[2,"diabetes"], age = 21:81, mass = 32)
+ auc <- PI(m2, newdata = nd2, reference = nd1, one2one = TRUE,
+ conf.level = 0.95)
+ plot(nd1$age, auc[, "Estimate"], xlab = "Age (in years)", ylab =
+ "AUC", ylim = c(0, 1), type = "l")
+ lines(nd1$age, auc[, "lwr"], lty = 3)
+ lines(nd1$age, auc[, "upr"], lty = 3)
+ }
Loading required package: mlbench
Warning in data("PimaIndiansDiabetes2", package = "mlbench") :
data set ‘PimaIndiansDiabetes2’ not found
Error: object 'PimaIndiansDiabetes2' not found
Execution halted
Flavor: r-devel-linux-x86_64-fedora-clang
Version: 1.4-4
Check: examples
Result: ERROR
Running examples in ‘tram-Ex.R’ failed
The error most likely occurred in:
> ### Name: tram-methods
> ### Title: Methods for Stratified Linear Transformation Models
> ### Aliases: as.mlt.tram model.frame.tram model.matrix.tram
> ### model.matrix.stram coef.tram coef.Lm coef.Survreg vcov.tram
> ### logLik.tram estfun.tram predict.tram predict.stram residuals.tram
> ### plot.tram plot.ROCtram PI PI.tram PI.default OVL OVL.tram OVL.default
> ### TV TV.tram TV.default L1 L1.tram L1.default ROC ROC.tram ROC.default
>
> ### ** Examples
>
>
> data("BostonHousing2", package = "mlbench")
>
> ### fit non-normal Box-Cox type linear model with two
> ### baseline functions (for houses near and off Charles River)
> BC_BH_2 <- BoxCox(cmedv | 0 + chas ~ crim + zn + indus + nox +
+ rm + age + dis + rad + tax + ptratio + b + lstat,
+ data = BostonHousing2)
> logLik(BC_BH_2)
'log Lik.' -1334.509 (df=26)
>
> ### classical likelihood inference
> summary(BC_BH_2)
(Stratified) Non-normal (Box-Cox-Type) Linear Regression Model
Call:
BoxCox(formula = cmedv | 0 + chas ~ crim + zn + indus + nox +
rm + age + dis + rad + tax + ptratio + b + lstat, data = BostonHousing2)
Coefficients:
Estimate Std. Error z value Pr(>|z|)
crim -0.0467906 0.0074130 -6.312 2.76e-10 ***
zn 0.0061513 0.0029332 2.097 0.036 *
indus 0.0140681 0.0131135 1.073 0.283
nox -4.9487919 0.8464110 -5.847 5.01e-09 ***
rm 0.4368418 0.0948225 4.607 4.09e-06 ***
age -0.0016568 0.0028368 -0.584 0.559
dis -0.2991249 0.0437646 -6.835 8.21e-12 ***
rad 0.0811888 0.0142694 5.690 1.27e-08 ***
tax -0.0037180 0.0008041 -4.624 3.76e-06 ***
ptratio -0.2184113 0.0285718 -7.644 2.11e-14 ***
b 0.0026673 0.0005776 4.618 3.87e-06 ***
lstat -0.1669453 0.0123199 -13.551 < 2e-16 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Log-Likelihood:
-1334.509 (df = 26)
Likelihood-ratio Test: Chisq = 817.2314 on 12 degrees of freedom; p = < 2.2e-16
>
> ### coefficients of the linear predictor
> coef(BC_BH_2)
crim zn indus nox rm age
-0.046790563 0.006151332 0.014068066 -4.948791933 0.436841809 -0.001656839
dis rad tax ptratio b lstat
-0.299124862 0.081188783 -0.003717984 -0.218411314 0.002667338 -0.166945349
>
> ### plot linear predictor (mean of _transformed_ response)
> ### vs. observed values
> plot(predict(BC_BH_2, type = "lp"), BostonHousing2$cmedv)
>
> ### all coefficients
> coef(BC_BH_2, with_baseline = TRUE)
Bs1(cmedv):chas0 Bs2(cmedv):chas0 Bs3(cmedv):chas0 Bs4(cmedv):chas0
-13.299892745 -11.572055177 -11.572055179 -4.413500468
Bs5(cmedv):chas0 Bs6(cmedv):chas0 Bs7(cmedv):chas0 Bs1(cmedv):chas1
-2.922815888 -2.922815896 -2.176114273 -17.466541536
Bs2(cmedv):chas1 Bs3(cmedv):chas1 Bs4(cmedv):chas1 Bs5(cmedv):chas1
-17.466541536 -8.197577847 -4.375130082 -4.375130049
Bs6(cmedv):chas1 Bs7(cmedv):chas1 crim zn
-4.375130134 -3.375504890 -0.046790563 0.006151332
indus nox rm age
0.014068066 -4.948791933 0.436841809 -0.001656839
dis rad tax ptratio
-0.299124862 0.081188783 -0.003717984 -0.218411314
b lstat
0.002667338 -0.166945349
>
> ### compute predicted median along with 10% and 90% quantile for the first
> ### observations
> predict(BC_BH_2, newdata = BostonHousing2[1:3,], type = "quantile",
+ prob = c(.1, .5, .9))
prob [,1] [,2] [,3]
0.1 22.77239 19.83903 23.39704
0.5 27.98349 23.65863 29.08549
0.9 38.50440 29.55907 41.48202
>
> ### plot the predicted density for these observations
> plot(BC_BH_2, newdata = BostonHousing2[1:3, -1],
+ which = "distribution", type = "density", K = 1000)
>
> ### evaluate the two baseline transformations, with confidence intervals
> nd <- model.frame(BC_BH_2)[1:2, -1]
> nd$chas <- factor(c("0", "1"))
> library("colorspace")
> col <- diverge_hcl(2, h = c(246, 40), c = 96, l = c(65, 90))
> fill <- diverge_hcl(2, h = c(246, 40), c = 96, l = c(65, 90), alpha = .3)
> plot(BC_BH_2, which = "baseline only", newdata = nd, col = col,
+ confidence = "interval", fill = fill, lwd = 2,
+ xlab = "Median Value", ylab = expression(h[Y]))
> legend("bottomright", lty = 1, col = col,
+ title = "Near Charles River", legend = c("no", "yes"), bty = "n")
>
> ### cars data; with quantile functions
> plot(dist ~ speed, data = cars)
> m <- Colr(dist ~ speed, data = cars)
> q <- predict(as.mlt(m), newdata = data.frame(speed = s <- 7:20),
+ type = "quantile", prob = c(1, 5, 9) / 10)
> lines(s, q[1,])
> lines(s, q[2,])
> lines(s, q[3,])
>
> nd <- data.frame(speed = s <- as.double(1:5 * 5))
>
> # Prob(dist at speed s > dist at speed 0)
> # speed 0 is reference, not a good choice here
> PI(m, newdata = nd)
[,1] [,2] [,3] [,4] [,5]
[1,] 0.8593495 0.978335 0.9975546 0.9997618 0.9999786
>
> # Prob(dist at speed s > dist at speed 15)
> lp15 <- c(predict(m, newdata = data.frame(speed = 15)))
> PI(m, newdata = nd, reference = lp15)
[,1] [,2] [,3] [,4] [,5]
[1,] 0.02166504 0.1406505 0.5 0.8593495 0.978335
> PI(m, newdata = nd, reference = nd[3,,drop = FALSE])
[,1] [,2] [,3] [,4] [,5]
[1,] 0.02166504 0.1406505 0.5 0.8593495 0.978335
>
> # Prob(dist at speed s' > dist at speed s)
> PI(m, newdata = nd, reference = nd)
1 2 3 4
2 0.8593495
3 0.9783350 0.8593495
4 0.9975546 0.9783350 0.8593495
5 0.9997618 0.9975546 0.9783350 0.8593495
> # essentially:
> lp <- predict(m, newdata = nd)
> PI(object = dist(lp))
1 2 3 4
2 0.8593495
3 0.9783350 0.8593495
4 0.9975546 0.9783350 0.8593495
5 0.9997618 0.9975546 0.9783350 0.8593495
> # same, with simultaneous confidence intervals
> PI(m, newdata = nd, reference = nd, conf.level = .95)
Estimate lwr upr
1-2 0.8593495 0.7811056 0.9141291
1-3 0.9783350 0.9324841 0.9937147
2-3 0.8593495 0.7811056 0.9141291
1-4 0.9975546 0.9835574 0.9996740
2-4 0.9783350 0.9324841 0.9937147
3-4 0.8593495 0.7811056 0.9141291
1-5 0.9997618 0.9965137 0.9999854
2-5 0.9975546 0.9835574 0.9996740
3-5 0.9783350 0.9324841 0.9937147
4-5 0.8593495 0.7811056 0.9141291
attr(,"conf.level")
[1] 0.95
attr(,"calpha")
[1] 1.960362
>
> # plot ROC curves + confidence bands
> # compare speed 20 and 25 to speed 15
> plot(ROC(m, newdata = nd[4:5,,drop = FALSE],
+ reference = nd[3,,drop = FALSE],
+ conf.level = 0.95))
>
> # Overlap of conditional densities at speed s' and s
> OVL(m, newdata = nd, reference = nd)
1 2 3 4
2 0.419779466
3 0.131832586 0.419779466
4 0.036802262 0.131832586 0.419779466
5 0.009910296 0.036802262 0.131832586 0.419779466
>
> ### ROC analysis (takes too long for CRAN Windows)
> if (require("mlbench") && .Platform$OS.type != "windows") {
+
+ layout(matrix(1:4, nrow = 2))
+ data("PimaIndiansDiabetes2", package = "mlbench")
+ dia <- sort(unique(PimaIndiansDiabetes2$diabetes))
+ nd <- data.frame(diabetes = dia,
+ age = 29, mass = 32) ### median values
+
+ ### unconditional ROC analysis: glucose tolerance test
+ m0 <- Colr(glucose ~ diabetes, data = PimaIndiansDiabetes2)
+ # ROC curve + confidence band
+ plot(ROC(m0, newdata = nd[2,,drop = FALSE], conf.level = .95))
+ # Wald interval for AUC
+ PI(m0, newdata = nd[2,,drop = FALSE], conf.level = .95)
+ # score interval for AUC
+ PI(-c(coef(m0), score_test(m0)$conf.int[2:1]))
+
+ ### adjusted ROC analysis for age and mass
+ m1 <- Colr(glucose ~ diabetes + age + mass, data = PimaIndiansDiabetes2)
+ # ROC curve + confidence band (this is the same for all ages /
+ # masses)
+ plot(ROC(m1, newdata = nd[2,,drop = FALSE],
+ reference = nd[1,,drop = FALSE],
+ conf.level = .95))
+ # Wald interval for adjusted AUC
+ PI(m1, newdata = nd[2,,drop = FALSE], reference = nd[1,,drop = FALSE],
+ conf.level = .95)
+ # Score interval for adjusted AUC
+ PI(-c(coef(m1)[1], score_test(m1, names(coef(m1))[1])$conf.int[2:1]))
+
+ ### conditional ROC analysis: AUC regression ~ age + mass
+ m2 <- Colr(glucose ~ diabetes * (age + mass), data = PimaIndiansDiabetes2)
+ # ROC curve for a person with age = 29 and mass = 32
+ plot(ROC(m2, newdata = nd[2,,drop = FALSE],
+ reference = nd[1,,drop = FALSE],
+ conf.level = .95))
+ # AUC for persons ages 21:81, all with mass = 32
+ nd1 <- data.frame(diabetes = nd[1,"diabetes"], age = 21:81, mass = 32)
+ nd2 <- data.frame(diabetes = nd[2,"diabetes"], age = 21:81, mass = 32)
+ auc <- PI(m2, newdata = nd2, reference = nd1, one2one = TRUE,
+ conf.level = 0.95)
+ plot(nd1$age, auc[, "Estimate"], xlab = "Age (in years)", ylab =
+ "AUC", ylim = c(0, 1), type = "l")
+ lines(nd1$age, auc[, "lwr"], lty = 3)
+ lines(nd1$age, auc[, "upr"], lty = 3)
+ }
Loading required package: mlbench
Warning in data("PimaIndiansDiabetes2", package = "mlbench") :
data set ‘PimaIndiansDiabetes2’ not found
Error: object 'PimaIndiansDiabetes2' not found
Execution halted
Flavor: r-devel-linux-x86_64-fedora-gcc
Version: 1.4-4
Check: examples
Result: ERROR
Running examples in ‘tram-Ex.R’ failed
The error most likely occurred in:
> base::assign(".ptime", proc.time(), pos = "CheckExEnv")
> ### Name: tram-methods
> ### Title: Methods for Stratified Linear Transformation Models
> ### Aliases: as.mlt.tram model.frame.tram model.matrix.tram
> ### model.matrix.stram coef.tram coef.Lm coef.Survreg vcov.tram
> ### logLik.tram estfun.tram predict.tram predict.stram residuals.tram
> ### plot.tram plot.ROCtram PI PI.tram PI.default OVL OVL.tram OVL.default
> ### TV TV.tram TV.default L1 L1.tram L1.default ROC ROC.tram ROC.default
>
> ### ** Examples
>
>
> data("BostonHousing2", package = "mlbench")
>
> ### fit non-normal Box-Cox type linear model with two
> ### baseline functions (for houses near and off Charles River)
> BC_BH_2 <- BoxCox(cmedv | 0 + chas ~ crim + zn + indus + nox +
+ rm + age + dis + rad + tax + ptratio + b + lstat,
+ data = BostonHousing2)
> logLik(BC_BH_2)
'log Lik.' -1334.509 (df=26)
>
> ### classical likelihood inference
> summary(BC_BH_2)
(Stratified) Non-normal (Box-Cox-Type) Linear Regression Model
Call:
BoxCox(formula = cmedv | 0 + chas ~ crim + zn + indus + nox +
rm + age + dis + rad + tax + ptratio + b + lstat, data = BostonHousing2)
Coefficients:
Estimate Std. Error z value Pr(>|z|)
crim -0.0467906 0.0074130 -6.312 2.76e-10 ***
zn 0.0061513 0.0029332 2.097 0.036 *
indus 0.0140681 0.0131135 1.073 0.283
nox -4.9487919 0.8464110 -5.847 5.01e-09 ***
rm 0.4368418 0.0948225 4.607 4.09e-06 ***
age -0.0016568 0.0028368 -0.584 0.559
dis -0.2991249 0.0437646 -6.835 8.21e-12 ***
rad 0.0811888 0.0142694 5.690 1.27e-08 ***
tax -0.0037180 0.0008041 -4.624 3.76e-06 ***
ptratio -0.2184113 0.0285718 -7.644 2.11e-14 ***
b 0.0026673 0.0005776 4.618 3.87e-06 ***
lstat -0.1669453 0.0123199 -13.551 < 2e-16 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Log-Likelihood:
-1334.509 (df = 26)
Likelihood-ratio Test: Chisq = 817.2314 on 12 degrees of freedom; p = < 2.2e-16
>
> ### coefficients of the linear predictor
> coef(BC_BH_2)
crim zn indus nox rm age
-0.046790563 0.006151332 0.014068066 -4.948791933 0.436841809 -0.001656839
dis rad tax ptratio b lstat
-0.299124862 0.081188783 -0.003717984 -0.218411314 0.002667338 -0.166945349
>
> ### plot linear predictor (mean of _transformed_ response)
> ### vs. observed values
> plot(predict(BC_BH_2, type = "lp"), BostonHousing2$cmedv)
>
> ### all coefficients
> coef(BC_BH_2, with_baseline = TRUE)
Bs1(cmedv):chas0 Bs2(cmedv):chas0 Bs3(cmedv):chas0 Bs4(cmedv):chas0
-13.299892745 -11.572055177 -11.572055179 -4.413500468
Bs5(cmedv):chas0 Bs6(cmedv):chas0 Bs7(cmedv):chas0 Bs1(cmedv):chas1
-2.922815888 -2.922815896 -2.176114273 -17.466541536
Bs2(cmedv):chas1 Bs3(cmedv):chas1 Bs4(cmedv):chas1 Bs5(cmedv):chas1
-17.466541536 -8.197577847 -4.375130082 -4.375130049
Bs6(cmedv):chas1 Bs7(cmedv):chas1 crim zn
-4.375130134 -3.375504890 -0.046790563 0.006151332
indus nox rm age
0.014068066 -4.948791933 0.436841809 -0.001656839
dis rad tax ptratio
-0.299124862 0.081188783 -0.003717984 -0.218411314
b lstat
0.002667338 -0.166945349
>
> ### compute predicted median along with 10% and 90% quantile for the first
> ### observations
> predict(BC_BH_2, newdata = BostonHousing2[1:3,], type = "quantile",
+ prob = c(.1, .5, .9))
prob [,1] [,2] [,3]
0.1 22.77239 19.83903 23.39704
0.5 27.98349 23.65863 29.08549
0.9 38.50440 29.55907 41.48202
>
> ### plot the predicted density for these observations
> plot(BC_BH_2, newdata = BostonHousing2[1:3, -1],
+ which = "distribution", type = "density", K = 1000)
>
> ### evaluate the two baseline transformations, with confidence intervals
> nd <- model.frame(BC_BH_2)[1:2, -1]
> nd$chas <- factor(c("0", "1"))
> library("colorspace")
> col <- diverge_hcl(2, h = c(246, 40), c = 96, l = c(65, 90))
> fill <- diverge_hcl(2, h = c(246, 40), c = 96, l = c(65, 90), alpha = .3)
> plot(BC_BH_2, which = "baseline only", newdata = nd, col = col,
+ confidence = "interval", fill = fill, lwd = 2,
+ xlab = "Median Value", ylab = expression(h[Y]))
> legend("bottomright", lty = 1, col = col,
+ title = "Near Charles River", legend = c("no", "yes"), bty = "n")
>
> ### cars data; with quantile functions
> plot(dist ~ speed, data = cars)
> m <- Colr(dist ~ speed, data = cars)
> q <- predict(as.mlt(m), newdata = data.frame(speed = s <- 7:20),
+ type = "quantile", prob = c(1, 5, 9) / 10)
> lines(s, q[1,])
> lines(s, q[2,])
> lines(s, q[3,])
>
> nd <- data.frame(speed = s <- as.double(1:5 * 5))
>
> # Prob(dist at speed s > dist at speed 0)
> # speed 0 is reference, not a good choice here
> PI(m, newdata = nd)
[,1] [,2] [,3] [,4] [,5]
[1,] 0.8593495 0.978335 0.9975546 0.9997618 0.9999786
>
> # Prob(dist at speed s > dist at speed 15)
> lp15 <- c(predict(m, newdata = data.frame(speed = 15)))
> PI(m, newdata = nd, reference = lp15)
[,1] [,2] [,3] [,4] [,5]
[1,] 0.02166504 0.1406505 0.5 0.8593495 0.978335
> PI(m, newdata = nd, reference = nd[3,,drop = FALSE])
[,1] [,2] [,3] [,4] [,5]
[1,] 0.02166504 0.1406505 0.5 0.8593495 0.978335
>
> # Prob(dist at speed s' > dist at speed s)
> PI(m, newdata = nd, reference = nd)
1 2 3 4
2 0.8593495
3 0.9783350 0.8593495
4 0.9975546 0.9783350 0.8593495
5 0.9997618 0.9975546 0.9783350 0.8593495
> # essentially:
> lp <- predict(m, newdata = nd)
> PI(object = dist(lp))
1 2 3 4
2 0.8593495
3 0.9783350 0.8593495
4 0.9975546 0.9783350 0.8593495
5 0.9997618 0.9975546 0.9783350 0.8593495
> # same, with simultaneous confidence intervals
> PI(m, newdata = nd, reference = nd, conf.level = .95)
Estimate lwr upr
1-2 0.8593495 0.7811056 0.9141291
1-3 0.9783350 0.9324841 0.9937147
2-3 0.8593495 0.7811056 0.9141291
1-4 0.9975546 0.9835574 0.9996740
2-4 0.9783350 0.9324841 0.9937147
3-4 0.8593495 0.7811056 0.9141291
1-5 0.9997618 0.9965137 0.9999854
2-5 0.9975546 0.9835574 0.9996740
3-5 0.9783350 0.9324841 0.9937147
4-5 0.8593495 0.7811056 0.9141291
attr(,"conf.level")
[1] 0.95
attr(,"calpha")
[1] 1.960362
>
> # plot ROC curves + confidence bands
> # compare speed 20 and 25 to speed 15
> plot(ROC(m, newdata = nd[4:5,,drop = FALSE],
+ reference = nd[3,,drop = FALSE],
+ conf.level = 0.95))
>
> # Overlap of conditional densities at speed s' and s
> OVL(m, newdata = nd, reference = nd)
1 2 3 4
2 0.419779466
3 0.131832586 0.419779466
4 0.036802262 0.131832586 0.419779466
5 0.009910296 0.036802262 0.131832586 0.419779466
>
> ### ROC analysis (takes too long for CRAN Windows)
> if (require("mlbench") && .Platform$OS.type != "windows") {
+
+ layout(matrix(1:4, nrow = 2))
+ data("PimaIndiansDiabetes2", package = "mlbench")
+ dia <- sort(unique(PimaIndiansDiabetes2$diabetes))
+ nd <- data.frame(diabetes = dia,
+ age = 29, mass = 32) ### median values
+
+ ### unconditional ROC analysis: glucose tolerance test
+ m0 <- Colr(glucose ~ diabetes, data = PimaIndiansDiabetes2)
+ # ROC curve + confidence band
+ plot(ROC(m0, newdata = nd[2,,drop = FALSE], conf.level = .95))
+ # Wald interval for AUC
+ PI(m0, newdata = nd[2,,drop = FALSE], conf.level = .95)
+ # score interval for AUC
+ PI(-c(coef(m0), score_test(m0)$conf.int[2:1]))
+
+ ### adjusted ROC analysis for age and mass
+ m1 <- Colr(glucose ~ diabetes + age + mass, data = PimaIndiansDiabetes2)
+ # ROC curve + confidence band (this is the same for all ages /
+ # masses)
+ plot(ROC(m1, newdata = nd[2,,drop = FALSE],
+ reference = nd[1,,drop = FALSE],
+ conf.level = .95))
+ # Wald interval for adjusted AUC
+ PI(m1, newdata = nd[2,,drop = FALSE], reference = nd[1,,drop = FALSE],
+ conf.level = .95)
+ # Score interval for adjusted AUC
+ PI(-c(coef(m1)[1], score_test(m1, names(coef(m1))[1])$conf.int[2:1]))
+
+ ### conditional ROC analysis: AUC regression ~ age + mass
+ m2 <- Colr(glucose ~ diabetes * (age + mass), data = PimaIndiansDiabetes2)
+ # ROC curve for a person with age = 29 and mass = 32
+ plot(ROC(m2, newdata = nd[2,,drop = FALSE],
+ reference = nd[1,,drop = FALSE],
+ conf.level = .95))
+ # AUC for persons ages 21:81, all with mass = 32
+ nd1 <- data.frame(diabetes = nd[1,"diabetes"], age = 21:81, mass = 32)
+ nd2 <- data.frame(diabetes = nd[2,"diabetes"], age = 21:81, mass = 32)
+ auc <- PI(m2, newdata = nd2, reference = nd1, one2one = TRUE,
+ conf.level = 0.95)
+ plot(nd1$age, auc[, "Estimate"], xlab = "Age (in years)", ylab =
+ "AUC", ylim = c(0, 1), type = "l")
+ lines(nd1$age, auc[, "lwr"], lty = 3)
+ lines(nd1$age, auc[, "upr"], lty = 3)
+ }
Loading required package: mlbench
Warning in data("PimaIndiansDiabetes2", package = "mlbench") :
data set ‘PimaIndiansDiabetes2’ not found
Error: object 'PimaIndiansDiabetes2' not found
Execution halted
Examples with CPU (user + system) or elapsed time > 5s
user system elapsed
mmlt 6.777 0.152 7.741
perm_test 6.019 0.095 6.899
score_test 5.697 0.052 7.281
Coxph 5.469 0.090 6.560
Flavor: r-patched-linux-x86_64
Version: 1.4-4
Check: examples
Result: ERROR
Running examples in ‘tram-Ex.R’ failed
The error most likely occurred in:
> base::assign(".ptime", proc.time(), pos = "CheckExEnv")
> ### Name: tram-methods
> ### Title: Methods for Stratified Linear Transformation Models
> ### Aliases: as.mlt.tram model.frame.tram model.matrix.tram
> ### model.matrix.stram coef.tram coef.Lm coef.Survreg vcov.tram
> ### logLik.tram estfun.tram predict.tram predict.stram residuals.tram
> ### plot.tram plot.ROCtram PI PI.tram PI.default OVL OVL.tram OVL.default
> ### TV TV.tram TV.default L1 L1.tram L1.default ROC ROC.tram ROC.default
>
> ### ** Examples
>
>
> data("BostonHousing2", package = "mlbench")
>
> ### fit non-normal Box-Cox type linear model with two
> ### baseline functions (for houses near and off Charles River)
> BC_BH_2 <- BoxCox(cmedv | 0 + chas ~ crim + zn + indus + nox +
+ rm + age + dis + rad + tax + ptratio + b + lstat,
+ data = BostonHousing2)
> logLik(BC_BH_2)
'log Lik.' -1334.509 (df=26)
>
> ### classical likelihood inference
> summary(BC_BH_2)
(Stratified) Non-normal (Box-Cox-Type) Linear Regression Model
Call:
BoxCox(formula = cmedv | 0 + chas ~ crim + zn + indus + nox +
rm + age + dis + rad + tax + ptratio + b + lstat, data = BostonHousing2)
Coefficients:
Estimate Std. Error z value Pr(>|z|)
crim -0.0467906 0.0074130 -6.312 2.76e-10 ***
zn 0.0061513 0.0029332 2.097 0.036 *
indus 0.0140681 0.0131135 1.073 0.283
nox -4.9487919 0.8464110 -5.847 5.01e-09 ***
rm 0.4368418 0.0948225 4.607 4.09e-06 ***
age -0.0016568 0.0028368 -0.584 0.559
dis -0.2991249 0.0437646 -6.835 8.21e-12 ***
rad 0.0811888 0.0142694 5.690 1.27e-08 ***
tax -0.0037180 0.0008041 -4.624 3.76e-06 ***
ptratio -0.2184113 0.0285718 -7.644 2.11e-14 ***
b 0.0026673 0.0005776 4.618 3.87e-06 ***
lstat -0.1669453 0.0123199 -13.551 < 2e-16 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Log-Likelihood:
-1334.509 (df = 26)
Likelihood-ratio Test: Chisq = 817.2314 on 12 degrees of freedom; p = < 2.2e-16
>
> ### coefficients of the linear predictor
> coef(BC_BH_2)
crim zn indus nox rm age
-0.046790563 0.006151332 0.014068066 -4.948791933 0.436841809 -0.001656839
dis rad tax ptratio b lstat
-0.299124862 0.081188783 -0.003717984 -0.218411314 0.002667338 -0.166945349
>
> ### plot linear predictor (mean of _transformed_ response)
> ### vs. observed values
> plot(predict(BC_BH_2, type = "lp"), BostonHousing2$cmedv)
>
> ### all coefficients
> coef(BC_BH_2, with_baseline = TRUE)
Bs1(cmedv):chas0 Bs2(cmedv):chas0 Bs3(cmedv):chas0 Bs4(cmedv):chas0
-13.299892745 -11.572055177 -11.572055179 -4.413500468
Bs5(cmedv):chas0 Bs6(cmedv):chas0 Bs7(cmedv):chas0 Bs1(cmedv):chas1
-2.922815888 -2.922815896 -2.176114273 -17.466541536
Bs2(cmedv):chas1 Bs3(cmedv):chas1 Bs4(cmedv):chas1 Bs5(cmedv):chas1
-17.466541536 -8.197577847 -4.375130082 -4.375130049
Bs6(cmedv):chas1 Bs7(cmedv):chas1 crim zn
-4.375130134 -3.375504890 -0.046790563 0.006151332
indus nox rm age
0.014068066 -4.948791933 0.436841809 -0.001656839
dis rad tax ptratio
-0.299124862 0.081188783 -0.003717984 -0.218411314
b lstat
0.002667338 -0.166945349
>
> ### compute predicted median along with 10% and 90% quantile for the first
> ### observations
> predict(BC_BH_2, newdata = BostonHousing2[1:3,], type = "quantile",
+ prob = c(.1, .5, .9))
prob [,1] [,2] [,3]
0.1 22.77239 19.83903 23.39704
0.5 27.98349 23.65863 29.08549
0.9 38.50440 29.55907 41.48202
>
> ### plot the predicted density for these observations
> plot(BC_BH_2, newdata = BostonHousing2[1:3, -1],
+ which = "distribution", type = "density", K = 1000)
>
> ### evaluate the two baseline transformations, with confidence intervals
> nd <- model.frame(BC_BH_2)[1:2, -1]
> nd$chas <- factor(c("0", "1"))
> library("colorspace")
> col <- diverge_hcl(2, h = c(246, 40), c = 96, l = c(65, 90))
> fill <- diverge_hcl(2, h = c(246, 40), c = 96, l = c(65, 90), alpha = .3)
> plot(BC_BH_2, which = "baseline only", newdata = nd, col = col,
+ confidence = "interval", fill = fill, lwd = 2,
+ xlab = "Median Value", ylab = expression(h[Y]))
> legend("bottomright", lty = 1, col = col,
+ title = "Near Charles River", legend = c("no", "yes"), bty = "n")
>
> ### cars data; with quantile functions
> plot(dist ~ speed, data = cars)
> m <- Colr(dist ~ speed, data = cars)
> q <- predict(as.mlt(m), newdata = data.frame(speed = s <- 7:20),
+ type = "quantile", prob = c(1, 5, 9) / 10)
> lines(s, q[1,])
> lines(s, q[2,])
> lines(s, q[3,])
>
> nd <- data.frame(speed = s <- as.double(1:5 * 5))
>
> # Prob(dist at speed s > dist at speed 0)
> # speed 0 is reference, not a good choice here
> PI(m, newdata = nd)
[,1] [,2] [,3] [,4] [,5]
[1,] 0.8593495 0.978335 0.9975546 0.9997618 0.9999786
>
> # Prob(dist at speed s > dist at speed 15)
> lp15 <- c(predict(m, newdata = data.frame(speed = 15)))
> PI(m, newdata = nd, reference = lp15)
[,1] [,2] [,3] [,4] [,5]
[1,] 0.02166504 0.1406505 0.5 0.8593495 0.978335
> PI(m, newdata = nd, reference = nd[3,,drop = FALSE])
[,1] [,2] [,3] [,4] [,5]
[1,] 0.02166504 0.1406505 0.5 0.8593495 0.978335
>
> # Prob(dist at speed s' > dist at speed s)
> PI(m, newdata = nd, reference = nd)
1 2 3 4
2 0.8593495
3 0.9783350 0.8593495
4 0.9975546 0.9783350 0.8593495
5 0.9997618 0.9975546 0.9783350 0.8593495
> # essentially:
> lp <- predict(m, newdata = nd)
> PI(object = dist(lp))
1 2 3 4
2 0.8593495
3 0.9783350 0.8593495
4 0.9975546 0.9783350 0.8593495
5 0.9997618 0.9975546 0.9783350 0.8593495
> # same, with simultaneous confidence intervals
> PI(m, newdata = nd, reference = nd, conf.level = .95)
Estimate lwr upr
1-2 0.8593495 0.7811056 0.9141291
1-3 0.9783350 0.9324841 0.9937147
2-3 0.8593495 0.7811056 0.9141291
1-4 0.9975546 0.9835574 0.9996740
2-4 0.9783350 0.9324841 0.9937147
3-4 0.8593495 0.7811056 0.9141291
1-5 0.9997618 0.9965137 0.9999854
2-5 0.9975546 0.9835574 0.9996740
3-5 0.9783350 0.9324841 0.9937147
4-5 0.8593495 0.7811056 0.9141291
attr(,"conf.level")
[1] 0.95
attr(,"calpha")
[1] 1.960362
>
> # plot ROC curves + confidence bands
> # compare speed 20 and 25 to speed 15
> plot(ROC(m, newdata = nd[4:5,,drop = FALSE],
+ reference = nd[3,,drop = FALSE],
+ conf.level = 0.95))
>
> # Overlap of conditional densities at speed s' and s
> OVL(m, newdata = nd, reference = nd)
1 2 3 4
2 0.419779466
3 0.131832586 0.419779466
4 0.036802262 0.131832586 0.419779466
5 0.009910296 0.036802262 0.131832586 0.419779466
>
> ### ROC analysis (takes too long for CRAN Windows)
> if (require("mlbench") && .Platform$OS.type != "windows") {
+
+ layout(matrix(1:4, nrow = 2))
+ data("PimaIndiansDiabetes2", package = "mlbench")
+ dia <- sort(unique(PimaIndiansDiabetes2$diabetes))
+ nd <- data.frame(diabetes = dia,
+ age = 29, mass = 32) ### median values
+
+ ### unconditional ROC analysis: glucose tolerance test
+ m0 <- Colr(glucose ~ diabetes, data = PimaIndiansDiabetes2)
+ # ROC curve + confidence band
+ plot(ROC(m0, newdata = nd[2,,drop = FALSE], conf.level = .95))
+ # Wald interval for AUC
+ PI(m0, newdata = nd[2,,drop = FALSE], conf.level = .95)
+ # score interval for AUC
+ PI(-c(coef(m0), score_test(m0)$conf.int[2:1]))
+
+ ### adjusted ROC analysis for age and mass
+ m1 <- Colr(glucose ~ diabetes + age + mass, data = PimaIndiansDiabetes2)
+ # ROC curve + confidence band (this is the same for all ages /
+ # masses)
+ plot(ROC(m1, newdata = nd[2,,drop = FALSE],
+ reference = nd[1,,drop = FALSE],
+ conf.level = .95))
+ # Wald interval for adjusted AUC
+ PI(m1, newdata = nd[2,,drop = FALSE], reference = nd[1,,drop = FALSE],
+ conf.level = .95)
+ # Score interval for adjusted AUC
+ PI(-c(coef(m1)[1], score_test(m1, names(coef(m1))[1])$conf.int[2:1]))
+
+ ### conditional ROC analysis: AUC regression ~ age + mass
+ m2 <- Colr(glucose ~ diabetes * (age + mass), data = PimaIndiansDiabetes2)
+ # ROC curve for a person with age = 29 and mass = 32
+ plot(ROC(m2, newdata = nd[2,,drop = FALSE],
+ reference = nd[1,,drop = FALSE],
+ conf.level = .95))
+ # AUC for persons ages 21:81, all with mass = 32
+ nd1 <- data.frame(diabetes = nd[1,"diabetes"], age = 21:81, mass = 32)
+ nd2 <- data.frame(diabetes = nd[2,"diabetes"], age = 21:81, mass = 32)
+ auc <- PI(m2, newdata = nd2, reference = nd1, one2one = TRUE,
+ conf.level = 0.95)
+ plot(nd1$age, auc[, "Estimate"], xlab = "Age (in years)", ylab =
+ "AUC", ylim = c(0, 1), type = "l")
+ lines(nd1$age, auc[, "lwr"], lty = 3)
+ lines(nd1$age, auc[, "upr"], lty = 3)
+ }
Loading required package: mlbench
Warning in data("PimaIndiansDiabetes2", package = "mlbench") :
data set ‘PimaIndiansDiabetes2’ not found
Error: object 'PimaIndiansDiabetes2' not found
Execution halted
Examples with CPU (user + system) or elapsed time > 5s
user system elapsed
mmlt 7.248 0.149 8.708
score_test 6.270 0.036 7.723
perm_test 5.676 0.128 6.103
Coxph 5.451 0.133 7.236
Flavor: r-release-linux-x86_64