From f606838c5310f365eea1c0d6421f5c3636a4dc79 Mon Sep 17 00:00:00 2001 From: Johannes Ranke Date: Tue, 8 Dec 2020 22:08:38 +0100 Subject: mixed.mmkin and test coverage --- tests/testthat/test_confidence.R | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'tests/testthat/test_confidence.R') diff --git a/tests/testthat/test_confidence.R b/tests/testthat/test_confidence.R index 3fdd3f2c..54be675c 100644 --- a/tests/testthat/test_confidence.R +++ b/tests/testthat/test_confidence.R @@ -1,6 +1,19 @@ context("Confidence intervals and p-values") +test_that("Some special cases of confidence interval calculation work", { + + tmp <- expect_warning(mkinfit("FOMC", FOCUS_2006_A, quiet = TRUE), "not converge") + + expect_equivalent( + confint(tmp, transform = FALSE), + matrix(rep(NA, 8), nrow = 4)) +}) + test_that("The confint method 'quadratic' is consistent with the summary", { + expect_equivalent( + confint(fit_nw_1, parm = "parent_0", method = "quadratic"), + summary(fit_nw_1)$bpar["parent_0", c("Lower", "Upper")]) + expect_equivalent( confint(fit_nw_1, method = "quadratic"), summary(fit_nw_1)$bpar[, c("Lower", "Upper")]) @@ -74,8 +87,8 @@ test_that("Likelihood profile based confidence intervals work", { } f_mle <- stats4::mle(f_nll, start = as.list(parms(f)), nobs = nrow(FOCUS_2006_C)) - ci_mkin_1_p_0.95 <- confint(f, method = "profile", level = 0.95, - cores = n_cores, quiet = TRUE) + ci_mkin_1_p_0.95 <- expect_message(confint(f, method = "profile", level = 0.95, + cores = n_cores, quiet = FALSE), "Profiling the likelihood") # Magically, we get very similar boundaries as stats4::mle # (we need to capture the output to avoid printing this while testing as -- cgit v1.2.1