trace tracker logo

Testing in parallel or series

This utility calculates the overall sensitivity and specificity of the testing regimen when two tests of known sensitivity and specificity are used together, either in parallel or in series. Calculations assume that the two tests are independent, conditional on disease status (that is, sensitivity [specificity] for one test remains the same, regardless of the result of the other test.

No results

No example available
No references available
				######################################
# Program to calculate Se and Sp for 2 tests in parallel and series
######################################


# check version and load header script
rm(list = ls())
test<- ifelse(length(commandArgs()) < 3, TRUE, FALSE)
fpath<- ifelse(test, "webRootUrl", "rtoolsPath")

# load header scripts
  source(paste(fpath, "R/epi_head.R", sep = ""))
  source(paste(fpath, "R/HTMLStream.R", sep = ""))
  source(paste(fpath, "R/epitools_functions.r", sep = ""))

# extract command arguments
    a1<- a0[8:13]

# cat(a0)
# cat(a1)
digits<- 4
test1<- a1[1]
test2<- a1[4]
Se1<- type.convert(a1[2])
Sp1<- type.convert(a1[3])
Se2<- type.convert(a1[5])
Sp2<- type.convert(a1[6])
dim(a1)<- c(3, 2)
a1<- t(a1)
colnames(a1)<- c("Test", "Sensitivity", "Specificity")
results<- array(0, dim = c(2, 4))
rownames(results)<- c("Sensitivity", "Specificity")
colnames(results)<- c(test1, test2, "Parallel", "Serial")

results[,1:2]<- type.convert(t(a1[,2:3]))
results[1,3]<- 1 - (1 - Se1)*(1 - Se2)
results[1,4]<- Se1*Se2
results[2,3]<- Sp1*Sp2
results[2,4]<- 1 - (1 - Sp1)*(1 - Sp2)

results<- formatC(results, format = "f", digits = digits)

# write to html and file
# cat(test)
heading<- "Sensitivity and specificity for two tests in parallel or series"
subheadings<- ""
filename<- digest(Sys.time())
tmp.file<- paste(fpath, "tmp/", filename, sep = "")
result.txt<- "

The table below summarises the sensitivities and specificities of two tests used in parallel or series. These results assume that the two tests are independent, conditional on disease status.

" output<- html.output(heading, subheadings, inputs = "", results = list(results), graphs = "", graph.headings = "", show.inputs = F, show.graphs = F, tmp.file, result.txt = result.txt) write.html(output, tmp.file) cat(output)