tests/testthat/test-exp.R

library(Temporal)
library(testthat)

test_that("Check exponential.", {
  
  # Without censoring.
  withr::with_seed(
    seed = 100,
    {
      data <- GenData(n = 1e3, dist = "exp", theta = 1)
      fit <- FitParaSurv(data, dist = "exp") 
    }
  )
  # Check confidence interval for rate contains 1.
  expect_true(all(fit@Parameters$L <= 1, 1 <= fit@Parameters$U))
  
  # With censoring.
  withr::with_seed(
    seed = 101,
    {
      data <- GenData(n = 1e3, dist = "exp", theta = 1, p = 0.2)
      fit <- FitParaSurv(data, dist = "exp") 
    }
  )
  # Check confidence interval for rate contains 1.
  expect_true(all(fit@Parameters$L <= 1, 1 <= fit@Parameters$U))
  
})

Try the Temporal package in your browser

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

Temporal documentation built on Sept. 24, 2023, 1:06 a.m.