Skip to content

Commit

Permalink
add test for gdp prior
Browse files Browse the repository at this point in the history
  • Loading branch information
ygeunkim committed Nov 26, 2024
1 parent b6cf470 commit f5537fe
Show file tree
Hide file tree
Showing 3 changed files with 136 additions and 0 deletions.
78 changes: 78 additions & 0 deletions tests/testthat/test-summary-forecast.R
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,19 @@ test_that("Rolling windows - VHAR-DL-LDLT", {
expect_s3_class(test_roll_sparse, "bvharcv")
})

test_that("Rolling windows - VHAR-GDP-LDLT", {
skip_on_cran()

test_roll_dense <- help_vhar_bayes_roll(set_gdp(), set_ldlt(), FALSE)
test_roll_sparse <- help_vhar_bayes_roll(set_gdp(), set_ldlt(), TRUE)

expect_s3_class(test_roll_dense, "predbvhar_roll")
expect_s3_class(test_roll_dense, "bvharcv")

expect_s3_class(test_roll_sparse, "predbvhar_roll")
expect_s3_class(test_roll_sparse, "bvharcv")
})

test_that("Rolling windows - VAR-Minn-SV", {
skip_on_cran()

Expand Down Expand Up @@ -349,6 +362,19 @@ test_that("Rolling windows - VAR-DL-SV", {
expect_s3_class(test_roll_sparse, "bvharcv")
})

test_that("Rolling windows - VAR-GDP-SV", {
skip_on_cran()

test_roll_dense <- help_var_bayes_roll(set_gdp(), set_sv(), FALSE)
test_roll_sparse <- help_var_bayes_roll(set_gdp(), set_sv(), TRUE)

expect_s3_class(test_roll_dense, "predbvhar_roll")
expect_s3_class(test_roll_dense, "bvharcv")

expect_s3_class(test_roll_sparse, "predbvhar_roll")
expect_s3_class(test_roll_sparse, "bvharcv")
})

test_that("Rolling windows - VHAR-Minn-SV", {
skip_on_cran()

Expand Down Expand Up @@ -427,6 +453,19 @@ test_that("Rolling windows - VHAR-DL-SV", {
expect_s3_class(test_roll_sparse, "bvharcv")
})

test_that("Rolling windows - VHAR-GDP-SV", {
skip_on_cran()

test_roll_dense <- help_vhar_bayes_roll(set_gdp(), set_sv(), FALSE)
test_roll_sparse <- help_vhar_bayes_roll(set_gdp(), set_sv(), TRUE)

expect_s3_class(test_roll_dense, "predbvhar_roll")
expect_s3_class(test_roll_dense, "bvharcv")

expect_s3_class(test_roll_sparse, "predbvhar_roll")
expect_s3_class(test_roll_sparse, "bvharcv")
})

test_that("Expanding windows - VAR-Minn-LDLT", {
skip_on_cran()

Expand Down Expand Up @@ -505,6 +544,19 @@ test_that("Expanding windows - VAR-DL-LDLT", {
expect_s3_class(test_expand_sparse, "bvharcv")
})

test_that("Expanding windows - VAR-GDP-LDLT", {
skip_on_cran()

test_expand_dense <- help_var_bayes_expand(set_gdp(), set_ldlt(), FALSE)
test_expand_sparse <- help_var_bayes_expand(set_gdp(), set_ldlt(), TRUE)

expect_s3_class(test_expand_dense, "predbvhar_expand")
expect_s3_class(test_expand_dense, "bvharcv")

expect_s3_class(test_expand_sparse, "predbvhar_expand")
expect_s3_class(test_expand_sparse, "bvharcv")
})

test_that("Expanding windows - VHAR-Minn-LDLT", {
skip_on_cran()

Expand Down Expand Up @@ -583,6 +635,19 @@ test_that("Expanding windows - VHAR-DL-LDLT", {
expect_s3_class(test_expand_sparse, "bvharcv")
})

test_that("Expanding windows - VHAR-GDP-LDLT", {
skip_on_cran()

test_expand_dense <- help_vhar_bayes_expand(set_gdp(), set_ldlt(), FALSE)
test_expand_sparse <- help_vhar_bayes_expand(set_gdp(), set_ldlt(), TRUE)

expect_s3_class(test_expand_dense, "predbvhar_expand")
expect_s3_class(test_expand_dense, "bvharcv")

expect_s3_class(test_expand_sparse, "predbvhar_expand")
expect_s3_class(test_expand_sparse, "bvharcv")
})

test_that("Expanding windows - VAR-Minn-SV", {
skip_on_cran()

Expand Down Expand Up @@ -738,4 +803,17 @@ test_that("Expanding windows - VHAR-DL-SV", {
expect_s3_class(test_expand_sparse, "predbvhar_expand")
expect_s3_class(test_expand_sparse, "bvharcv")
})

test_that("Expanding windows - VHAR-GDP-SV", {
skip_on_cran()

test_expand_dense <- help_vhar_bayes_expand(set_gdp(), set_sv(), FALSE)
test_expand_sparse <- help_vhar_bayes_expand(set_gdp(), set_sv(), TRUE)

expect_s3_class(test_expand_dense, "predbvhar_expand")
expect_s3_class(test_expand_dense, "bvharcv")

expect_s3_class(test_expand_sparse, "predbvhar_expand")
expect_s3_class(test_expand_sparse, "bvharcv")
})
#> Test passed 🌈
30 changes: 30 additions & 0 deletions tests/testthat/test-var-bayes.R
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,21 @@ test_that("VAR-DL-LDLT", {
expect_true(all(c("lambda", "tau") %in% fit_test$param_names))
})

test_that("VAR-GDP-LDLT", {
set.seed(1)
fit_test <- var_bayes(
etf_vix[1:50, 1:2],
p = 1,
num_iter = 5,
num_burn = 0,
bayes_spec = set_gdp(),
cov_spec = set_ldlt(),
include_mean = FALSE
)
expect_s3_class(fit_test, "gdpmod")
# expect_true(all(c("lambda", "tau") %in% fit_test$param_names))
})

test_that("VAR-Minn-SV", {
set.seed(1)
fit_test <- var_bayes(
Expand Down Expand Up @@ -175,6 +190,21 @@ test_that("VAR-DL-SV", {
expect_true(all(c("lambda", "tau") %in% fit_test$param_names))
})

test_that("VAR-DL-SV", {
set.seed(1)
fit_test <- var_bayes(
etf_vix[1:50, 1:2],
p = 1,
num_iter = 5,
num_burn = 0,
bayes_spec = set_gdp(),
cov_spec = set_sv(),
include_mean = FALSE
)
expect_s3_class(fit_test, "gdpmod")
# expect_true(all(c("lambda", "tau") %in% fit_test$param_names))
})

test_that("Multi chain", {
set.seed(1)
iter_test <- 5
Expand Down
28 changes: 28 additions & 0 deletions tests/testthat/test-vhar-bayes.R
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,20 @@ test_that("VHAR-DL-LDLT", {
expect_true(all(c("lambda", "tau") %in% fit_test$param_names))
})

test_that("VHAR-GDP-LDLT", {
set.seed(1)
fit_test <- vhar_bayes(
etf_vix[1:50, 1:2],
num_iter = 5,
num_burn = 0,
bayes_spec = set_gdp(),
cov_spec = set_ldlt(),
include_mean = FALSE
)
expect_s3_class(fit_test, "gdpmod")
# expect_true(all(c("lambda", "tau") %in% fit_test$param_names))
})

test_that("Members - VHAR-Minn-SV", {
set.seed(1)
fit_test <- vhar_bayes(
Expand Down Expand Up @@ -163,6 +177,20 @@ test_that("Members - VHAR-DL-SV", {
expect_true(all(c("lambda", "tau") %in% fit_test$param_names))
})

test_that("Members - VHAR-GDP-SV", {
set.seed(1)
fit_test <- vhar_bayes(
etf_vix[1:50, 1:2],
num_iter = 5,
num_burn = 0,
bayes_spec = set_gdp(),
cov_spec = set_sv(),
include_mean = FALSE
)
expect_s3_class(fit_test, "gdpmod")
# expect_true(all(c("lambda", "tau") %in% fit_test$param_names))
})

test_that("Multi chain", {
set.seed(1)
iter_test <- 5
Expand Down

0 comments on commit f5537fe

Please sign in to comment.