tests/testthat/test-thetaf.R

# A unit test for thetaf.R
test_that("test thetaf()", {
  thetafc <- thetaf(WWWusage)$mean
  expect_true(all(thetafc == thetaf(WWWusage, fan = TRUE)$mean))
  expect_error(thetaf(WWWusage, level = -10))
  expect_error(thetaf(WWWusage, level = 110))
  # Constant series should not error
  series <- ts(rep(950, 20), frequency = 4)
  constantForecast <- expect_no_error(thetaf(series))
  expect_true(is.constant(round(constantForecast$mean, 12)))
})

Try the forecast package in your browser

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

forecast documentation built on March 18, 2026, 9:07 a.m.