aboutsummaryrefslogtreecommitdiff
path: root/tests/testthat/test_confidence.R
blob: 0423302b02e0c899caaac99c08fa2bca20d1a51e (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
34
35
36
37
38
39
40
# Copyright (C) 2019 Johannes Ranke
# Contact: jranke@uni-bremen.de

# This file is part of the R package mkin

# mkin is free software: you can redistribute it and/or modify it under the
# terms of the GNU General Public License as published by the Free Software
# Foundation, either version 3 of the License, or (at your option) any later
# version.

# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
# details.

# You should have received a copy of the GNU General Public License along with
# this program. If not, see <http://www.gnu.org/licenses/>

context("Confidence intervals and p-values")

test_that("Confidence intervals are stable", {
  bpar_1 <- summary(f_SFO_lin_mkin_ML)$bpar[, c("Estimate", "Lower", "Upper")]
  # The reference used here is mkin 0.9.48.1
  bpar_1_mkin_0.9 <-   read.table(text =
"parent_0       102.0000 98.6000 106.0000
k_parent         0.7390  0.6770   0.8070
k_M1             0.2990  0.2560   0.3490
k_M2             0.0202  0.0176   0.0233
f_parent_to_M1   0.7690  0.6640   0.8480
f_M1_to_M2       0.7230  0.6030   0.8180",
col.names = c("parameter", "estimate", "lower", "upper"))

  expect_equivalent(signif(bpar_1[1:6, "Estimate"], 3), bpar_1_mkin_0.9$estimate)

  # Relative difference of lower bound of the confidence interval is < 0.02
  expect_equivalent(bpar_1[1:6, "Lower"], bpar_1_mkin_0.9$lower,
      scale = bpar_1_mkin_0.9$lower, tolerance = 0.02)
  expect_equivalent(f_SFO_lin_mkin_OLS$bpar, f_SFO_lin_mkin_ML$bpar)
  })

Contact - Imprint