Skip to content

Commit

Permalink
Create test_forecast.R
Browse files Browse the repository at this point in the history
  • Loading branch information
donotdespair committed Jul 15, 2024
1 parent d20cc69 commit 713025d
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions inst/tinytest/test_forecast.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@

data(oil)

# for bsvar
set.seed(1)
suppressMessages(
specification_no1 <- specify_bsvarSIGN$new(oil, p = 1)
)
run_no1 <- estimate(specification_no1, 3, 1, show_progress = FALSE)
ff <- forecast(run_no1, horizon = 2)

set.seed(1)
suppressMessages(
ff2 <- oil |>
specify_bsvarSIGN$new(p = 1) |>
estimate(S = 3, thin = 1, show_progress = FALSE) |>
forecast(horizon = 2)
)


expect_identical(
ff$forecasts[1,1,1], ff2$forecasts[1,1,1],
info = "forecast: forecast identical for normal and pipe workflow."
)

expect_true(
is.numeric(ff$forecasts) & is.array(ff$forecasts),
info = "forecast: returns numeric array."
)


expect_error(
specify_bsvar$new(us_fiscal_lsuw) |> forecast(horizon = 3),
info = "forecast: wrong input provided."
)

expect_error(
forecast(run_no1, horizon = 1.5),
info = "forecast: specify horizon as integer."
)

0 comments on commit 713025d

Please sign in to comment.