tests/testthat/test-predict.R

testthat::test_that("predict", {
  fit <- garma(runif(120))
  testthat::expect_error(
    predict(fit, n.ahead = (-1)),
    regexp = "The parameter 'n.ahead' must be an integer g.t. 0"
  )

  testthat::expect_error(
    predict(fit, n.ahead = 5, newdata = runif(5)),
    regexp = "You have provided the 'newdata' parameter but the original 'fit' did not include an xreg"
  )

  fit <- garma(runif(120), xreg = runif(120))
  testthat::expect_error(
    predict(fit, n.ahead = 5, newdata = runif(4)),
    regexp = "The length of newdata must be 5"
  )

})

Try the garma package in your browser

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

garma documentation built on April 4, 2025, 2:13 a.m.