tests/testthat/test-cumu-effect-esplot.R

test_that("cumu/att.cumu/esplot run without error on fect output", {
  skip_on_cran()
  suppressWarnings(try(data("simdata", package = "fect"), silent = TRUE))
  expect_true(exists("simdata"))
  out <- fect::fect(
    Y ~ D + X1 + X2,
    data = simdata,
    index = c("id", "time"),
    method = "ife",
    r = 1,
    CV = FALSE,
    se = FALSE,
    parallel = FALSE
  )
  # cumu (att.cumu)
  # att.cumu requires uncertainty objects from keep.sims=TRUE
  out_keep <- fect::fect(
    Y ~ D + X1 + X2,
    data = simdata,
    index = c("id", "time"),
    method = "ife",
    r = 1,
    CV = FALSE,
    se = TRUE,
    nboots = 20,
    keep.sims = TRUE,
    parallel = FALSE
  )
  c <- att.cumu(out_keep, period = c(1, 3), plot = FALSE)
  expect_true(is.matrix(c) || is.data.frame(c))
  # esplot
  p <- esplot(out_keep$est.att, Estimate = "ATT")
  expect_s3_class(p, "ggplot")
})

Try the fect package in your browser

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

fect documentation built on April 30, 2026, 9:06 a.m.