binTab: Boolean Test-&-Disease or Risk-&-Disease Table

View source: R/binTab.R

binTabR Documentation

Boolean Test-&-Disease or Risk-&-Disease Table

Description

To create a Boolean test-&-disease or risk-&-disease table.

Usage

binTab(x, ...)

## S3 method for class 'matrix'
binTab(x, ...)

## S3 method for class 'table'
binTab(x, ...)

## S3 method for class 'formula'
binTab(formula, data, ...)

Arguments

x

(an R object convertible to a) 2\times 2 integer matrix, contingency table of two Boolean variables. The endpoint (i.e., disease) is on rows and the test/risk on columns.

formula

formula in the fashion of ~disease+test or ~disease+risk, see function xtabs

data

a data.frame

Details

Function binTab creates a 2\times 2 test-&-disease contingency table with layout

Test (-) Test (+)
Disease (-) x_{--} x_{-+}
Disease (+) x_{+-} x_{++}

or a 2\times 2 risk-&-disease contingency table with layout

Risk Factor (-) Risk Factor (+)
Disease (-) x_{--} x_{-+}
Disease (+) x_{+-} x_{++}

The endpoint (i.e., disease) must be on the rows and the test/risk on the columns.

Value

Function binTab returns a two-by-two integer matrix.

See Also

Function caret::confusionMatrix does not provide confidence intervals of sensitivity, specificity, etc.

Examples

binTab(matrix(c(7L, 3L, 8L, 6L), nrow = 2L))
binTab(matrix(c(7L, 3L, 8L, 6L), nrow = 2L, dimnames = list(X = c('a','b'), NULL)))
binTab(~ (mag < 4.5) + (depth > 400), data = quakes)

DanielBiostatistics10th documentation built on Oct. 16, 2024, 1:08 a.m.