Skip to content

Commit

Permalink
update ekf test with missing data
Browse files Browse the repository at this point in the history
  • Loading branch information
helske committed Sep 5, 2021
1 parent 10bf8f6 commit ba11142
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions tests/testthat/test_ekpf.R
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ test_that("EKF and IEKF work", {
log_prior_pdf = pntrs$log_prior_pdf,
n_states = 1, n_etas = 1, state_names = "state"), NA)

expect_equal(ekf(model_nlg)$logLik, 3.55814184565819)
expect_equal(ekf(model_nlg)$logLik, 2.65163101109689)
expect_equal(ekf(model_nlg, iekf_iter = 2)$logLik,
logLik(model_nlg, method = "ekf", iekf_iter = 2))
expect_equal(ekf(model_nlg, iekf_iter = 1)$logLik, 3.69550903344128)
logLik(model_nlg, method = "ekf", iekf_iter = 2, particles = 0))
expect_equal(ekf(model_nlg, iekf_iter = 1)$logLik, 2.61650080342709)
expect_equal(ekf(model_nlg, iekf_iter = 1),
ekf(model_nlg, iekf_iter = 2))

Expand All @@ -75,7 +75,7 @@ test_that("EKF and IEKF work", {
expect_equal(out_ekf1$alphahat, out_ekf2)
expect_equal(
ekf_fast_smoother(model_nlg, iekf_iter = 2),
ekf_smoother(model_nlg)$alphahat, iekf_iter = 2)
ekf_smoother(model_nlg, iekf_iter = 2)$alphahat)

expect_error(ukf(model_nlg), NA)
expect_error(bootstrap_filter(model_nlg, 10), NA)
Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test_predict.R
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ test_that("Gaussian predictions work", {
ifelse(x[1] > 1 | any(x < 0), -Inf, - sum(0.5 * x[2:3]^2))
}

expect_warning(model2 <- ssm_mlg(matrix(model$y, length(model$y), 1),
expect_error(model2 <- ssm_mlg(matrix(model$y, length(model$y), 1),
Z = 1, H = model$H, T = model$T, R = model$R,
a1 = model$a1, P1 = model$P1,
init_theta = c(rho = 0.9, sigma = 0.1, sd_y = 0.1),
update_fn = ufun, prior_fn = pfun, state_names = "signal"))
update_fn = ufun, prior_fn = pfun, state_names = "signal"), NA)

set.seed(123)
expect_error(mcmc_results2 <- run_mcmc(model2, iter = 1000),
Expand Down

0 comments on commit ba11142

Please sign in to comment.