tests/testthat/test-dgps.R

test_that("Coefs from DGP can be recovered", {
  mods <- c("weibull", "lm", "coxph", "colr", "polr")
  tcfx <- c(1, 0)

  lapply(mods, \(tmod) {
    set.seed(1)
    tmodFUN <- tramicp:::.mod_from_name(tmod)
    dgp <- function(n = 1e4, mod = tmod, ...)
      dgp_dicp(n = n, mod = mod, cfx = tcfx, ... = ...)
    d <- dgp()
    expect_true(max(abs(coef(tmodFUN(Y ~ X1 + X2, data = d))) - abs(tcfx)) < 0.05)
  })
})

Try the tramicp package in your browser

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

tramicp documentation built on April 4, 2025, 3:25 a.m.