Title: | Comparison of Binary Diagnostic Tests in a Paired Study Design |
---|---|
Description: | Comparison of the accuracy of two binary diagnostic tests in a "paired" study design, i.e. when each test is applied to each subject in the study. |
Authors: | Christian Stock [aut, cre] |
Maintainer: | Christian Stock <[email protected]> |
License: | GPL (>= 3) |
Version: | 1.2.6 |
Built: | 2025-02-04 05:10:10 UTC |
Source: | https://github.com/chstock/dtcompair |
Comparison of the accuracy of two binary diagnostic tests in a “paired” study design, i.e. when each test is applied to each subject in the study.
The accuracy measures that can be compared in the present version are sensitivity, specificity, positive and negative predictive values, and positive and negative diagnostic likelihood ratios.
It is required that results from a binary gold-standard test are also available.
Methods for comparison of sensitivity and specificity: McNemar test (McNemar, 1947) and exact binomial test. Further, several methods to compute confidence intervals for differences in sensitivity and specificity are implemented.
Methods for comparison of positive and negative predictive values: generalized score statistic (Leisenring, Alonzo and Pepe, 2000), weighted generalized score statistic (Kosinski, 2013) and comparison of relative predictive values (Moskowitz and Pepe, 2006).
Methods for comparison of positive and negative diagnostic likelihood ratios: a regression model approach (Gu and Pepe, 2009).
For a general introduction into the evaluation of diagnostic tests see e.g. Pepe (2003), Zhou, Obuchowski and McClish (2011).
Christian Stock, Thomas Hielscher and Andrea Discacciati
Maintainer: Christian Stock <[email protected]>
Gu and Pepe (2009), "Estimating the capacity for improvement in risk prediction with a marker", <doi:10.1093/biostatistics/kxn025>.
Kosinski (2013), "A weighted generalized score statistic for comparison of predictive values of diagnostic tests", <doi:10.1002/sim.5587>.
Leisenring, Alonzo and Pepe (2000), "Comparisons of predictive values of binary medical diagnostic tests for paired designs", <doi:10.1111/j.0006-341X.2000.00345.x>.
McNemar (1947), "Note on the sampling error of the difference between correlated proportions or percentages", <doi:10.1007/BF02295996>.
Moskowitz and Pepe (2006), "Comparing the predictive values of diagnostic tests: sample size and analysis for paired study designs", <doi:10.1191/1740774506cn147oa>.
Pepe (2003, ISBN:978-0198509844), "The statistical evaluation of medical tests for classification and prediction".
Zhou, Obuchowski and McClish (2011), "Statistical Methods in Diagnostic Medicine", <doi:10.1002/9780470906514>.
Data management functions: tab.1test
, tab.paired
, read.tab.paired
, generate.paired
and represent.long
.
Computation of standard accuracy measures for a single test: acc.1test
and acc.paired
.
Comparison of sensitivity and specificity: sesp.mcnemar
, sesp.exactbinom
and sesp.diff.ci
.
Comparison of positive and negative predictive values: pv.gs
, pv.wgs
and pv.rpv
.
Comparison of positive and negative diagnostic likelihood ratios: dlr.regtest
and DLR
.
data(Paired1) # Hypothetical study data hsd <- tab.paired(d=d, y1=y1, y2=y2, data=Paired1) acc.paired(hsd) sesp.mcnemar(hsd) pv.rpv(hsd) dlr.regtest(hsd)
data(Paired1) # Hypothetical study data hsd <- tab.paired(d=d, y1=y1, y2=y2, data=Paired1) acc.paired(hsd) sesp.mcnemar(hsd) pv.rpv(hsd) dlr.regtest(hsd)
Sensitivity and specificity, (positive and negative) predictive values and (positive and negative) diagnostic likelihood ratios of a single binary diagnostic test.
acc.1test(tab, alpha, testname, method.ci, ...)
acc.1test(tab, alpha, testname, method.ci, ...)
tab |
An object of class |
alpha |
Significance level alpha for 100(1-alpha)%-confidence intervals, the default is 0.05. |
testname |
A character string containing the name of the diagnostic test. |
method.ci |
A character string with the name of the function to compute
the confidence intervals for sensitivity, specificity, and predictive values.
The default is |
... |
Additional arguments (usually not required). |
The calculation of accuracy measures follows standard methodology, e.g. described in Pepe (2003) or Zhou et al. (2011).
The confidence intervals for sensitivity, specificity, and predictive values are
computed using the methodology implemented in the function passed to the
argument method.ci
.
Available options are:
waldci
- Wald asymptotic normal-based confidence interval; the
default,
logitci
- asymptotic normal-based confidence interval on the
logit scale and then back-transformed,
exactci
- Clopper-Pearson exact confidence interval,
add4cici
- Agresti-Coull add-4 confidence interval,
addz2ci
- Agresti-Coull add-z^2/2 confidence interval,
blakerci
- Blaker exact confidence interval,
scoreci
- Wilson score confidence interval,
midPci
- mid-P confidence interval.
Options (3) to (8) are based on the homonymous functions from the {PropCIs}
package. Please see the respective package documentation for more details.
Confidence intervals for diagnostic likelihood ratios are computed according to Simel et al. (1991).
A list of class acc.1test
:
tab |
A contingency table (matrix) of test results; the same
|
||||||||||||||||
sensitivity |
A numeric vector containing the estimated sensitivity ( |
||||||||||||||||
specificity |
A numeric vector containing the estimated specificity ( |
||||||||||||||||
ppv |
A numeric vector containing the estimated positive predictive value ( |
||||||||||||||||
npv |
A numeric vector containing the estimated negative predictive value ( |
||||||||||||||||
pdlr |
A numeric vector containing the estimated positive diagnostic likelihood ratio ( |
||||||||||||||||
ndlr |
A numeric vector containing the estimated negative diagnostic likelihood ratio ( |
||||||||||||||||
alpha |
The significance level alpha used to compute 100(1-alpha)%-confidence intervals, the default is 0.05. |
||||||||||||||||
testname |
A character string containing the name of the diagnostic test. |
||||||||||||||||
method.ci |
A character string describing the method used to compute the confidence intervals for sensitivity, specificity, and predictive values. |
Pepe, M. (2003). The statistical evaluation of medical tests for classification and prediction. Oxford Statistical Science Series. Oxford University Press, 1st edition.
Simel, D.L., Samsa, G.P., Matchar, D.B. (1991). Likelihood ratios with confidence: sample size estimation for diagnostic test studies. J Clin Epidemiol, 44(8):763-70.
Zhou, X., Obuchowski, N., and McClish, D. (2011). Statistical Methods in Diagnostic Medicine. Wiley Series in Probability and Statistics. John Wiley & Sons, Hoboken, New Jersey, 2nd edition.
tab.1test
,
print.acc.1test
,
acc.paired
.
data(Paired1) # Hypothetical study data a1 <- tab.1test(d=d, y=y1, data=Paired1) a2 <- acc.1test(a1) print(a2) a3 <- acc.1test(a1, method="exactci", alpha=0.01) print(a3)
data(Paired1) # Hypothetical study data a1 <- tab.1test(d=d, y=y1, data=Paired1) a2 <- acc.1test(a1) print(a2) a3 <- acc.1test(a1, method="exactci", alpha=0.01) print(a3)
Sensitivity and specificity, (positive and negative) predictive values and (positive and negative) diagnostic likelihood ratios of a two binary diagnostic tests in a paired study design.
acc.paired(tab, alpha, method.ci, ...)
acc.paired(tab, alpha, method.ci, ...)
tab |
An object of class |
alpha |
Significance level alpha for 100(1-alpha)%-confidence intervals, the default is 0.05. |
method.ci |
A function used to compute the confidence intervals for sensitivity, specificity, and predictive values. The default is |
... |
Additional arguments, usually not required. |
The calculation of accuracy measures follows standard methodology, e.g. described in Pepe (2003) or Zhou et al. (2011).
The confidence intervals for sensitivity, specificity, and predictive values are computed using the methodology implemented in the function passed to the argument method.ci
.
Confidence intervals for diagnostic likelihood ratios are computed according to Simel et al. (1991).
A list of class acc.paired
:
Test1 |
A list of class |
Test2 |
A list of class |
Pepe, M. (2003). The statistical evaluation of medical tests for classifcation and prediction. Oxford Statistical Science Series. Oxford University Press, 1st edition.
Zhou, X., Obuchowski, N., and McClish, D. (2011). Statistical Methods in Diagnostic Medicine. Wiley Series in Probability and Statistics. John Wiley & Sons, Hoboken, New Jersey, 2nd edition.
tab.paired
,
print.acc.paired
,
acc.1test
.
data(Paired1) # Hypothetical study data b1 <- tab.paired(d=d, y1=y1, y2=y2, data=Paired1) b2 <- acc.paired(b1) print(b2)
data(Paired1) # Hypothetical study data b1 <- tab.paired(d=d, y1=y1, y2=y2, data=Paired1) b2 <- acc.paired(b1) print(b2)
This function allows for estimating the log diagnostic likelihood ratio in a regression model approach. It can be used to assess the gain in diagnostic accuracy for a new binary or continuous diagnostic marker compared to established markers, to determine the impact of covariates on the risk prediction model, and to estimate the DLR for selected marker/covariate values.
DLR(basemodel, augmentedmodel, diseasestatus, dataset, clustervar = NULL, alpha=0.05)
DLR(basemodel, augmentedmodel, diseasestatus, dataset, clustervar = NULL, alpha=0.05)
basemodel |
pre-test/base model X, formula character string |
augmentedmodel |
post-test/ augmented model V, formula character string, this is usually the basemodel X including the additional diagnostic test of interest Y and interactions XY |
diseasestatus |
variable name containing disease status, assumed to be a 0/1 variable, for having condition of interest (1) or not (0), character string |
dataset |
dataframe, needs to be in wide format with one observation per subject |
clustervar |
optional, cluster variable name in dataset, character string |
alpha |
significance level alpha used for confidence intervals, the default is 0.05. |
This function is an implementation of the algorithm described in the appendix of Gu and Pepe (2009) using the GEE approach in order to get standard error estimates. The definition of I and Zero matrices is slightly more flexible than the ones described in section 3 in order to allow for models without interaction.
Returns a list including
logPreTestModel |
logistic regression model output for prior disease using base model X: P(D=1|X). All estimates are on a log scale. |
logPostTestModel |
logistic regression model output for posterior disease using augmented model V: P(D=1|X,Y),i.e. P(D=1|V). All estimates are on a log scale. |
logDLRModel |
regression model output for log DLR defined as difference between logPostTestModel and logPreTestModel. All estimates are on a log scale. |
DLR |
Positive/negative DLR for diagnostic marker Y, with all base covariates X set to 1. Results are only sensible for binary marker Y taking values 0/1. |
Thomas Hielscher ([email protected])
Gu, W. and Pepe, M. S. (2009). Estimating the capacity for improvement in risk prediction with a marker. Biostatistics, 10(1):172-86.
library(DTComPair) data(Paired1) # test y1 conditioned on null model: DLR+(Y1=1) and DLR-(Y1=0) DLR("~ 1","~ y1","d",Paired1) # test y1 conditioned on test y2 with interaction, DLR+(Y1=1|Y2=1) and DLR-(Y1=0|Y2=1) DLR("~ y2","~ y2 * y1","d",Paired1)
library(DTComPair) data(Paired1) # test y1 conditioned on null model: DLR+(Y1=1) and DLR-(Y1=0) DLR("~ 1","~ y1","d",Paired1) # test y1 conditioned on test y2 with interaction, DLR+(Y1=1|Y2=1) and DLR-(Y1=0|Y2=1) DLR("~ y2","~ y2 * y1","d",Paired1)
Performs a test for differences in (positive and negative) diagnostic likelihood ratios (DLRs) of two binary diagnostic tests in a paired study using a regression model approach proposed by Gu and Pepe (2009).
dlr.regtest(tab, alpha)
dlr.regtest(tab, alpha)
tab |
An object of class |
alpha |
Significance level alpha for 100(1-alpha)%-confidence intervals, the default is 0.05. |
The null hypothesis rDLR = DLR of Test 1 / DLR of Test 2 = 1 is tested with respect to both positive and negative DLRs of the two diagnostic tests.
This function calls DLR
, a general implementation of the method proposed by Gu and Pepe (2009).
A list containing
pdlr |
A list with
|
ndlr |
A list with
|
alpha |
The significance level alpha used to compute 100(1-alpha)%-confidence intervals for the |
method |
The name of the method used to compare the positive and negative DLRs, here “diagnostic likelihood regression model (regtest)”. |
Gu, W. and Pepe, M. S. (2009). Estimating the capacity for improvement in risk prediction with a marker. Biostatistics, 10(1):172-86.
data(Paired1) # Hypothetical study data ptab <- tab.paired(d=d, y1=y1, y2=y2, data=Paired1) ptab dlr.results <- dlr.regtest(ptab) str(dlr.results) dlr.results
data(Paired1) # Hypothetical study data ptab <- tab.paired(d=d, y1=y1, y2=y2, data=Paired1) ptab dlr.results <- dlr.regtest(ptab) str(dlr.results) dlr.results
Returns a 100(1-alpha)% elliptical joint confidence region for the parameter vector {log(relative positive predictive value), log(relative negative predictive value)}.
ellipse.pv.rpv(x, alpha = 0.05, npoints = 100, exponentiate = FALSE)
ellipse.pv.rpv(x, alpha = 0.05, npoints = 100, exponentiate = FALSE)
x |
an object returned by the |
alpha |
significance level alpha used to compute the 100(1-alpha)% region. The default is 0.05, for a 95% region. |
npoints |
the number of points used in the ellipse. Default is 100. |
exponentiate |
a logical value indicating whether or not to exponentiate the values for the centre of the ellipse and for the the ellipsoidal outline. Defaults to FALSE. |
A list containing:
centre |
the centre of the ellipse. |
ellipse |
an |
Moskowitz, C.S., and Pepe, M.S. (2006). Comparing the predictive values of diagnostic tests: sample size and analysis for paired study designs. Clin Trials, 3(3):272-9.
pv.rpv
and ellipse::ellipse
.
data(Paired1) # Hypothetical study data ftable(Paired1) paired.layout <- tab.paired(d=d, y1=y1, y2=y2, data=Paired1) paired.layout rpv.results <- pv.rpv(paired.layout) ellipse.data <- ellipse.pv.rpv(rpv.results) if(interactive()){ plot(ellipse.data$ellipse, type = "l", ylim = c(-0.4, 0.2), xlim = c(-0.2, 0.2)) points(ellipse.data$centre[1], ellipse.data$centre[2], col = "red", pch = 19) abline(h = 0, v = 0, lty = 3) }
data(Paired1) # Hypothetical study data ftable(Paired1) paired.layout <- tab.paired(d=d, y1=y1, y2=y2, data=Paired1) paired.layout rpv.results <- pv.rpv(paired.layout) ellipse.data <- ellipse.pv.rpv(rpv.results) if(interactive()){ plot(ellipse.data$ellipse, type = "l", ylim = c(-0.4, 0.2), xlim = c(-0.2, 0.2)) points(ellipse.data$centre[1], ellipse.data$centre[2], col = "red", pch = 19) abline(h = 0, v = 0, lty = 3) }
Generates a dataset from contingency tables of binary diagnostic test results in a paired study design.
generate.paired(tab, ...)
generate.paired(tab, ...)
tab |
An object of class |
... |
Additional arguments (usually not required). |
A dataframe containing:
d |
A numeric vector specifying the gold-standard results (1 = presence of disease, 0 = absence of disease). |
y1 |
A numeric vector specifying the results of diagnostic test 1 (1 = positive, 0 = negative). |
y2 |
A numeric vector specifying the results of diagnostic test 2 (1 = positive, 0 = negative). |
tab.paired
and read.tab.paired
.
data(Paired1) # Hypothetical study data ftable(Paired1) paired.layout <- tab.paired(d=d, y1=y1, y2=y2, data=Paired1) new.df <- generate.paired(paired.layout) head(new.df) ftable(new.df)
data(Paired1) # Hypothetical study data ftable(Paired1) paired.layout <- tab.paired(d=d, y1=y1, y2=y2, data=Paired1) new.df <- generate.paired(paired.layout) head(new.df) ftable(new.df)
Hypothetical data from a paired study that aims to compare the accuracy of two binary diagnostic tests.
Paired1
Paired1
A dataframe containing 3 columns (d
, y1
and y2
) and 712 rows.
d
is a numeric vector specifying the gold-standard results (1 = presence of disease, 0 = absence of disease).
y1
is a numeric vector specifying the results of diagnostic test 1 (1 = positive, 0 = negative).
y2
is a numeric vector specifying the results of diagnostic test 1 (1 = positive, 0 = negative).
data(Paired1) # Hypothetical study data ftable(Paired1)
data(Paired1) # Hypothetical study data ftable(Paired1)
Prints objects of class acc.1test
in an easy-to-read form (S3method).
## S3 method for class 'acc.1test' print(x, ...)
## S3 method for class 'acc.1test' print(x, ...)
x |
An object of class |
... |
Additional arguments (usually not required). |
Creates a list object from parts of its input that is then printed in a tabular layout.
data(Paired1) # Hypothetical study data a1 <- tab.1test(d=d, y=y1, data=Paired1) a2 <- acc.1test(a1) print(a2)
data(Paired1) # Hypothetical study data a1 <- tab.1test(d=d, y=y1, data=Paired1) a2 <- acc.1test(a1) print(a2)
Prints objects of class acc.paired
in an easy-to-read form (S3method).
## S3 method for class 'acc.paired' print(x, ...)
## S3 method for class 'acc.paired' print(x, ...)
x |
An object of class |
... |
Additional arguments (usually not required). |
Creates a list object from parts of its input that is then printed in a tabular layout.
data(Paired1) # Hypothetical study data b1 <- tab.paired(d=d, y1=y1, y2=y2, data=Paired1) b2 <- acc.paired(b1) print(b2)
data(Paired1) # Hypothetical study data b1 <- tab.paired(d=d, y1=y1, y2=y2, data=Paired1) b2 <- acc.paired(b1) print(b2)
Prints objects of class tab.1test
in an easy-to-read form (S3method).
## S3 method for class 'tab.1test' print(x, ...)
## S3 method for class 'tab.1test' print(x, ...)
x |
An object of class |
... |
Additional arguments (usually not required). |
Creates a list object from parts of its input that is then printed in a tabular layout.
tab.1test
,
acc.1test
,
tab.paired
.
data(Paired1) # Hypothetical study data a <- tab.1test(d=d, y=y1, data=Paired1) print(a)
data(Paired1) # Hypothetical study data a <- tab.1test(d=d, y=y1, data=Paired1) print(a)
Prints objects of class tab.paired
in an easy-to-read form (S3method).
## S3 method for class 'tab.paired' print(x, ...)
## S3 method for class 'tab.paired' print(x, ...)
x |
An object of class |
... |
Additional arguments (usually not required). |
Creates a list object from parts of its input that is then printed in a tabular layout.
tab.paired
,
acc.paired
,
tab.1test
.
data(Paired1) # Hypothetical study data b <- tab.paired(d=d, y1=y1, y2=y2, data=Paired1) print(b)
data(Paired1) # Hypothetical study data b <- tab.paired(d=d, y1=y1, y2=y2, data=Paired1) print(b)
Performs a test for differences in (positive and negative) predictive values of two binary diagnostic tests using a generalized score statistic proposed by Leisenring, Alonzo and Pepe (2000).
pv.gs(tab)
pv.gs(tab)
tab |
An object of class |
A list containing:
ppv |
A list with |
npv |
A list with |
method |
The name of the method used to compare predictive values, here “generalized score statistic (gs)”. |
Leisenring, W., Alonzo, T., and Pepe, M. S. (2000). Comparisons of predictive values of binary medical diagnostic tests for paired designs. Biometrics, 56(2):345-51.
data(Paired1) # Hypothetical study data ftable(Paired1) paired.layout <- tab.paired(d=d, y1=y1, y2=y2, data=Paired1) paired.layout gs.results <- pv.gs(paired.layout) str(gs.results) gs.results gs.results$ppv["p.value"]
data(Paired1) # Hypothetical study data ftable(Paired1) paired.layout <- tab.paired(d=d, y1=y1, y2=y2, data=Paired1) paired.layout gs.results <- pv.gs(paired.layout) str(gs.results) gs.results gs.results$ppv["p.value"]
It is often of interest to estimate predictive values assuming the test were applied to a population with a different prevalence of the disease. Projected predictive values may be calculated using Bayes theorem and the relation between predictive values and diagnostic likelihood ratios can be used to derived corresponding confidence intervals.
pv.prev(pi, acc)
pv.prev(pi, acc)
pi |
A theoretical prevalence of the disease (proportion). |
acc |
An object of class 'acc.1test'. |
Predictive values, assuming a certain prevalence of the disease, are derived using the relation between predictive values and diagnostic likelihood ratios:
- PPV = 1 / (1 + (1 / pi - 1) / pDLR) - NPV = 1 / (1 + (1 / (1 / pi - 1)) / nDLR).
See Newcombe RG (2013). Confidence Intervals for Proportions and Related Measures of Effect Size. Chapman and Hall/ CRC Biostatistics Series (chapters 12.3+5 and 14.9).
The alpha-level of (1-alpha)-confidence intervals is inherited from 'acc.1test'.
A vector containing the projected values.
[acc.1test()]
data(Paired1) # Hypothetical study data a1 <- tab.1test(d=d, y=y1, data=Paired1) a2 <- acc.1test(a1, alpha = 0.05) pv.prev(pi=0.2, acc=a2) pv.prev(pi=0.5, acc=a2)
data(Paired1) # Hypothetical study data a1 <- tab.1test(d=d, y=y1, data=Paired1) a2 <- acc.1test(a1, alpha = 0.05) pv.prev(pi=0.2, acc=a2) pv.prev(pi=0.5, acc=a2)
Performs a test for differences in (positive and negative) predictive values of two binary diagnostic tests in a paired study design using relative predictive values, as proposed by Moskowitz and Pepe (2006).
pv.rpv(tab, alpha)
pv.rpv(tab, alpha)
tab |
An object of class |
alpha |
Significance level alpha used to compute 100(1-alpha)%-confidence intervals, the default is 0.05. |
A list containing:
ppv |
named vector containing |
npv |
named vector containing |
Sigma |
Estimated variance-covariance matrix for {log(relative positive predictive value), log(relative negative predictive value)}. |
method |
Name of the method used to compare predictive values, here “relative predictive values (rpv)”. |
alpha |
Significance level alpha used to compute 100(1-alpha)%-confidence intervals for |
Moskowitz, C.S., and Pepe, M.S. (2006). Comparing the predictive values of diagnostic tests: sample size and analysis for paired study designs. Clin Trials, 3(3):272-9.
data(Paired1) # Hypothetical study data ftable(Paired1) paired.layout <- tab.paired(d=d, y1=y1, y2=y2, data=Paired1) paired.layout rpv.results <- pv.rpv(paired.layout) str(rpv.results) rpv.results rpv.results$ppv["p.value"]
data(Paired1) # Hypothetical study data ftable(Paired1) paired.layout <- tab.paired(d=d, y1=y1, y2=y2, data=Paired1) paired.layout rpv.results <- pv.rpv(paired.layout) str(rpv.results) rpv.results rpv.results$ppv["p.value"]
Performs a test for differences in (positive and negative) predictive values of two binary diagnostic tests using a weighted generalized score statistic proposed by Kosinski (2013).
pv.wgs(tab)
pv.wgs(tab)
tab |
An object of class |
A list containing:
ppv |
A list with |
npv |
A list with |
method |
The name of the method used to compare predictive values, here “weighted generalized score statistic (wgs)”. |
Kosinski, A.S. (2013). A weighted generalized score statistic for comparison of predictive values of diagnostic tests. Stat Med, 32(6):964-77.
data(Paired1) # Hypothetical study data ftable(Paired1) paired.layout <- tab.paired(d=d, y1=y1, y2=y2, data=Paired1) paired.layout wgs.results <- pv.wgs(paired.layout) str(wgs.results) wgs.results wgs.results$ppv["p.value"]
data(Paired1) # Hypothetical study data ftable(Paired1) paired.layout <- tab.paired(d=d, y1=y1, y2=y2, data=Paired1) paired.layout wgs.results <- pv.wgs(paired.layout) str(wgs.results) wgs.results wgs.results$ppv["p.value"]
Reads in objects of class tab.1test using cell frequencies.
read.tab.1test(a, b, c, d, testname, ...)
read.tab.1test(a, b, c, d, testname, ...)
a |
The number of diseased subjects with a positive test. |
b |
The number of non-diseased subjects with a positive test. |
c |
The number of diseased subjects with a negative test. |
d |
The number of non-diseased subjects with a negative test. |
testname |
An optional vector specifying the name of the diagnostic test, e.g. |
... |
Additional arguments (usually not required). |
Returns a list of class tab.1test
containing:
tab.1test |
A contingency table (matrix) of test results.
|
||||||||||||||||
testname |
The name of the diagnostic test. |
Objects of class tab.1test
are required as arguments for acc.1test
, a function to compute the accuracy of a binary diagnostic test.
tab.1test
,
print.tab.1test
,
acc.1test
.
read.t1 <- read.tab.1test(321, 51, 730, 272, testname="Test1") class(read.t1) read.t1 acc.1test(read.t1)
read.t1 <- read.tab.1test(321, 51, 730, 272, testname="Test1") class(read.t1) read.t1 acc.1test(read.t1)
Reads in objects of class tab.paired using cell frequencies.
read.tab.paired(d.a, d.b, d.c, d.d, nd.a, nd.b, nd.c, nd.d, testnames, ...)
read.tab.paired(d.a, d.b, d.c, d.d, nd.a, nd.b, nd.c, nd.d, testnames, ...)
d.a |
The number of diseased subjects with a positive test 1 and a positive test 2. |
d.b |
The number of diseased subjects with a negative test 1 and a positive test 2. |
d.c |
The number of diseased subjects with a positive test 1 and a negative test 2. |
d.d |
The number of diseased subjects with a negative test 1 and a negative test 2. |
nd.a |
The number of non-diseased subjects with a positive test 1 and a positive test 2. |
nd.b |
The number of non-diseased subjects with a negative test 1 and a positive test 2. |
nd.c |
The number of non-diseased subjects with a positive test 1 and a negative test 2. |
nd.d |
The number of non-diseased subjects with a negative test 1 and a negative test 2. |
testnames |
An optional vector specifying the names of diagnostic test 1 and diagnostic test 2, e.g. |
... |
Additional arguments (usually not required). |
Returns a list of class tab.paired
containing:
diseased |
A contingency table (matrix) of test results among diseased subjects.
|
||||||||||||||||
non.diseased |
A contingency table (matrix) of test results among non-diseased subjects.
|
||||||||||||||||
testnames |
The names of the diagnostic tests. |
Objects of class tab.paired
are essential arguments for various functions in the
DTComPair
-package.
tab.paired
,
print.tab.paired
,
acc.paired
,
generate.paired
.
read.t2 <- read.tab.paired(321, 51, 730, 272, 120, 8, 74, 109, testnames=c("Test A", "Test B")) class(read.t2) read.t2 acc.paired(read.t2)
read.t2 <- read.tab.paired(321, 51, 730, 272, 120, 8, 74, 109, testnames=c("Test A", "Test B")) class(read.t2) read.t2 acc.paired(read.t2)
Long representation of results from two binary diagnostic tests.
represent.long(d, y1, y2)
represent.long(d, y1, y2)
d |
A numeric vector specifying the gold-standard results (1 = presence of disease, 0 = absence of disease). |
y1 |
A numeric vector specifying the results of diagnostic test 1 (1 = positive, 0 = negative). |
y2 |
An numeric vector specifying the results of diagnostic test 2 (1 = positive, 0 = negative). |
Sometimes a long representation of data from a “paired” study of binary diagnostic tests is required, e.g. to run regression analyses.
In a wide representation each subject has 1 record in the dataset containing d
, y1
and y2
.
In a long representation each subjects has 2 records in the dataset, one for each test. The data format is shown below.
A dataframe containing:
id |
A numeric vector specifying the patient identifier. |
d |
A numeric vector specifying the gold-standard results (1 = presence of disease, 0 = absence of disease). |
x |
A numeric vector specifying the diagnostic test (1 = test 1, 0 = test 2). |
y |
A numeric vector specifying the test results (1 = positive, 0 = negative). |
tab.paired
and read.tab.paired
.
data(Paired1) # Hypothetical study data names(Paired1) new.long <- represent.long(d=Paired1$d, y1=Paired1$y1, y2=Paired1$y2) str(new.long) head(new.long)
data(Paired1) # Hypothetical study data names(Paired1) new.long <- represent.long(d=Paired1$d, y1=Paired1$y1, y2=Paired1$y2) str(new.long) head(new.long)
Calculates confidence intervals for differences in sensitivity and specificity of two binary diagnostic tests in a paired study design.
sesp.diff.ci(tab, ci.method, alpha, cont.corr)
sesp.diff.ci(tab, ci.method, alpha, cont.corr)
tab |
An object of class |
ci.method |
The available methods are “ |
alpha |
Significance level alpha for 100(1-alpha)%-confidence intervals for the difference in sensitivity and specificity, the default is 0.05. |
cont.corr |
A logical value indicating whether the continuity correction should be used (only available for |
For details and recommendations see Newcombe (2012) and Wenzel and Zapf (2013).
A list containing:
sensitivity |
A vector containing
|
specificity |
A vector containing
|
ci.method |
The name of the method used to calculate confidence intervals. |
alpha |
The level alpha used to compute 100(1-alpha)%-confidence intervals. |
cont.corr |
A logical value indicating whether the continuity correction was applied. |
Altman, D.G. (1991). Practical statistics for medical research. Chapman & Hall, London.
Agresti, A. and Min, Y. (2005). Simple improved confidence intervals for comparing matched proportions. Stat Med, 24(5): 729-40.
Bonett, D.G., and Price, R.M. (2011). Adjusted Wald confidence intervals for a difference of binomial proportions based on paired data. J Educ Behav Stat, 37(4): 479-488.
Newcombe R.G. (2012). Confidence intervals for proportions and related measures of effect size. Chapman and Hall/CRC Biostatistics Series.
Tango, T. (1998). Equivalence test and confidence interval for the difference in proportions for the paired-sample design. Stat Med, 17(8): 891-908.
Wenzel, D., and Zapf, A. (2013). Difference of two dependent sensitivities and specificities: comparison of various approaches. Biom J, 55(5): 705-718.
library(DTComPair) t1 <- read.tab.paired(18, 14, 0, 18, 18, 12, 2, 18) t1 sesp.diff.ci(t1, ci.method="wald", cont.corr=FALSE) sesp.diff.ci(t1, ci.method="wald", cont.corr=TRUE) sesp.diff.ci(t1, ci.method="agresti-min") sesp.diff.ci(t1, ci.method="tango")
library(DTComPair) t1 <- read.tab.paired(18, 14, 0, 18, 18, 12, 2, 18) t1 sesp.diff.ci(t1, ci.method="wald", cont.corr=FALSE) sesp.diff.ci(t1, ci.method="wald", cont.corr=TRUE) sesp.diff.ci(t1, ci.method="agresti-min") sesp.diff.ci(t1, ci.method="tango")
Performs an exact binomial test for differences in sensitivity and specificity of two binary diagnostic tests in a paired study design.
sesp.exactbinom(tab)
sesp.exactbinom(tab)
tab |
An object of class |
The function performs a standard exact binomial test.
An exact binomial test is recommended when the number of patients with differing results for test 1 and test 2 (discordant pairs) is small, i.e. <20 (Zhou et al., 2011).
A list containing:
sensitivity |
A list containing
|
specificity |
A list containing
|
method |
The name of the method used to compare sensitivity and specificity, here “exactbinom”. |
Zhou, X., Obuchowski, N., and McClish, D. (2011). Statistical Methods in Diagnostic Medicine. Wiley Series in Probability and Statistics. John Wiley & Sons, Hoboken, New Jersey, 2nd edition.
sesp.mcnemar
and tab.paired
.
data(Paired1) # Hypothetical study data ftable(Paired1) paired.layout <- tab.paired(d=d, y1=y1, y2=y2, data=Paired1) paired.layout exact.results <- sesp.exactbinom(paired.layout) str(exact.results) exact.results exact.results$sensitivity["p.value"]
data(Paired1) # Hypothetical study data ftable(Paired1) paired.layout <- tab.paired(d=d, y1=y1, y2=y2, data=Paired1) paired.layout exact.results <- sesp.exactbinom(paired.layout) str(exact.results) exact.results exact.results$sensitivity["p.value"]
Performs a generalized McNemar's test to jointly compare sensitivity and specificity.
sesp.gen.mcnemar(tab)
sesp.gen.mcnemar(tab)
tab |
An object of class 'tab.paired'. |
A vector containing the test statistic and the p-value.
Lachenbruch P.A., Lynch C.J. (1998). Assessing screening tests: extensions of McNemar's test. Stat Med, 17(19): 2207-17.
[tab.paired()], [read.tab.paired()] and [sesp.mcnemar()]
# Example 1: data(Paired1) # Hypothetical study data ftable(Paired1) paired.layout1 <- tab.paired(d=d, y1=y1, y2=y2, data=Paired1) print(paired.layout1) sesp.gen.mcnemar(paired.layout1) # Example 2 (from Lachenbruch and Lynch (1998)): paired.layout2 <- read.tab.paired( d.a = 850, d.b = 40, d.c = 60, d.d = 50, nd.a = 60, nd.b = 25, nd.c = 15, nd.d = 900, testnames = c("T1", "T2") ) print(paired.layout2) sesp.gen.mcnemar(paired.layout2)
# Example 1: data(Paired1) # Hypothetical study data ftable(Paired1) paired.layout1 <- tab.paired(d=d, y1=y1, y2=y2, data=Paired1) print(paired.layout1) sesp.gen.mcnemar(paired.layout1) # Example 2 (from Lachenbruch and Lynch (1998)): paired.layout2 <- read.tab.paired( d.a = 850, d.b = 40, d.c = 60, d.d = 50, nd.a = 60, nd.b = 25, nd.c = 15, nd.d = 900, testnames = c("T1", "T2") ) print(paired.layout2) sesp.gen.mcnemar(paired.layout2)
Performs a McNemar Test for comparison of sensitivities and specificities of two binary diagnostic tests in a paired study design.
sesp.mcnemar(tab)
sesp.mcnemar(tab)
tab |
An object of class |
The test is performed as described by McNemar (1947).
A list containing:
sensitivity |
A list containing
|
specificity |
A list containing
|
method |
The name of the method used to compare sensitivity and specificity, here “ |
McNemar, Q. (1947). Note on the sampling error of the difference between correlated proportions or percentages. Psychometrika, 12(2):153-7.
sesp.exactbinom
and tab.paired
.
data(Paired1) # Hypothetical study data ftable(Paired1) paired.layout <- tab.paired(d=d, y1=y1, y2=y2, data=Paired1) paired.layout mcnem.results <- sesp.mcnemar(paired.layout) str(mcnem.results) mcnem.results mcnem.results$sensitivity["p.value"]
data(Paired1) # Hypothetical study data ftable(Paired1) paired.layout <- tab.paired(d=d, y1=y1, y2=y2, data=Paired1) paired.layout mcnem.results <- sesp.mcnemar(paired.layout) str(mcnem.results) mcnem.results mcnem.results$sensitivity["p.value"]
Calculates two-sided Wald confidence intervals and performs a Wald test for the relative sensitivity and specificity of two binary diagnostic tests in a paired study design.
sesp.rel(tab, alpha)
sesp.rel(tab, alpha)
tab |
an object of class |
alpha |
significance level alpha used to compute two-sided 100(1-alpha)%-confidence intervals, the default is 0.05. |
If relative sensitivity>1, the percentage increase in sensitivity for test2
relative to test1
is computed as 100(relative sensitivity-1)%. If
relative sensitivity<1 the percentage decrease in sensitivity for test2
relative to test1
is computed as 100(1-relative sensitivity)%.
Percentage increase/decrease in specificity is computed in an analogous fashion.
Given the independence of relative sensitivity and relative specificity, a possible joint 100(1-alpha)% confidence region for {relative sensitivity, relative specificity}
is formed by the rectangle {lcl.rel.sens
, ucl.rel.sens
} x {lcl.rel.spec
, ucl.rel.spec
}, where {lcl.rel.sens
, ucl.rel.sens
} and
{lcl.rel.spec
, ucl.rel.spec
} are 100(1-alpha*)% confidence intervals for relative sensitivity and relative specificity, respectively, and alpha*=1-sqrt(1-alpha).
The McNemar's test implemented in sesp.mcnemar
is asymptotically equivalent to the Wald test implemented here.
A list containing:
sensitivity |
a named vector containing |
specificity |
a named vector containing |
alpha |
significance level alpha for 100(1-alpha)%-confidence intervals for |
Alonzo, T. A., Pepe, M. S., & Moskowitz, C. S. (2002). Sample size calculations for comparative studies of medical tests for detecting presence of disease. Statistics in medicine, 21(6), 835-852.
sesp.diff.ci
, sesp.mcnemar
, and sesp.exactbinom
.
data(Paired1) # Hypothetical study data ftable(Paired1) paired.layout <- tab.paired(d=d, y1=y1, y2=y2, data=Paired1) paired.layout sesp.rel.results <- sesp.rel(paired.layout) str(sesp.rel.results) sesp.rel.results
data(Paired1) # Hypothetical study data ftable(Paired1) paired.layout <- tab.paired(d=d, y1=y1, y2=y2, data=Paired1) paired.layout sesp.rel.results <- sesp.rel(paired.layout) str(sesp.rel.results) sesp.rel.results
Produces a contingency table of results from a single binary diagnostic test vs. the gold-standard results.
tab.1test(d, y, data = NULL, testname, ...)
tab.1test(d, y, data = NULL, testname, ...)
d |
A numeric vector specifying the gold-standard results (1 = presence of disease, 0 = absence of disease). |
y |
A numeric vector specifying the results of the diagnostic test (1 = positive, 0 = negative). |
data |
An optional data frame, list or environment containing the required variables |
testname |
An optional character variable specifying the name of the diagnostic test, e.g. |
... |
Additional arguments (usually not required). |
Returns a list of class tab.1test
:
tab.1test |
A contingency table (matrix) of test results.
|
||||||||||||||||
testname |
The name of the diagnostic test. |
Objects of class tab.1test
are required as arguments for acc.1test
, a function to compute the accuracy of a binary diagnostic test.
tab.paired
,
acc.1test
,
acc.paired
.
data(Paired1) # Hypothetical study data a <- tab.1test(d=d, y=y1, data=Paired1) str(a) a$tab.1test a
data(Paired1) # Hypothetical study data a <- tab.1test(d=d, y=y1, data=Paired1) str(a) a$tab.1test a
Produces contingency tables of results from two binary diagnostic tests evaluated in a paired study design.
tab.paired(d, y1, y2, data = NULL, testnames, ...)
tab.paired(d, y1, y2, data = NULL, testnames, ...)
d |
A numeric vector specifying the gold-standard results (1 = presence of disease, 0 = absence of disease). |
y1 |
A numeric vector specifying the results of diagnostic test 1 (1 = positive, 0 = negative). |
y2 |
A numeric vector specifying the results of diagnostic test 2 (1 = positive, 0 = negative). |
data |
An optional data frame, list or environment containing the required variables |
testnames |
An optional vector specifying the names of diagnostic test 1 and diagnostic test 2, e.g. |
... |
Additional arguments (usually not required). |
Returns a list of class tab.paired
:
diseased |
A contingency table (matrix) of test results among diseased subjects.
|
||||||||||||||||
non.diseased |
A contingency table (matrix) of test results among non-diseased subjects.
|
||||||||||||||||
testnames |
The names of the diagnostic tests. |
Objects of class tab.paired
are essential arguments for various functions in the
DTComPair
-package.
print.tab.paired
,
read.tab.paired
,
tab.1test
.
data(Paired1) # Hypothetical study data b <- tab.paired(d=d, y1=y1, y2=y2, data=Paired1) str(b) b$diseased b$non.diseased print(b)
data(Paired1) # Hypothetical study data b <- tab.paired(d=d, y1=y1, y2=y2, data=Paired1) str(b) b$diseased b$non.diseased print(b)
Calculates two-sided Wald confidence intervals and performs a Wald test for the relative true positive fraction (TPF) (sensitivity) and false positive fraction (FPF) (i.e., one minus specificity) of two binary diagnostic tests in a paired study design.
This function is primarily intended for the analysis of paired screen positive studies, i.e. those paired studies where the disease (outcome) is ascertained using the gold standard test only in subjects who screen positive to either or both diagnostic tests. However, this function can also be used with data from standard paired studies, i.e. where the gold standard test is applied to all subjects.
tpffpf.rel(tab, alpha)
tpffpf.rel(tab, alpha)
tab |
an object of class |
alpha |
significance level alpha used to compute two-sided 100(1-alpha)%-confidence intervals, the default is 0.05. |
If relative true positive fraction>1, the percentage increase in true positive fraction for Test2 relative to Test1 is computed as 100(relative true positive fraction-1)%. If relative true positive fraction<1 the percentage decrease in true positive fraction for Test2 relative to Test1 is computed as 100(1-relative true positive fraction)%. Percentage increase/decrease in false positive fraction is computed in an analogous fashion.
Given the independence of relative TPR and relative TNR, a possible joint 100(1-alpha)% confidence region for {relative TPF, relative FPF}
is formed by the rectangle {lcl.rel.tpf
, ucl.rel.tpf
} x {lcl.rel.fpf
, ucl.rel.fpf
}, where {lcl.rel.tpf
, ucl.rel.tpf
} and
{lcl.rel.fpf
, ucl.rel.fpf
} are 100(1-alpha*)% confidence intervals for relative TPF and relative FPF, respectively, and alpha*=1-sqrt(1-alpha).
In screen positive studies, only relative TPF and relative FPF can be estimated from the data.
Their constituents, i.e. TPF and FPF for the two tests, are not estimable.
Relative specificity is not estimable either. Therefore, sesp.rel
should not
be used to attempt to estimate those quantities from studies with a paired screen positive design.
McNemar's test (sesp.mcnemar
) can, however, be used to test the null hypothesis of equality in specificities in
paired screen positive studies (Schatzkin et al., 1987).
A list containing:
tpf |
a named vector containing
|
fpf |
a named vector containing
|
alpha |
significance level alpha for 100(1-alpha)%-confidence intervals for |
Schatzkin, A., Connor, R. J., Taylor, P. R., & Bunnag, B. (1987). Comparing new and old screening tests when a reference procedure cannot be performed on all screenees: example of automated cytometry for early detection of cervical cancer. American Journal of Epidemiology, 125(4), 672-678.
Cheng, H., & Macaluso, M. (1997). Comparison of the accuracy of two tests with a confirmatory procedure limited to positive results. Epidemiology, 104-106.
Alonzo, T. A., Pepe, M. S., & Moskowitz, C. S. (2002). Sample size calculations for comparative studies of medical tests for detecting presence of disease. Statistics in medicine, 21(6), 835-852.
sesp.rel
.
# Data from Cheng and Macaluso (Table 2) breast.cancer.data <- read.tab.paired( 10, 24, 21, NA, 13, 144, 95, NA, testnames=c("Mammography", "Physical examination") ) breast.cancer.data tpffpf.rel.results <- tpffpf.rel(breast.cancer.data) str(tpffpf.rel.results) tpffpf.rel.results
# Data from Cheng and Macaluso (Table 2) breast.cancer.data <- read.tab.paired( 10, 24, 21, NA, 13, 144, 95, NA, testnames=c("Mammography", "Physical examination") ) breast.cancer.data tpffpf.rel.results <- tpffpf.rel(breast.cancer.data) str(tpffpf.rel.results) tpffpf.rel.results