aboutsummaryrefslogtreecommitdiff
path: root/tests/testthat/test_din32645.R
blob: e6d2840b64b50456aa393f67c987375b1fc0499d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
context("Known results for the dataset provided in DIN 32645")

require(chemCal)

m <- lm(y ~ x, data = din32645)
prediction <- inverse.predict(m, 3500, alpha = 0.01)

test_that("We get correct confidence intervals", {
  # Result collected from Procontrol 3.1 (isomehr GmbH)
  expect_equal(round(prediction$Confidence, 5), 0.07434)
})

test_that("We get a correct critical value", {
  crit <- lod(m, alpha = 0.01, beta = 0.5)
  # DIN 32645 gives 0.07 for the critical value
  # (decision limit, "Nachweisgrenze")
  expect_equal(round(crit$x, 2), 0.07)
  # According to Dintest test data, we should get 0.0698
  expect_equal(round(crit$x, 4), 0.0698)
})

test_that("We get a correct smalles detectable value using the DIN method", {
  lod.din <- lod(m, alpha = 0.01, beta = 0.01, method = "din")
  # DIN 32645 gives 0.14 for the smallest detectable value ("Erfassungsgrenze")
  expect_equal(round(lod.din$x, 2), 0.14)
})

test_that("We get a correct limit of quantification", {
  loq.din <- loq(m, alpha = 0.01)
  # The value cited for Procontrol 3.1 (0.2121) deviates
  # at the last digit, so we only test for three digits
  expect_equal(round(loq.din$x, 3), 0.212)
})

Contact - Imprint