Skip to content

Commit 8ba5c2e

Browse files
committed
add more tests
1 parent f71ae09 commit 8ba5c2e

2 files changed

Lines changed: 78 additions & 1 deletion

File tree

tests/testthat/test-jvn.R

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,76 @@ test_that("jvn_nowcast returns expected components", {
4040
"bic", "convergence", "data")
4141
)
4242
})
43+
44+
test_that("jvn_nowcast works with different solvers", {
45+
result <- jvn_nowcast(
46+
df = df_jvn, e = 2, h = 0,
47+
solver_options = list(method = "BFGS")
48+
)
49+
expect_named(
50+
result,
51+
c("states", "jvn_model_mat", "params", "fit", "loglik", "aic",
52+
"bic", "convergence", "data")
53+
)
54+
55+
result <- jvn_nowcast(
56+
df = df_jvn, e = 2, h = 0,
57+
solver_options = list(method = "nlminb")
58+
)
59+
expect_named(
60+
result,
61+
c("states", "jvn_model_mat", "params", "fit", "loglik", "aic",
62+
"bic", "convergence", "data")
63+
)
64+
65+
result <- jvn_nowcast(
66+
df = df_jvn, e = 2, h = 0,
67+
solver_options = list(method = "two-step")
68+
)
69+
expect_named(
70+
result,
71+
c("states", "jvn_model_mat", "params", "fit", "loglik", "aic",
72+
"bic", "convergence", "data")
73+
)
74+
75+
result <- jvn_nowcast(
76+
df = df_jvn, e = 2, h = 0,
77+
solver_options = list(n_starts = 2)
78+
)
79+
expect_named(
80+
result,
81+
c("states", "jvn_model_mat", "params", "fit", "loglik", "aic",
82+
"bic", "convergence", "data")
83+
)
84+
})
85+
86+
test_that("jvn_nowcast works with spillovers", {
87+
result <- jvn_nowcast(
88+
df = df_jvn, e = 2, h = 0,
89+
include_spillovers = T
90+
)
91+
expect_named(
92+
result,
93+
c("states", "jvn_model_mat", "params", "fit", "loglik", "aic",
94+
"bic", "convergence", "data")
95+
)
96+
})
97+
98+
test_that("jvn_nowcast works with trace = 1", {
99+
result <- jvn_nowcast(
100+
df = df_jvn, e = 2, h = 0,
101+
solver_options = list("trace" = 1)
102+
)
103+
expect_named(
104+
result,
105+
c("states", "jvn_model_mat", "params", "fit", "loglik", "aic",
106+
"bic", "convergence", "data")
107+
)
108+
})
109+
110+
test_that("plot returns a ggplot object", {
111+
result <- jvn_nowcast(df_jvn, e = 2, h = 0)
112+
p <- plot(result)
113+
expect_s3_class(p, "ggplot")
114+
})
115+

tests/testthat/test-kk.R

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,11 @@ test_that("kk_nowcast handles irregular time series for forecasting", {
152152
)
153153
})
154154

155-
155+
test_that("plot returns a ggplot object", {
156+
result <- kk_nowcast(df_kk, e = 1, h = 0, model = "Kishor-Koenig")
157+
p <- plot(result)
158+
expect_s3_class(p, "ggplot")
159+
})
156160

157161

158162

0 commit comments

Comments
 (0)