tests/testthat/test-fitted.R

test_that("fitted method for poisson_rt works", {
  set.seed(12345)
  y <- c(1, rpois(100, dnorm(1:100, 50, 15) * 500 + 1))
  out <- estimate_rt(y, nsol = 10)
  expect_identical(out$Rt, fitted(out))
  expect_identical(out$Rt[, 1], fitted(out, out$lambda[1]))
  expect_warning(ff <- fitted(out, out$lambda[1] + .001))
  expect_identical(out$Rt[, 1], ff)

  fff <- suppressWarnings(fitted(out, c(out$lambda[1] + .001, out$lambda[1])))
  expect_identical(out$Rt[, c(1, 1)], fff)

  l <- mean(out$lambda[1:2])
  expect_equal(exp(rowMeans(log(out$Rt[, 1:2]))), fitted(out, l))
})

Try the rtestim package in your browser

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

rtestim documentation built on Aug. 8, 2025, 6:21 p.m.