# equal numbers of diseased/non-diseased, 80% sens, 73% spec, 74 participants total
prec_lr(.5, .8, .27, 74)
# Simel et al 1991, problem 1 - LR+ CI width from N
# Sensitivity of a new test is at least 80%, specificity is 73% and the LR+
# is 2.96 (= 0.8/(1-0.73)). We have as many diseased as not diseased
# (n1 = n2, n = 2*n1 = 146.8, prevalence = .5)
prec_lr(prev = .5, p1 = .8, p2 = 1-.73, n = 146.8)
prec_pos_lr(prev = .5, sens = .8, spec = .73, n = 146.8)
# problem 1 of Simel et al actually derives n1 rather than the width of the
# confidence interval (ie N from CI width). If we know that the lower limit
# of the CI should be 2.0, the confidence interval width is approximately
# exp(2*(log(2.96) - log(2))) = 2.19 (approximate because the CI Of the LR
# is only symetrical on the log(LR) scale), which we can put in conf.width
prec_lr(prev = .5, p1 = .8, p2 = 1-.73, conf.width = 2.2)
# same, but using the wrapper to specify sens and spec
prec_pos_lr(prev = .5, sens = .8, spec = .73, conf.width = 2.2)
# Simel et al 1991, problem 2 - LR- CI width from N
# p1 = 1 - sens = .1, p2 = spec = .5
# n1 = n2, n = 160, prev = .5
prec_lr(prev = .5, p1 = .1, p2 = .5, n = 160)
# same, but using the wrapper to specify sens and spec
prec_neg_lr(prev = .5, sens = .9, spec = .5, n = 160)
Run the code above in your browser using DataLab