R Under development (unstable) (2024-01-29 r85841 ucrt) -- "Unsuffered Consequences" Copyright (C) 2024 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 > options(digits = 1) ## make M1 happy > > ## dgp > set.seed(29) > N <- 1000 > x <- runif(N) > y <- rchisq(N, df = 4) > d <- data.frame(y = y, x = x, one = 1) > > d$xx <- d$x - 5 ## shift x > > > ## no h-intercept; additional mu-intercept > m0 <- Survreg(y ~ x | x, data = d, remove_intercept = FALSE) > coef(as.mlt(m0)) log(y) (Intercept) x scl_x 1.52 2.38 -0.10 -0.04 > sqrt(diag(vcov(m0))) (Intercept) x scl_x 0.1 0.2 0.2 > > m1 <- Survreg(y ~ xx | x, data = d, remove_intercept = FALSE) > coef(as.mlt(m1)) log(y) (Intercept) xx scl_x 1.52 1.86 -0.10 -0.04 > sqrt(diag(vcov(m1))) (Intercept) xx scl_x 1.1 0.2 0.2 > > m2 <- Survreg(y ~ xx | xx, data = d, remove_intercept = FALSE) > coef(as.mlt(m2)) log(y) (Intercept) xx scl_xx 1.38 1.86 -0.10 -0.04 > sqrt(diag(vcov(m2))) (Intercept) xx scl_xx 1.1 0.2 0.2 > > > ## h-intercept; scale_shift > m0 <- Survreg(y ~ x | x, data = d, scale_shift = TRUE) > coef(as.mlt(m0)) (Intercept) log(y) x scl_x -2.38 1.52 -0.06 -0.04 > sqrt(diag(vcov(m0))) x scl_x 0.1 0.2 > > m1 <- Survreg(y ~ xx | x, data = d, scale_shift = TRUE) > coef(as.mlt(m1)) (Intercept) log(y) xx scl_x -2.08 1.52 -0.06 -0.04 > sqrt(diag(vcov(m1))) xx scl_x 0.1 0.2 > > m2 <- Survreg(y ~ xx | xx, data = d, scale_shift = TRUE) > coef(as.mlt(m2)) (Intercept) log(y) xx scl_xx -1.88 1.38 -0.06 -0.04 > sqrt(diag(vcov(m2))) xx scl_xx 0.1 0.2 > > OR <- 1 > > d$ly <- log(y) > > ## no h-intercept; additional mu-intercept > m0 <- Coxph(ly ~ x | x, data = d, log_first = FALSE, order = OR, remove_intercept = FALSE) Warning message: In c.basis(bresponse = function (data, deriv = 0L, integrate = FALSE) : more than one basis contains an intercept term > coef(as.mlt(m0)) Bs1(ly) (Intercept) x scl_x -1.47 -0.68 0.07 -0.04 > sqrt(diag(vcov(m0))) (Intercept) x scl_x 0.08 0.14 0.16 > > m1 <- Coxph(ly ~ xx | x, data = d, log_first = FALSE, order = OR, remove_intercept = FALSE) Warning message: In c.basis(bresponse = function (data, deriv = 0L, integrate = FALSE) : more than one basis contains an intercept term > coef(as.mlt(m1)) Bs1(ly) (Intercept) xx scl_x -1.47 -0.31 0.07 -0.04 > sqrt(diag(vcov(m1))) (Intercept) xx scl_x 0.6 0.1 0.2 > > m2 <- Coxph(ly ~ xx | xx, data = d, log_first = FALSE, order = OR, remove_intercept = FALSE) Warning message: In c.basis(bresponse = function (data, deriv = 0L, integrate = FALSE) : more than one basis contains an intercept term > coef(as.mlt(m2)) Bs1(ly) (Intercept) xx scl_xx -1.34 -0.32 0.07 -0.04 > sqrt(diag(vcov(m2))) (Intercept) xx scl_xx 0.6 0.1 0.2 > > OR <- 1 > > ## h-intercept; scale_shift > m0 <- Coxph(y ~ x | x, data = d, scale_shift = TRUE, log_first = TRUE, order = OR) > coef(as.mlt(m0)) Bs1(y) Bs2(y) x scl_x -2.15 0.79 0.06 -0.04 > sqrt(diag(vcov(m0))) x scl_x 0.1 0.2 > > m1 <- Coxph(y ~ xx | x, data = d, scale_shift = TRUE, log_first = TRUE, order = OR) > coef(as.mlt(m1)) Bs1(y) Bs2(y) xx scl_x -1.84 1.10 0.06 -0.04 > sqrt(diag(vcov(m1))) xx scl_x 0.1 0.2 > > m2 <- Coxph(y ~ xx | xx, data = d, scale_shift = TRUE, log_first = TRUE, order = OR) > coef(as.mlt(m2)) Bs1(y) Bs2(y) xx scl_xx -1.68 1.00 0.05 -0.04 > sqrt(diag(vcov(m2))) xx scl_xx 0.1 0.2 > > > proc.time() user system elapsed 2.3 0.3 2.6