Skip to content

Commit

Permalink
Include rmst() formula example ~ Surv(month, evntd, trt)
Browse files Browse the repository at this point in the history
  • Loading branch information
jdblischak committed Mar 14, 2024
1 parent 9ed6d32 commit 3ccb493
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 6 deletions.
17 changes: 14 additions & 3 deletions R/rmst.R
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,27 @@
#' )
#'
#' # Formula interface
#' library("survival")
#'
#' rmst(
#' month ~ evntd + trt,
#' Surv(month | evntd) ~ trt,
#' data = ex1_delayed_effect,
#' tau = 10,
#' reference = "0"
#' )
#'
#' library("survival")
#' # alternative
#' rmst(
#' Surv(month | evntd) ~ trt,
#' ~ Surv(month, evntd, trt),
#' data = ex1_delayed_effect,
#' tau = 10,
#' reference = "0"
#' )
#'
#' # This example doesn't make statistical sense, but demonstrates that only the
#' # order of the 3 variables actually matters
#' rmst(
#' month ~ evntd + trt,
#' data = ex1_delayed_effect,
#' tau = 10,
#' reference = "0"
Expand Down
17 changes: 14 additions & 3 deletions man/rmst.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions tests/testthat/test-unvalidated-rmst.R
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,12 @@ test_that("formula method matches default method", {
reference = "0"
)
expect_equal(rmst_formula_2, rmst_default)

rmst_formula_3 <- rmst(
~ survival::Surv(month, evntd, trt),
data = ex1_delayed_effect,
tau = 10,
reference = "0"
)
expect_equal(rmst_formula_3, rmst_default)
})

0 comments on commit 3ccb493

Please sign in to comment.