This is a document work. I use this to follow the pdf document original of this package.
Downloads:
Reference manual: | bdpv.pdf |
Package source: | bdpv_1.1.tar.gz |
Windows binaries: | r-devel: bdpv_1.1.zip, r-release: bdpv_1.1.zip, r-oldrel: bdpv_1.1.zip |
OS X El Capitan binaries: | r-release: bdpv_1.1.tgz |
OS X Mavericks binaries: | r-oldrel: bdpv_1.1.tgz |
Old sources: | bdpv archive |
bdpv-package
Confidence intervals and experimental design for negative and positive predictive values in binary diagnostic tests. Computing asymptotic confidence intervals for negative and positive predictive values of binary diagnostic test assuming a case-control design. Experimental design based on asymptotic formulas and Monte Carlo simulation for hypothesis tests on predictive values, including some plot functions to explore various experimental designs.# 1) Example data: Mercaldo et al.(2007), Table VIII:
Tab8<- span="">matrix(c(240, 178, 87, 288), ncol=2)
colnames(Tab8)<- span="">c("Case","Control")
rownames(Tab8)<- span="">c("ApoEe4plus","ApoEe4minus")
Tab8->->->
## Case Control
## ApoEe4plus 240 87
## ApoEe4minus 178 288
# Assuming prevalence=0.03
BDtest(xmat=Tab8, pr=0.03, conf.level = 0.95)
## Confidence intervals for binary diagnostic tests.
## Input data set with columns representing the true property of the compounds and rows representing the result of a binary diagnostic test.
## True positive True negative
## Test positive 240 87
## Test negative 178 288
## Estimates and exact confidence limits for assay sensitivity and specificity.
## Estimate Lower 95% limit Lower 97.5% limit Upper 97.5% limit
## Sensitivity 0.5741627 0.5328859 0.5251792 0.6220889
## Specificity 0.7680000 0.7292953 0.7219182 0.8097934
## Estimates and asymptotic confidence limits for predictive values. The prevalence is assumed to be 0.03.
## Estimate Lower 95% limit Lower 97.5% limit Upper 97.5% limit
## NPV 0.98314039 0.98131911 0.98094879 0.98508370
## PPV 0.07109937 0.06069456 0.05887097 0.08563667
# Assuming prevalence=0.5
BDtest(xmat=Tab8, pr=0.5, conf.level = 0.95)
## Confidence intervals for binary diagnostic tests.
## Input data set with columns representing the true property of the compounds and rows representing the result of a binary diagnostic test.
## True positive True negative
## Test positive 240 87
## Test negative 178 288
## Estimates and exact confidence limits for assay sensitivity and specificity.
## Estimate Lower 95% limit Lower 97.5% limit Upper 97.5% limit
## Sensitivity 0.5741627 0.5328859 0.5251792 0.6220889
## Specificity 0.7680000 0.7292953 0.7219182 0.8097934
## Estimates and asymptotic confidence limits for predictive values. The prevalence is assumed to be 0.5.
## Estimate Lower 95% limit Lower 97.5% limit Upper 97.5% limit
## NPV 0.6433037 0.6189981 0.6142686 0.6713227
## PPV 0.7122169 0.6762984 0.6691552 0.7517531
# 2) Experimental design acc. to Steinberg et al.(2009)
TEST<- span="">nPV(se=c(0.76, 0.78, 0.80, 0.82, 0.84),
sp=c(0.93, 0.94, 0.95, 0.96, 0.97),
pr=0.0625, NPV0=0.98, PPV0=0.25, NPVpower = 0.8, PPVpower = 0.8,
rangeP = c(0.10, 0.9), nsteps = 20, alpha = 0.05)->
## Warning in nPPV(propP = Pseq, se = ARGLIST$se[i], sp = ARGLIST$sp[i], prev
## = ARGLIST$prev[i], : Some sample sizes n (185) might be too small to expect
## validity of asymptotic formulas for anticipated sensitivity (se), and the
## corresponding proportion of positives (propP).
## Warning in nPPV(propP = Pseq, se = ARGLIST$se[i], sp = ARGLIST$sp[i], prev
## = ARGLIST$prev[i], : Some sample sizes n (137, 138) might be too small to
## expect validity of asymptotic formulas for anticipated sensitivity (se),
## and the corresponding proportion of positives (propP).
## Warning in nNPV(propP = Pseq, se = ARGLIST$se[i], sp = ARGLIST$sp[i], prev
## = ARGLIST$prev[i], : Some sample sizes n (403, 393, 393) might be too small
## to expect validity of asymptotic formulas for anticipated specificity (sp),
## and the corresponding proportion of negatives (1-propP).
## Warning in nPPV(propP = Pseq, se = ARGLIST$se[i], sp = ARGLIST$sp[i], prev
## = ARGLIST$prev[i], : Some sample sizes n (108, 110, 113) might be too small
## to expect validity of asymptotic formulas for anticipated sensitivity (se),
## and the corresponding proportion of positives (propP).
## Warning in nPPV(propP = Pseq, se = ARGLIST$se[i], sp = ARGLIST$sp[i], prev
## = ARGLIST$prev[i], : Some sample sizes n (108, 110, ..., 870) might be too
## small to expect validity of asymptotic formulas for anticipated specificity
## (sp), and the corresponding proportion of negatives (1-propP).
## Warning in nNPV(propP = Pseq, se = ARGLIST$se[i], sp = ARGLIST$sp[i], prev
## = ARGLIST$prev[i], : Some sample sizes n (280, 264, ..., 220) might be too
## small to expect validity of asymptotic formulas for anticipated specificity
## (sp), and the corresponding proportion of negatives (1-propP).
## Warning in nPPV(propP = Pseq, se = ARGLIST$se[i], sp = ARGLIST$sp[i], prev
## = ARGLIST$prev[i], : Some sample sizes n (90, 92, 96, 100) might be too
## small to expect validity of asymptotic formulas for anticipated sensitivity
## (se), and the corresponding proportion of positives (propP).
## Warning in nPPV(propP = Pseq, se = ARGLIST$se[i], sp = ARGLIST$sp[i], prev
## = ARGLIST$prev[i], : Some sample sizes n (90, 92, ..., 747) might be too
## small to expect validity of asymptotic formulas for anticipated specificity
## (sp), and the corresponding proportion of negatives (1-propP).
## Warning in nNPV(propP = Pseq, se = ARGLIST$se[i], sp = ARGLIST$sp[i], prev
## = ARGLIST$prev[i], : Some sample sizes n (228, 211, ..., 141) might be too
## small to expect validity of asymptotic formulas for anticipated specificity
## (sp), and the corresponding proportion of negatives (1-propP).
## Warning in nPPV(propP = Pseq, se = ARGLIST$se[i], sp = ARGLIST$sp[i], prev
## = ARGLIST$prev[i], : Some sample sizes n (79, 82, ..., 99) might be too
## small to expect validity of asymptotic formulas for anticipated sensitivity
## (se), and the corresponding proportion of positives (propP).
## Warning in nPPV(propP = Pseq, se = ARGLIST$se[i], sp = ARGLIST$sp[i], prev
## = ARGLIST$prev[i], : Some sample sizes n (79, 82, ..., 674) might be too
## small to expect validity of asymptotic formulas for anticipated specificity
## (sp), and the corresponding proportion of negatives (1-propP).
## Warning in nNPV(propP = Pseq, se = ARGLIST$se[i], sp = ARGLIST$sp[i], prev
## = ARGLIST$prev[i], : Some sample sizes n (242, 216, ..., 100) might be too
## small to expect validity of asymptotic formulas for anticipated specificity
## (sp), and the corresponding proportion of negatives (1-propP).
TEST
## Asymptotic experimental design for predictive values:
## 5 setting(s) generated from given input parameters:
## Sensitivity (se), specifity (sp), prevalence (prev),
## thresholds of negative and positive predictive values (NPV0, PPV0),
## intended power for rejecting H0: NPV<=NPV0; H0: PPV<=PPV0 (power),
## true values of NPV and PPV resulting from given sp, se, prev.
## se sp prev NPV0 PPV0 NPVpower PPVpower trueNPV truePPV
## Setting 1 0.76 0.93 0.0625 0.98 0.25 0.8 0.8 0.9830867 0.4198895
## Setting 2 0.78 0.94 0.0625 0.98 0.25 0.8 0.8 0.9846369 0.4642857
## Setting 3 0.80 0.95 0.0625 0.98 0.25 0.8 0.8 0.9861592 0.5161290
## Setting 4 0.82 0.96 0.0625 0.98 0.25 0.8 0.8 0.9876543 0.5774648
## Setting 5 0.84 0.97 0.0625 0.98 0.25 0.8 0.8 0.9891230 0.6511628
## Proportion of true positives (propP) and sample sizes (n.) for the
## 5 sets for NPV and PPV:
## propP n.NPV.Setting.1 n.NPV.Setting.2 n.NPV.Setting.3
## 1 0.1000000 6731 3048 1768
## 2 0.1421053 4743 2147 1245
## 3 0.1842105 3664 1658 961
## 4 0.2263158 2987 1351 783
## 5 0.2684211 2523 1141 661
## 6 0.3105263 2185 988 572
## 7 0.3526316 1929 871 504
## 8 0.3947368 1727 780 451
## 9 0.4368421 1566 706 409
## 10 0.4789474 1433 646 373
## 11 0.5210526 1322 596 344
## 12 0.5631579 1229 553 319
## 13 0.6052632 1150 517 298
## 14 0.6473684 1083 486 280
## 15 0.6894737 1026 459 264
## 16 0.7315789 978 437 250
## 17 0.7736842 939 418 239
## 18 0.8157895 910 403 229
## 19 0.8578947 895 393 223
## 20 0.9000000 906 393 220
## n.NPV.Setting.4 n.NPV.Setting.5 n.PPV.Setting.1 n.PPV.Setting.2
## 1 1174 850 185 137
## 2 827 598 183 138
## 3 638 462 186 141
## 4 520 376 191 146
## 5 439 317 199 153
## 6 379 275 209 161
## 7 335 242 221 170
## 8 299 216 234 181
## 9 271 196 251 193
## 10 247 179 269 208
## 11 228 164 292 226
## 12 211 152 319 247
## 13 197 142 352 272
## 14 185 133 393 304
## 15 174 125 445 345
## 16 165 118 514 398
## 17 157 112 608 472
## 18 150 107 746 579
## 19 145 103 966 749
## 20 141 100 1370 1064
## n.PPV.Setting.3 n.PPV.Setting.4 n.PPV.Setting.5
## 1 108 90 79
## 2 110 92 82
## 3 113 96 85
## 4 118 100 89
## 5 123 105 94
## 6 130 111 99
## 7 138 118 106
## 8 147 125 113
## 9 157 134 121
## 10 170 145 131
## 11 184 157 142
## 12 201 172 155
## 13 222 190 172
## 14 248 213 192
## 15 282 242 218
## 16 326 279 252
## 17 386 331 299
## 18 473 406 367
## 19 613 526 475
## 20 870 747 674
plotnPV(TEST, log="y", legpar=list(x=0.6))
# 3) Simulation of power and coverage probability
simPVmat(se=0.8, sp=0.95, pr=0.0625, n1=c(177, 181),
n0=c(554, 87), NPV0=0.98, PPV0=c(0.4, 0.25))
## $INDAT
## se sp pr NPV0 PPV0 n1 n0 n
## Setting 1 0.8 0.95 0.0625 0.98 0.40 177 554 731
## Setting 2 0.8 0.95 0.0625 0.98 0.25 181 87 268
##
## $NPV
## pow cov q10 q20 q50 tr H0
## Setting 1 0.848 0.968 0.9794789 0.9804584 0.9823678 0.9861592 0.98
## Setting 2 0.856 0.960 0.9795472 0.9805747 0.9824941 0.9861592 0.98
##
## $PPV
## pow cov q10 q20 q50 tr H0
## Setting 1 0.842 0.97 0.3910851 0.4064937 0.4354261 0.516129 0.40
## Setting 2 0.962 1.00 0.2683916 0.2888690 0.3385292 0.516129 0.25
##
## $NSIM
## [1] 500
##
## $conf.level
## [1] 0.95
as.data.frame.nPV: Coerce results of “nPV” to a data.frame.
Coerce the possibly long sample size tables resulting from calling “nPV” to a data.frame.
BDtest: Computing confidence intervals for sensitivity, specificity and predictive values assuming a case-control study
This function computes confidence intervals for negative and positive predictive values. Confidence intervals for sensitivity, specificity are computed for completeness. All methods assume that data are obtained by binomial sampling, with the number of true positives and true negatives in the study fixed by design. The methods to compute negative and positive predictive values (NPV, PPV) assume that prevalence is a known quantity, based on external knowledge.
# Reproduce the standard logit interval results in
# Table IX, Mercaldo et al.(2007)
# 1) Example data: Mercaldo et al.(2007), Table VIII:
Tab8<- span="">matrix(c(240, 178, 87, 288), ncol=2)
colnames(Tab8)<- span="">c("Case","Control")
rownames(Tab8)<- span="">c("ApoEe4plus","ApoEe4minus")
Tab8->->->
## Case Control
## ApoEe4plus 240 87
## ApoEe4minus 178 288
# Assuming prevalence=0.03
BDtest(xmat=Tab8, pr=0.03, conf.level = 0.95)
## Confidence intervals for binary diagnostic tests.
## Input data set with columns representing the true property of the compounds and rows representing the result of a binary diagnostic test.
## True positive True negative
## Test positive 240 87
## Test negative 178 288
## Estimates and exact confidence limits for assay sensitivity and specificity.
## Estimate Lower 95% limit Lower 97.5% limit Upper 97.5% limit
## Sensitivity 0.5741627 0.5328859 0.5251792 0.6220889
## Specificity 0.7680000 0.7292953 0.7219182 0.8097934
## Estimates and asymptotic confidence limits for predictive values. The prevalence is assumed to be 0.03.
## Estimate Lower 95% limit Lower 97.5% limit Upper 97.5% limit
## NPV 0.98314039 0.98131911 0.98094879 0.98508370
## PPV 0.07109937 0.06069456 0.05887097 0.08563667
# Assuming prevalence=0.5
BDtest(xmat=Tab8, pr=0.5, conf.level = 0.95)
## Confidence intervals for binary diagnostic tests.
## Input data set with columns representing the true property of the compounds and rows representing the result of a binary diagnostic test.
## True positive True negative
## Test positive 240 87
## Test negative 178 288
## Estimates and exact confidence limits for assay sensitivity and specificity.
## Estimate Lower 95% limit Lower 97.5% limit Upper 97.5% limit
## Sensitivity 0.5741627 0.5328859 0.5251792 0.6220889
## Specificity 0.7680000 0.7292953 0.7219182 0.8097934
## Estimates and asymptotic confidence limits for predictive values. The prevalence is assumed to be 0.5.
## Estimate Lower 95% limit Lower 97.5% limit Upper 97.5% limit
## NPV 0.6433037 0.6189981 0.6142686 0.6713227
## PPV 0.7122169 0.6762984 0.6691552 0.7517531
CInpvppv: Asymptotic confidence intervals for negative and positive predictive values.
Computes asymptotic confidence intervals for negative and positive predictive values under the assumption of binomial sampling and known prevalence, according to Mercaldo et al. (2007). The standard logit intervals and and adjusted version are available, where the standard logit intervals are recommended.
CIlnpv(x0=c(87,288), x1=c(240,178), p=0.03,
conf.level = 0.95, alternative = "two.sided")
## $conf.int
## lower upper
## 0.9809488 0.9850837
##
## $estimate
## [1] 0.9831404
CIlppv(x0=c(87,288), x1=c(240,178), p=0.03,
conf.level = 0.95, alternative = "two.sided")
## $conf.int
## lower upper
## 0.05887097 0.08563667
##
## $estimate
## [1] 0.07109937
CIlnpvak(x0=c(87,288), x1=c(240,178), p=0.03,
conf.level = 0.95, alternative = "two.sided")
## $conf.int
## lower upper
## 0.9808626 0.9850003
##
## $estimate
## [1] 0.9830552
CIlppvak(x0=c(87,288), x1=c(240,178), p=0.03,
conf.level = 0.95, alternative = "two.sided")
## $conf.int
## lower upper
## 0.05828659 0.08446570
##
## $estimate
## [1] 0.07025717
CIpvBayes: Confidence intervals for negative and positive predictive values in a case-control setting by simulation from the posterior distribution.
Computes confidence intervals for negative and positive predictive values by simulation from the posterior beta-distribution (Stamey and Holt, 2010), assuming a case-control design to estimate sensitivity and specificity, while prevalence estimates of an external study and/or prior knowledge concerning prevalence may be introduced additionally.
# example data: Stamey and Holt, Table 8 (page 108)
# Diseased
# Test D=1 D=0
# T=1 240 87
# T=0 178 288
#n1,n0: 418 375
# reproduce the results for the Bayes I method
# in Stamey and Holt (2010), Table 9, page 108
# assuming known prevalence 0.03
# ppv 0.0591, 0.0860
# npv 0.9810, 0.9850
CIpvBI( x1=c(240,178), x0=c(87,288), pr=0.03)
## $conf.int
## lower upper
## NPV 0.98089278 0.98509790
## PPV 0.05864672 0.08556177
##
## $estimate
## NPV PPV
## 0.98309588 0.07065651
##
## $postmed
## NPV PPV
## 0.98310564 0.07068499
##
## $tab
## True positive True negative
## Test positive 240 87
## Test negative 178 288
## Total 418 375
##
## $prior
## pr.sens pr.1-spec
## a:shape1 1 1
## b:shape2 1 1
# assuming known prevalence 0.04
# ppv 0.0779, 0.1111
# npv 0.9745, 0.9800
CIpvBI( x1=c(240,178), x0=c(87,288), pr=0.04)
## $conf.int
## lower upper
## NPV 0.97459900 0.9799923
## PPV 0.07844254 0.1122433
##
## $estimate
## NPV PPV
## 0.9773593 0.0929106
##
## $postmed
## NPV PPV
## 0.97735441 0.09321523
##
## $tab
## True positive True negative
## Test positive 240 87
## Test negative 178 288
## Total 418 375
##
## $prior
## pr.sens pr.1-spec
## a:shape1 1 1
## b:shape2 1 1
# compare with standard logit intervals
tab <- span=""> cbind( x1=c(240,178), x0=c(87,288))
tab->
## x1 x0
## [1,] 240 87
## [2,] 178 288
BDtest(tab, pr=0.03)
## Confidence intervals for binary diagnostic tests.
## Input data set with columns representing the true property of the compounds and rows representing the result of a binary diagnostic test.
## True positive True negative
## Test positive 240 87
## Test negative 178 288
## Estimates and exact confidence limits for assay sensitivity and specificity.
## Estimate Lower 95% limit Lower 97.5% limit Upper 97.5% limit
## Sensitivity 0.5741627 0.5328859 0.5251792 0.6220889
## Specificity 0.7680000 0.7292953 0.7219182 0.8097934
## Estimates and asymptotic confidence limits for predictive values. The prevalence is assumed to be 0.03.
## Estimate Lower 95% limit Lower 97.5% limit Upper 97.5% limit
## NPV 0.98314039 0.98131911 0.98094879 0.98508370
## PPV 0.07109937 0.06069456 0.05887097 0.08563667
BDtest(tab, pr=0.04)
## Confidence intervals for binary diagnostic tests.
## Input data set with columns representing the true property of the compounds and rows representing the result of a binary diagnostic test.
## True positive True negative
## Test positive 240 87
## Test negative 178 288
## Estimates and exact confidence limits for assay sensitivity and specificity.
## Estimate Lower 95% limit Lower 97.5% limit Upper 97.5% limit
## Sensitivity 0.5741627 0.5328859 0.5251792 0.6220889
## Specificity 0.7680000 0.7292953 0.7219182 0.8097934
## Estimates and asymptotic confidence limits for predictive values. The prevalence is assumed to be 0.04.
## Estimate Lower 95% limit Lower 97.5% limit Upper 97.5% limit
## NPV 0.97741855 0.97499488 0.97450245 0.9800080
## PPV 0.09347891 0.08008139 0.07772351 0.1120401
# reproduce the results for the Bayes II method
# in Stamey and Holt (2010), Table 9, page 108
CIpvBII( x1=c(240,178), x0=c(87,288), shapespr=c(16,486))
## $conf.int
## lower upper
## NPV 0.97212403 0.9898445
## PPV 0.04253945 0.1174023
##
## $estimate
## NPV PPV
## 0.98202563 0.07487081
##
## $postmed
## NPV PPV
## 0.98242657 0.07381749
##
## $tab
## True positive True negative
## Test positive 240 87
## Test negative 178 288
## Total 418 375
##
## $prior
## pr.sens pr.1-spec
## a:shape1 1 1
## b:shape2 1 1
##
## $prev.study
## obs.pos obs.neg
## 0 0
##
## $prev.prior
## a:shape1 b:shape2
## 16 486
CIpvBII( x1=c(240,178), x0=c(87,288), shapespr=c(21,481))
## $conf.int
## lower upper
## NPV 0.96460212 0.9855704
## PPV 0.05962714 0.1442427
##
## $estimate
## NPV PPV
## 0.97630232 0.09692271
##
## $postmed
## NPV PPV
## 0.97664717 0.09603418
##
## $tab
## True positive True negative
## Test positive 240 87
## Test negative 178 288
## Total 418 375
##
## $prior
## pr.sens pr.1-spec
## a:shape1 1 1
## b:shape2 1 1
##
## $prev.study
## obs.pos obs.neg
## 0 0
##
## $prev.prior
## a:shape1 b:shape2
## 21 481
nNPVPPV: Asymptotic experimental design for inference on negative and positive predictive values in case-control studies.
For internal use. Functions to compute sample size (to reach a pre-specified power) and optimal allocation of true positives and true negatives in case-control designs for binary diagnostic tests (Mercaldo et al. 2007)
nPPV(propP=c(0.2,0.4,0.6,0.8), se=0.9, sp=0.9,
prev=0.1, PPV0=0.4, conf.level=0.95, power=0.8)
## $n
## [1] 444 575 854 1698
##
## $se
## [1] 0.9
##
## $sp
## [1] 0.9
##
## $prev
## [1] 0.1
##
## $PPV0
## [1] 0.4
##
## $TRUEPPV
## [1] 0.5
##
## $propP
## [1] 0.2 0.4 0.6 0.8
##
## $power
## [1] 0.8
##
## $conf.level
## [1] 0.95
nNPV(propP=c(0.2,0.4,0.6,0.8), se=0.9, sp=0.9,
prev=0.1, NPV0=0.95, conf.level=0.95, power=0.8)
## Warning in nNPV(propP = c(0.2, 0.4, 0.6, 0.8), se = 0.9, sp = 0.9, prev =
## 0.1, : Some sample sizes n (133, 67, 45, 35) might be too small to expect
## validity of asymptotic formulas for anticipated sensitivity (se), and the
## corresponding proportion of positives (propP).
## Warning in nNPV(propP = c(0.2, 0.4, 0.6, 0.8), se = 0.9, sp = 0.9, prev
## = 0.1, : Some sample sizes n (67, 45, 35) might be too small to expect
## validity of asymptotic formulas for anticipated specificity (sp), and the
## corresponding proportion of negatives (1-propP).
## $n
## [1] 133 67 45 35
##
## $se
## [1] 0.9
##
## $sp
## [1] 0.9
##
## $prev
## [1] 0.1
##
## $NPV0
## [1] 0.95
##
## $TRUENPV
## [1] 0.9878049
##
## $propP
## [1] 0.2 0.4 0.6 0.8
##
## $power
## [1] 0.8
##
## $conf.level
## [1] 0.95
AOppvnpv(se=0.9, sp=0.9)
## Pppv Pnpv
## 0.1 0.9
nPV: Asymptotic sample size calculation for inference on negative and positive predictive values in case-control designs.
Functions to compute sample size (to reach a pre-specified power) and optimal allocation of true positives and true negatives in case-control designs (Steinberg et al., 2008) for binary diagnostic tests (Mercaldo et al. 2007).
#Reproducing illustration in Section 3.4 and 4.2 of
#Steinberg et al. (2009)
FIG1<- span="">nPV(se=0.8, sp=0.95, prev=1/16, NPV0=0.98, PPV0=0.4,
NPVpower = 0.8, PPVpower = 0.8,
rangeP = c(0.01, 0.99), nsteps = 100, alpha = 0.05)->
## Warning in nPPV(propP = Pseq, se = ARGLIST$se[i], sp = ARGLIST$sp[i], prev
## = ARGLIST$prev[i], : Some sample sizes n (1237, 895, 783) might be too
## small to expect validity of asymptotic formulas for anticipated sensitivity
## (se), and the corresponding proportion of positives (propP).
## Warning in nNPV(propP = Pseq, se = ARGLIST$se[i], sp = ARGLIST$sp[i], prev
## = ARGLIST$prev[i], : Some sample sizes n (277, 273, ..., 411) might be too
## small to expect validity of asymptotic formulas for anticipated specificity
## (sp), and the corresponding proportion of negatives (1-propP).
FIG1
## Asymptotic experimental design for predictive values:
## 1 setting(s) generated from given input parameters:
## Sensitivity (se), specifity (sp), prevalence (prev),
## thresholds of negative and positive predictive values (NPV0, PPV0),
## intended power for rejecting H0: NPV<=NPV0; H0: PPV<=PPV0 (power),
## true values of NPV and PPV resulting from given sp, se, prev.
## se sp prev NPV0 PPV0 NPVpower PPVpower trueNPV truePPV
## Setting 1 0.8 0.95 0.0625 0.98 0.4 0.8 0.8 0.9861592 0.516129
## Proportion of true positives (propP) and sample sizes (n.) for the
## 1 sets for NPV and PPV:
## propP n.NPV.Setting.1 n.PPV.Setting.1
## 1 0.01000000 17648 1237
## 2 0.01989899 8870 895
## 3 0.02979798 5924 783
## 4 0.03969697 4448 731
## 5 0.04959596 3561 701
## 6 0.05949495 2969 684
## 7 0.06939394 2546 673
## 8 0.07929293 2228 666
## 9 0.08919192 1981 663
## 10 0.09909091 1784 661
## 11 0.10898990 1622 662
## 12 0.11888889 1487 663
## 13 0.12878788 1373 665
## 14 0.13868687 1275 668
## 15 0.14858586 1191 672
## 16 0.15848485 1117 677
## 17 0.16838384 1051 681
## 18 0.17828283 993 687
## 19 0.18818182 941 693
## 20 0.19808081 894 699
## 21 0.20797980 852 706
## 22 0.21787879 813 713
## 23 0.22777778 778 720
## 24 0.23767677 746 727
## 25 0.24757576 716 735
## 26 0.25747475 689 744
## 27 0.26737374 664 753
## 28 0.27727273 640 762
## 29 0.28717172 618 771
## 30 0.29707071 598 781
## 31 0.30696970 579 791
## 32 0.31686869 561 801
## 33 0.32676768 544 812
## 34 0.33666667 528 823
## 35 0.34656566 513 834
## 36 0.35646465 499 846
## 37 0.36636364 486 859
## 38 0.37626263 473 872
## 39 0.38616162 461 885
## 40 0.39606061 450 899
## 41 0.40595960 439 913
## 42 0.41585859 429 928
## 43 0.42575758 419 943
## 44 0.43565657 410 959
## 45 0.44555556 401 975
## 46 0.45545455 392 992
## 47 0.46535354 384 1010
## 48 0.47525253 376 1029
## 49 0.48515152 369 1048
## 50 0.49505051 362 1068
## 51 0.50494949 355 1089
## 52 0.51484848 348 1110
## 53 0.52474747 342 1133
## 54 0.53464646 336 1156
## 55 0.54454545 330 1181
## 56 0.55444444 324 1207
## 57 0.56434343 318 1234
## 58 0.57424242 313 1262
## 59 0.58414141 308 1291
## 60 0.59404040 303 1322
## 61 0.60393939 299 1355
## 62 0.61383838 294 1389
## 63 0.62373737 290 1425
## 64 0.63363636 285 1463
## 65 0.64353535 281 1503
## 66 0.65343434 277 1546
## 67 0.66333333 273 1591
## 68 0.67323232 270 1638
## 69 0.68313131 266 1689
## 70 0.69303030 263 1743
## 71 0.70292929 259 1800
## 72 0.71282828 256 1862
## 73 0.72272727 253 1928
## 74 0.73262626 250 1999
## 75 0.74252525 247 2075
## 76 0.75242424 244 2158
## 77 0.76232323 242 2247
## 78 0.77222222 239 2344
## 79 0.78212121 237 2450
## 80 0.79202020 234 2566
## 81 0.80191919 232 2694
## 82 0.81181818 230 2835
## 83 0.82171717 228 2992
## 84 0.83161616 226 3167
## 85 0.84151515 225 3364
## 86 0.85141414 223 3588
## 87 0.86131313 222 3843
## 88 0.87121212 221 4138
## 89 0.88111111 220 4481
## 90 0.89101010 220 4887
## 91 0.90090909 220 5375
## 92 0.91080808 220 5970
## 93 0.92070707 221 6714
## 94 0.93060606 224 7671
## 95 0.94050505 227 8946
## 96 0.95040404 233 10730
## 97 0.96030303 243 13403
## 98 0.97020202 260 17853
## 99 0.98010101 297 26731
## 100 0.99000000 411 53184
DFIG1<- span="">as.data.frame(FIG1)
plot(x=DFIG1$propP, y=DFIG1[,2], ylim=c(0,2000), lty=1, type="l",
ylab="total sample size", xlab="proportion of true positives")
lines(x=DFIG1$propP, y=DFIG1[,3], lty=2 )->
plotnPV: Plot experimental design for different setting in a single figure.
The function creates a plot from the results of the function nPV.
TEST<- span="">nPV(se=c(0.9, 0.92, 0.94, 0.96, 0.98), sp=c(0.98, 0.96, 0.94, 0.92, 0.90),
pr=0.12, NPV0=0.98, PPV0=0.4, NPVpower = 0.8, PPVpower = 0.8,
rangeP = c(0.05, 0.95), nsteps = 100, alpha = 0.05)->
## Warning in nPPV(propP = Pseq, se = ARGLIST$se[i], sp = ARGLIST$sp[i], prev
## = ARGLIST$prev[i], : Some sample sizes n (68, 68, ..., 111) might be too
## small to expect validity of asymptotic formulas for anticipated sensitivity
## (se), and the corresponding proportion of positives (propP).
## Warning in nPPV(propP = Pseq, se = ARGLIST$se[i], sp = ARGLIST$sp[i], prev
## = ARGLIST$prev[i], : Some sample sizes n (68, 68, ..., 1230) might be too
## small to expect validity of asymptotic formulas for anticipated specificity
## (sp), and the corresponding proportion of negatives (1-propP).
## Warning in nNPV(propP = Pseq, se = ARGLIST$se[i], sp = ARGLIST$sp[i], prev
## = ARGLIST$prev[i], : Some sample sizes n (630, 621, ..., 417) might be too
## small to expect validity of asymptotic formulas for anticipated specificity
## (sp), and the corresponding proportion of negatives (1-propP).
## Warning in nPPV(propP = Pseq, se = ARGLIST$se[i], sp = ARGLIST$sp[i], prev
## = ARGLIST$prev[i], : Some sample sizes n (70, 70, ..., 124) might be too
## small to expect validity of asymptotic formulas for anticipated sensitivity
## (se), and the corresponding proportion of positives (propP).
## Warning in nPPV(propP = Pseq, se = ARGLIST$se[i], sp = ARGLIST$sp[i], prev
## = ARGLIST$prev[i], : Some sample sizes n (70, 70, ..., 1238) might be too
## small to expect validity of asymptotic formulas for anticipated specificity
## (sp), and the corresponding proportion of negatives (1-propP).
## Warning in nNPV(propP = Pseq, se = ARGLIST$se[i], sp = ARGLIST$sp[i], prev
## = ARGLIST$prev[i], : Some sample sizes n (331, 326, ..., 234) might be too
## small to expect validity of asymptotic formulas for anticipated specificity
## (sp), and the corresponding proportion of negatives (1-propP).
## Warning in nPPV(propP = Pseq, se = ARGLIST$se[i], sp = ARGLIST$sp[i], prev
## = ARGLIST$prev[i], : Some sample sizes n (81, 81, ..., 154) might be too
## small to expect validity of asymptotic formulas for anticipated sensitivity
## (se), and the corresponding proportion of positives (propP).
## Warning in nPPV(propP = Pseq, se = ARGLIST$se[i], sp = ARGLIST$sp[i], prev
## = ARGLIST$prev[i], : Some sample sizes n (81, 81, ..., 1429) might be too
## small to expect validity of asymptotic formulas for anticipated specificity
## (sp), and the corresponding proportion of negatives (1-propP).
## Warning in nNPV(propP = Pseq, se = ARGLIST$se[i], sp = ARGLIST$sp[i], prev
## = ARGLIST$prev[i], : Some sample sizes n (216, 213, ..., 152) might be too
## small to expect validity of asymptotic formulas for anticipated specificity
## (sp), and the corresponding proportion of negatives (1-propP).
## Warning in nPPV(propP = Pseq, se = ARGLIST$se[i], sp = ARGLIST$sp[i], prev
## = ARGLIST$prev[i], : Some sample sizes n (100, 100, ..., 210) might be too
## small to expect validity of asymptotic formulas for anticipated sensitivity
## (se), and the corresponding proportion of positives (propP).
## Warning in nNPV(propP = Pseq, se = ARGLIST$se[i], sp = ARGLIST$sp[i],
## prev = ARGLIST$prev[i], : Some sample sizes n (1943, 1644, ..., 110) might
## be too small to expect validity of asymptotic formulas for anticipated
## sensitivity (se), and the corresponding proportion of positives (propP).
## Warning in nNPV(propP = Pseq, se = ARGLIST$se[i], sp = ARGLIST$sp[i], prev
## = ARGLIST$prev[i], : Some sample sizes n (160, 157, ..., 110) might be too
## small to expect validity of asymptotic formulas for anticipated specificity
## (sp), and the corresponding proportion of negatives (1-propP).
## Warning in nPPV(propP = Pseq, se = ARGLIST$se[i], sp = ARGLIST$sp[i], prev
## = ARGLIST$prev[i], : Some sample sizes n (127, 127, ..., 357) might be too
## small to expect validity of asymptotic formulas for anticipated sensitivity
## (se), and the corresponding proportion of positives (propP).
## Warning in nNPV(propP = Pseq, se = ARGLIST$se[i], sp = ARGLIST$sp[i], prev
## = ARGLIST$prev[i], : Some sample sizes n (1666, 1410, ..., 92) might be too
## small to expect validity of asymptotic formulas for anticipated sensitivity
## (se), and the corresponding proportion of positives (propP).
## Warning in nNPV(propP = Pseq, se = ARGLIST$se[i], sp = ARGLIST$sp[i], prev
## = ARGLIST$prev[i], : Some sample sizes n (133, 131, ..., 92) might be too
## small to expect validity of asymptotic formulas for anticipated specificity
## (sp), and the corresponding proportion of negatives (1-propP).
plotnPV(TEST)
# plot parameters maybe introduced via ...
# the legend maybe modified via legpar:
plotnPV(TEST, log="y", legpar=list(x=0.6))
# own colour definitions
plotnPV(TEST, NPVpar=list(col=1:6, lwd=2, lty=1),
PPVpar=list(col=1:6, lwd=2, lty=3))
plotnPV2 Plot experimental design for different settings in a set of sub figure.
The function creates a plot from the results of the function nPV.
TEST<- span="">nPV(se=c(0.9, 0.92, 0.94, 0.96, 0.98), sp=c(0.98, 0.96, 0.94, 0.92, 0.90),
pr=0.12, NPV0=0.98, PPV0=0.4, NPVpower = 0.8, PPVpower = 0.8,
rangeP = c(0.05, 0.95), nsteps = 20, alpha = 0.05)->
## Warning in nPPV(propP = Pseq, se = ARGLIST$se[i], sp = ARGLIST$sp[i], prev
## = ARGLIST$prev[i], : Some sample sizes n (68, 70, ..., 108) might be too
## small to expect validity of asymptotic formulas for anticipated sensitivity
## (se), and the corresponding proportion of positives (propP).
## Warning in nPPV(propP = Pseq, se = ARGLIST$se[i], sp = ARGLIST$sp[i], prev
## = ARGLIST$prev[i], : Some sample sizes n (68, 70, ..., 1230) might be too
## small to expect validity of asymptotic formulas for anticipated specificity
## (sp), and the corresponding proportion of negatives (1-propP).
## Warning in nNPV(propP = Pseq, se = ARGLIST$se[i], sp = ARGLIST$sp[i], prev
## = ARGLIST$prev[i], : Some sample sizes n (616, 573, ..., 417) might be too
## small to expect validity of asymptotic formulas for anticipated specificity
## (sp), and the corresponding proportion of negatives (1-propP).
## Warning in nPPV(propP = Pseq, se = ARGLIST$se[i], sp = ARGLIST$sp[i], prev
## = ARGLIST$prev[i], : Some sample sizes n (70, 71, ..., 119) might be too
## small to expect validity of asymptotic formulas for anticipated sensitivity
## (se), and the corresponding proportion of positives (propP).
## Warning in nPPV(propP = Pseq, se = ARGLIST$se[i], sp = ARGLIST$sp[i], prev
## = ARGLIST$prev[i], : Some sample sizes n (70, 71, ..., 1238) might be too
## small to expect validity of asymptotic formulas for anticipated specificity
## (sp), and the corresponding proportion of negatives (1-propP).
## Warning in nNPV(propP = Pseq, se = ARGLIST$se[i], sp = ARGLIST$sp[i], prev
## = ARGLIST$prev[i], : Some sample sizes n (314, 294, ..., 234) might be too
## small to expect validity of asymptotic formulas for anticipated specificity
## (sp), and the corresponding proportion of negatives (1-propP).
## Warning in nPPV(propP = Pseq, se = ARGLIST$se[i], sp = ARGLIST$sp[i], prev
## = ARGLIST$prev[i], : Some sample sizes n (81, 83, ..., 151) might be too
## small to expect validity of asymptotic formulas for anticipated sensitivity
## (se), and the corresponding proportion of positives (propP).
## Warning in nPPV(propP = Pseq, se = ARGLIST$se[i], sp = ARGLIST$sp[i], prev
## = ARGLIST$prev[i], : Some sample sizes n (81, 83, ..., 1429) might be too
## small to expect validity of asymptotic formulas for anticipated specificity
## (sp), and the corresponding proportion of negatives (1-propP).
## Warning in nNPV(propP = Pseq, se = ARGLIST$se[i], sp = ARGLIST$sp[i], prev
## = ARGLIST$prev[i], : Some sample sizes n (218, 202, ..., 152) might be too
## small to expect validity of asymptotic formulas for anticipated specificity
## (sp), and the corresponding proportion of negatives (1-propP).
## Warning in nPPV(propP = Pseq, se = ARGLIST$se[i], sp = ARGLIST$sp[i], prev
## = ARGLIST$prev[i], : Some sample sizes n (100, 101, ..., 207) might be too
## small to expect validity of asymptotic formulas for anticipated sensitivity
## (se), and the corresponding proportion of positives (propP).
## Warning in nNPV(propP = Pseq, se = ARGLIST$se[i], sp = ARGLIST$sp[i], prev
## = ARGLIST$prev[i], : Some sample sizes n (1943, 998, ..., 110) might be too
## small to expect validity of asymptotic formulas for anticipated sensitivity
## (se), and the corresponding proportion of positives (propP).
## Warning in nNPV(propP = Pseq, se = ARGLIST$se[i], sp = ARGLIST$sp[i], prev
## = ARGLIST$prev[i], : Some sample sizes n (158, 147, ..., 110) might be too
## small to expect validity of asymptotic formulas for anticipated specificity
## (sp), and the corresponding proportion of negatives (1-propP).
## Warning in nPPV(propP = Pseq, se = ARGLIST$se[i], sp = ARGLIST$sp[i], prev
## = ARGLIST$prev[i], : Some sample sizes n (127, 131, ..., 345) might be too
## small to expect validity of asymptotic formulas for anticipated sensitivity
## (se), and the corresponding proportion of positives (propP).
## Warning in nNPV(propP = Pseq, se = ARGLIST$se[i], sp = ARGLIST$sp[i], prev
## = ARGLIST$prev[i], : Some sample sizes n (1666, 856, ..., 92) might be too
## small to expect validity of asymptotic formulas for anticipated sensitivity
## (se), and the corresponding proportion of positives (propP).
## Warning in nNPV(propP = Pseq, se = ARGLIST$se[i], sp = ARGLIST$sp[i], prev
## = ARGLIST$prev[i], : Some sample sizes n (126, 118, ..., 92) might be too
## small to expect validity of asymptotic formulas for anticipated specificity
## (sp), and the corresponding proportion of negatives (1-propP).
plotnPV2(TEST, log="x")
## $log
## [1] "x"
##
## $main
## [1] "Setting 1"
##
## $xlab
## [1] "Ratio n1/(n0+n1)"
##
## $ylab
## [1] "Sample size"
##
## $type
## [1] "l"
##
## $lty
## [1] 1
##
## $xlim
## [1] 0.05 0.95
## $log
## [1] "x"
##
## $main
## [1] "Setting 2"
##
## $xlab
## [1] "Ratio n1/(n0+n1)"
##
## $ylab
## [1] "Sample size"
##
## $type
## [1] "l"
##
## $lty
## [1] 1
##
## $xlim
## [1] 0.05 0.95
## $log
## [1] "x"
##
## $main
## [1] "Setting 3"
##
## $xlab
## [1] "Ratio n1/(n0+n1)"
##
## $ylab
## [1] "Sample size"
##
## $type
## [1] "l"
##
## $lty
## [1] 1
##
## $xlim
## [1] 0.05 0.95
## $log
## [1] "x"
##
## $main
## [1] "Setting 4"
##
## $xlab
## [1] "Ratio n1/(n0+n1)"
##
## $ylab
## [1] "Sample size"
##
## $type
## [1] "l"
##
## $lty
## [1] 1
##
## $xlim
## [1] 0.05 0.95
## $log
## [1] "x"
##
## $main
## [1] "Setting 5"
##
## $xlab
## [1] "Ratio n1/(n0+n1)"
##
## $ylab
## [1] "Sample size"
##
## $type
## [1] "l"
##
## $lty
## [1] 1
##
## $xlim
## [1] 0.05 0.95
print.BDtest Detailed print out for BDtest
Print details of the results of the function BDtest on the screen
print.nPV Detailed print out for nPV
Print details of the results of the experimental design function nPV on the screen
simPV Simulate performance of confidence intervals for predictive values in a case-control desig
The function draws data under the binomial assumption and computes the asymptotic confidence bounds (lower bounds only!) for the positive and negative predictive values. Output are the power (probability to exclude NPV0/PPV0), the realized coverage probability, 0.1,0.2, and 0.5-quantiles of the realized distribution of confidence bounds.
simPV(se=0.8, sp=0.95, pr=1/16, n1=177, n0=554, NPV0=0.98, PPV0=0.4)
## pow cov q10 q20 q50 tr H0
## NPV 0.856 0.956 0.9794224 0.9805417 0.9822282 0.9861592 0.98
## PPV 0.852 0.968 0.3913573 0.4089670 0.4378463 0.5161290 0.40
simPV(se=0.8, sp=0.95, pr=1/16, n1=181, n0=87, NPV0=0.98, PPV0=0.25)
## pow cov q10 q20 q50 tr H0
## NPV 0.852 0.958 0.9795654 0.9805747 0.9824941 0.9861592 0.98
## PPV 0.960 1.000 0.2684284 0.2862879 0.3377352 0.5161290 0.25
simPVmat Simulate performance of confidence intervals for predictive values in case-control design
Simulate the power (probability to exclude NPV0/PPV0), the coverage probability, and 0.1, 0.2, and 0.5-quantiles of the distribution of (lower!) asymptotic confidence bounds for predictive values. Different experimental setups may be compared. The function draws data under the binomial assumption and computes the asymptotic confidence bounds (lower bounds only!) for the positive and negative predictive values.
simPVmat(se=0.8, sp=0.95, pr=1/16,
n1=c(177, 181), n0=c(554, 87), NPV0=0.98, PPV0=c(0.4, 0.25))
## $INDAT
## se sp pr NPV0 PPV0 n1 n0 n
## Setting 1 0.8 0.95 0.0625 0.98 0.40 177 554 731
## Setting 2 0.8 0.95 0.0625 0.98 0.25 181 87 268
##
## $NPV
## pow cov q10 q20 q50 tr H0
## Setting 1 0.840 0.952 0.9794406 0.9803505 0.9823181 0.9861592 0.98
## Setting 2 0.826 0.976 0.9794241 0.9803117 0.9820892 0.9861592 0.98
##
## $PPV
## pow cov q10 q20 q50 tr H0
## Setting 1 0.864 0.966 0.3916883 0.4071447 0.4355451 0.516129 0.40
## Setting 2 0.940 1.000 0.2630227 0.2833974 0.3369411 0.516129 0.25
##
## $NSIM
## [1] 500
##
## $conf.level
## [1] 0.95
simPVmat(se=0.8, sp=0.95, pr=c(0.05,0.0625, 0.075, 0.1),
n1=177, n0=554, NPV0=0.98, PPV0=0.4)
## $INDAT
## se sp pr NPV0 PPV0 n1 n0 n
## Setting 1 0.8 0.95 0.0500 0.98 0.4 177 554 731
## Setting 2 0.8 0.95 0.0625 0.98 0.4 177 554 731
## Setting 3 0.8 0.95 0.0750 0.98 0.4 177 554 731
## Setting 4 0.8 0.95 0.1000 0.98 0.4 177 554 731
##
## $NPV
## pow cov q10 q20 q50 tr H0
## Setting 1 0.998 0.950 0.9838239 0.9846683 0.9859038 0.9890411 0.98
## Setting 2 0.860 0.952 0.9794615 0.9806360 0.9823924 0.9861592 0.98
## Setting 3 0.324 0.950 0.9751982 0.9764411 0.9786665 0.9832168 0.98
## Setting 4 0.014 0.950 0.9663185 0.9683536 0.9712814 0.9771429 0.98
##
## $PPV
## pow cov q10 q20 q50 tr H0
## Setting 1 0.328 0.958 0.3384829 0.3509495 0.3800455 0.4571429 0.4
## Setting 2 0.858 0.942 0.3928242 0.4119664 0.4411623 0.5161290 0.4
## Setting 3 0.996 0.956 0.4410514 0.4550254 0.4879797 0.5647059 0.4
## Setting 4 1.000 0.968 0.5205950 0.5401113 0.5681677 0.6400000 0.4
##
## $NSIM
## [1] 500
##
## $conf.level
## [1] 0.95
No comments:
Post a Comment