Skip to content

Commit

Permalink
forecast method test closes #5
Browse files Browse the repository at this point in the history
  • Loading branch information
donotdespair committed May 12, 2024
1 parent b98ae6c commit 5a05972
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions inst/tinytest/test_forecast.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@

data(ilo_cubic_panel)

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

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


expect_identical(
ff$forecasts[1,1,1,1], ff2$forecasts[1,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_bvarPANEL$new(ilo_cubic_panel) |> 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 5a05972

Please sign in to comment.