diff --git a/inst/tinytest/test_outcome_models.R b/inst/tinytest/test_outcome_models.R index 850e3c9..dc1d848 100644 --- a/inst/tinytest/test_outcome_models.R +++ b/inst/tinytest/test_outcome_models.R @@ -116,7 +116,7 @@ test_outcome_continuous() test_outcome_phreg <- function() { phreg <- mets::phreg - phreg.par <- mets::phreg.par + phreg_weibull <- mets::phreg_weibull Surv <- survival::Surv #nolint par1 <- list(scale = 1 / 100, shape = 2) @@ -183,13 +183,20 @@ test_outcome_phreg <- function() { xx0 <- covar(1e4) dd <- outcome(xx0) |> cbind(xx0) - cox1 <- phreg.par(Surv(time, status) ~ a + x, data = dd) - expect_equivalent(coef(cox1), c(log(unlist(par1)), 0, 0), - tolerance = 0.2) + cox1 <- phreg_weibull(Surv(time, status) ~ a + x, data = dd) + # par1$scale ** par1$shape because of transformation in coxWeibull.lvm + expect_equivalent( + coef(cox1), + c(log(par1$scale ** par1$shape), 0, 0, log(par1$shape)), + tolerance = 0.2 + ) - cox0 <- phreg.par(Surv(time, status) ~ a + x, data = dd) - expect_equivalent(coef(cox0), c(log(unlist(par0)), 0, 0), - tolerance = 0.2) + cox0 <- phreg_weibull(Surv(time, status) ~ a + x, data = dd) + expect_equivalent( + coef(cox0), + c(log(par1$scale ** par1$shape), 0, 0, log(par1$shape)), + tolerance = 0.2 + ) ## Specify parameters outcome <- setargs(outcome_phreg, @@ -200,14 +207,19 @@ test_outcome_phreg <- function() { ) dd <- outcome(xx0) |> cbind(xx0) - cox1 <- phreg.par(Surv(time, status) ~ a + x, data = dd) - expect_equivalent(coef(cox1), c(log(unlist(par1)), coef(fit1)), - tolerance = 0.2) - - cox0 <- phreg.par(Surv(time, status) ~ a + x, data = dd) - expect_equivalent(coef(cox0), c(log(unlist(par0)), coef(fit1)), - tolerance = 0.2) + cox1 <- phreg_weibull(Surv(time, status) ~ a + x, data = dd) + expect_equivalent( + coef(cox1), + c(log(par1$scale ** par1$shape), coef(fit1), log(par1$shape)), + tolerance = 0.2 + ) + cox0 <- phreg_weibull(Surv(time, status) ~ a + x, data = dd) + expect_equivalent( + coef(cox0), + c(log(par0$scale ** par1$shape), coef(fit1), log(par0$shape)), + tolerance = 0.2 + ) # Specify design via `lp` argument outcome <- setallargs(