diff options
author | Johannes Ranke <jranke@uni-bremen.de> | 2018-07-17 17:29:14 +0200 |
---|---|---|
committer | Johannes Ranke <jranke@uni-bremen.de> | 2018-07-17 17:38:29 +0200 |
commit | 280d36230052de4f94e384648c1283031fbc9840 (patch) | |
tree | df0ba9e07386b593cc396b8b6976210d42ee1a46 /tests/testthat/test_compare_investr.R | |
parent | e636c17f0d354a8e74546fc1469431dbe502dc76 (diff) |
Fix inverse predictions for replicate measurements
For details, see NEWS.md
Diffstat (limited to 'tests/testthat/test_compare_investr.R')
-rw-r--r-- | tests/testthat/test_compare_investr.R | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/testthat/test_compare_investr.R b/tests/testthat/test_compare_investr.R new file mode 100644 index 0000000..6191c89 --- /dev/null +++ b/tests/testthat/test_compare_investr.R @@ -0,0 +1,30 @@ +context("Compare with investr::calibrate") + +library(chemCal) +library(investr) + +test_that("Unweighted regressions give same results as investr::calibrate using the Wald method", { + compare_investr <- function(object, y_sample) { + pred_chemCal <- inverse.predict(object, y_sample) + pred_investr <- calibrate(object, y_sample, interval = "Wald") + expect_equivalent(pred_chemCal[["Prediction"]], + pred_investr$estimate) + expect_equivalent(pred_chemCal[["Standard Error"]], + pred_investr$se) + expect_equivalent(pred_chemCal[["Confidence Limits"]][1], + pred_investr$lower) + expect_equivalent(pred_chemCal[["Confidence Limits"]][2], + pred_investr$upper) + } + m_tol <- lm(peak_area ~ amount, data = rl95_toluene) + compare_investr(m_tol, 1000) + + m_din <- lm(y ~ x, din32645) + compare_investr(m_din, 5000) + + m_m1 <- lm(y ~ x, massart97ex1) + compare_investr(m_m1, 15) + + m_m3 <- lm(y ~ x, massart97ex3) + compare_investr(m_m3, 15) +}) |