tests/SurvregME.R

## -- Test utils & settings
source("test_util.R")
.run_test <- identical(Sys.getenv("NOT_CRAN"), "true")
oldopt <- options(digits = 4)
set.seed(100)

library("tramME")
library("tram")
library("survival")

m1 <- SurvregME(Surv(time, status) ~ rx, data = rats, dist = "exponential")
m2 <- survreg(Surv(time, status) ~ rx, data = rats, dist = "exponential")
chkeq(logLik(m1), logLik(m2), check.attributes = FALSE)
chkeq(coef(m1, as.survreg = TRUE), coef(m2), tol = 1e-6)

m1 <- SurvregME(Surv(time, status) ~ rx, data = rats, dist = "lognormal",
                fixed = c("rx" = -0.4))
m2 <- Survreg(Surv(time, status) ~ rx, data = rats, dist = "lognormal",
                fixed = c("rx" = -0.4))
stopifnot(m1$opt$convergence == 0, m2$convergence == 0)
chkeq(logLik(m1), logLik(m2), check.attributes = FALSE)
chkeq(coef(m1, with_baseline = TRUE), coef(m2, with_baseline = TRUE), tol = 1e-4)

summarize_tests()

options(oldopt)

Try the tramME package in your browser

Any scripts or data that you put into this service are public.

tramME documentation built on July 9, 2023, 7:10 p.m.