Skip to contents

Long representation of results from two binary diagnostic tests.

Usage

represent.long(d, y1, y2)

Arguments

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).

Details

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.

Value

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).

See also

Examples

data(Paired1) # Hypothetical study data
names(Paired1)
#> [1] "d"  "y1" "y2"
new.long <- represent.long(d=Paired1$d, y1=Paired1$y1, y2=Paired1$y2)
str(new.long)
#> 'data.frame':	1424 obs. of  4 variables:
#>  $ id: int  1 1 2 2 3 3 4 4 5 5 ...
#>  $ d : num  1 1 1 1 1 1 1 1 1 1 ...
#>  $ x : num  1 0 1 0 1 0 1 0 1 0 ...
#>  $ y : num  1 1 1 1 1 1 1 1 1 1 ...
head(new.long)
#>   id d x y
#> 1  1 1 1 1
#> 2  1 1 0 1
#> 3  2 1 1 1
#> 4  2 1 0 1
#> 5  3 1 1 1
#> 6  3 1 0 1