Construct a group membership matrix for two-, three-, or four-stage hierarchical algorithms.

GroupMembershipMatrix(stage1, stage2 = NULL, stage3 = NULL, stage4 = NULL)

Arguments

stage1

the group size in stage one of testing. This also corresponds to the number of individuals to be tested and will specify the number of columns in the resulting group membership matrix.

stage2

a vector of group sizes in stage two of testing. The group sizes specified here should sum to the number of individuals/group size specified in stage1. If NULL, a group membership matrix will be constructed for a two-stage hierarchical algorithm. Further details are given under 'Details'.

stage3

a vector of group sizes in stage three of testing. The group sizes specified here should sum to the number of individuals/group size specified in stage1. If group sizes are provided in stage2 and stage3 is NULL, a group membership matrix will be constructed for a three-stage hierarchical algorithm. Further details are given under 'Details'.

stage4

a vector of group sizes in stage four of testing. The group sizes specified here should sum to the number of individuals/group size specified in stage1. If group sizes are provided in stage3 and stage4 is NULL, a group membership matrix will be constructed for a four-stage hierarchical algorithm. Further details are given under 'Details'.

Value

A matrix specifying the group membership for each individual. The rows of the matrix correspond to the stages of testing and the columns of the matrix correspond to the individuals to be tested.

Details

This function constructs a group membership matrix for two-, three-, four-, or five-stage hierarchical algorithms. The resulting group membership matrix has rows corresponding to the number of stages of testing and columns corresponding to each individual to be tested. The value specified in stage1 corresponds to the number of individuals to be tested.

For group membership matrices when only stage1 is specified, a two-stage hierarchical algorithm is used and the second stage will consist of individual testing. For group membership matrices when stage1 and stage2 are specified, a three-stage hierarchical algorithm is used and the third stage will consist of individual testing. Group membership matrices for four- and five-stage hierarchical algorithms follow a similar structure. There should never be group sizes specified for later stages of testing without also providing group sizes for all earlier stages of testing (i.e., to provide group sizes for stage3, group sizes must also be provided for stage1 and stage2).

See also

Other operating characteristic functions: Sterrett(), TOD(), halving(), operatingCharacteristics1(), operatingCharacteristics2()

Author

Minh Nguyen and Christopher Bilder

Examples

# Generate a group membership matrix for a two-stage
#   hierarchical algorithm, within the opChar1() function
#   and calculate operating characteristics
opChar1(algorithm = "D2", p = 0.0193, Se = 0.99, Sp = 0.99,
        hier.config = GroupMembershipMatrix(stage1 = 16),
        print.time = FALSE)
#> 
#> Algorithm: Non-informative two-stage hierarchical testing 
#> 
#> Testing configuration: 
#>   Stage1
#> 1     16
#> 
#> Expected number of tests: 5.3605
#> Expected number of tests per individual: 0.3350
#> 
#> Accuracy for individuals:
#>      PSe    PSp   PPPV   PNPV Individuals
#> 1 0.9801 0.9974 0.8819 0.9996         All
#> 
#> Overall accuracy of the algorithm:
#>      PSe    PSp   PPPV   PNPV
#> 1 0.9801 0.9974 0.8819 0.9996

# Generate a group membership matrix for a five-stage
#   hierarchical algorithm and calculate the
#   operating characteristics for a two-disease assay
config.mat <- GroupMembershipMatrix(stage1 = 16,
                                    stage2 = c(8,8),
                                    stage3 = c(4,4,4,4),
                                    stage4 = rep(2, times = 8))
Se <- matrix(data = rep(0.95, 10), nrow = 2, ncol = 5,
             dimnames = list(Infection = 1:2, Stage = 1:5))
Sp <- matrix(data = rep(0.99, 10), nrow = 2, ncol = 5,
             dimnames = list(Infection = 1:2, Stage = 1:5))
opChar2(algorithm = "D5", p.vec = c(0.92, 0.05, 0.02, 0.01),
        Se = Se, Sp = Sp, hier.config = config.mat)
#> 
#>  Number of minutes running:  0 
#>  
#> 
#> Algorithm: Non-informative five-stage hierarchical testing 
#> 
#> Testing configuration: 
#>   Stage1 Stage2  Stage3          Stage4
#> 1     16    8,8 4,4,4,4 2,2,2,2,2,2,2,2
#> 
#> Expected number of tests: 8.5165
#> Expected number of tests per individual: 0.5323
#> 
#> Disease 1 accuracy for individuals:
#>      PSe    PSp   PPPV   PNPV Individuals
#> 1 0.8253 0.9991 0.9835 0.9890         All
#> 
#> Disease 2 accuracy for individuals:
#>      PSe    PSp   PPPV   PNPV Individuals
#> 1 0.8619 0.9989 0.9599 0.9957         All
#> 
#> Overall accuracy of the algorithm:
#>      PSe    PSp   PPPV   PNPV
#> 1 0.8253 0.9991 0.9835 0.9890
#> 2 0.8619 0.9989 0.9599 0.9957