Skip to content

Commit

Permalink
add mboost for good measure
Browse files Browse the repository at this point in the history
it's in Imports but I'm not sure why so I might move it back
  • Loading branch information
hfrick committed Jan 17, 2024
1 parent c39ddb0 commit 9c0f295
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions tests/testthat/test-boost_tree-mboost.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
library(testthat)

test_that("model object", {
skip_if_not_installed("mboost")

lung2 <- lung[-14, ]
exp_f_fit <- mboost::blackboost(
Surv(time, status) ~ age + ph.ecog,
Expand Down Expand Up @@ -28,6 +30,8 @@ test_that("model object", {
# prediction: time --------------------------------------------------------

test_that("time predictions", {
skip_if_not_installed("mboost")

cox_spec <- boost_tree() %>%
set_engine("mboost") %>%
set_mode("censored regression")
Expand All @@ -50,6 +54,8 @@ test_that("time predictions", {
# prediction: survival ----------------------------------------------------

test_that("survival predictions", {
skip_if_not_installed("mboost")

pred_time <- c(0, 100, 200, 10000)

set.seed(403)
Expand Down Expand Up @@ -160,6 +166,8 @@ test_that("survival_curve_to_prob() works", {
})

test_that("survival_prob_mboost() works", {
skip_if_not_installed("mboost")

lung2 <- lung[-14, ]
mboost_object <- mboost::blackboost(
Surv(time, status) ~ age + ph.ecog,
Expand Down Expand Up @@ -187,6 +195,8 @@ test_that("survival_prob_mboost() works", {
})

test_that("can predict for out-of-domain timepoints", {
skip_if_not_installed("mboost")

eval_time_obs_max_and_ood <- c(1022, 2000)
obs_without_NA <- lung[c(2,4),] # two observations because of https://github.com/boost-R/mboost/issues/117

Expand All @@ -203,6 +213,8 @@ test_that("can predict for out-of-domain timepoints", {
# prediction: linear_pred -------------------------------------------------

test_that("linear_pred predictions", {
skip_if_not_installed("mboost")

lung2 <- lung[-14, ]
exp_f_fit <- mboost::blackboost(
Surv(time, status) ~ age + ph.ecog,
Expand Down Expand Up @@ -240,6 +252,8 @@ test_that("linear_pred predictions", {
# fit via matrix interface ------------------------------------------------

test_that("`fix_xy()` works", {
skip_if_not_installed("mboost")

lung_x <- as.matrix(lung[, c("age", "ph.ecog")])
lung_y <- Surv(lung$time, lung$status)
lung_pred <- lung[1:5, ]
Expand Down

0 comments on commit 9c0f295

Please sign in to comment.