Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

sim.mp

Simulation Function for Group Testing Data with Matrix Pooling Design


Description

Simulates data in group testing form ready to be fit by gtreg.mp.

Usage

sim.mp(x = NULL, gshape = 20, gscale = 2, par,
    linkf = c("logit", "probit", "cloglog"),
    n.row, n.col, sens = 1, spec = 1,
    sens.ind = NULL, spec.ind = NULL)

Arguments

x

a matrix of user-submitted covariates to simulate the data with, defaults to NULL in which case a gamma distribution is used to generate the covariates automatically.

gshape

shape parameter of gamma distribution, must be non-negative, set to be 20 by default

gscale

scale parameter of gamma distribution, must be strictly positive, set to be 2 by default

par

the true coefficients in the linear predictor

linkf

a character string specifying one of the three link functions to be used: "logit" (default) or "probit" or "cloglog"

n.row

a vector that specifies the number of rows in each matrix, a scalar if only one matrix is simulated

n.col

a vector that specifies the number of columns in each matrix, a scalar if only one matrix is simulated

sens

sensitivity of the group tests, set to be 1 by default.

spec

specificity of the group tests, set to be 1 by default.

sens.ind

sensitivity of the individual retests, set to be equal to sens if not specified otherwise.

spec.ind

specificity of the individual retests, set to be equal to spec if not specified otherwise.

Details

sim.mp generates group testing data in matrix pooling form. The covariates are either specified by the x argument or they are generated from a gamma distribution with a given gshape and gscale. The individual probabilities are calculated from the covariates, the coefficients given in par and the link function specified through linkf. The true binary individual responses are then simulated from the individual probabilities. The individuals are organized into (by column) one or more matrices specified by n.row and n.col, and the true group responses are found (i.e., if at least one response is positive, the group is positive; otherwise, the group response is negative). The observed row and column group responses are then simulated using the given sens and spec values. Individual retests are simulated from sens.ind and spec.ind for individuals that lie on the intersection of an observed positive row and an observed positive column. In the case where no column (row) tests positive in a matrix, all the individuals in any observed positive rows (columns) will be assigned a simulated retest result. If no column or row is observed positive, NULL is returned.

Value

sim.mp returns a list with the components dframe: the data frame that is actually to be fit, ind: the true individual responses presented in matrices and prob: the individual probabilities.

dframe is a data frame with columns

col.resp

the column group response

row.resp

the row group response

x

the covariate

arrayn

the array number

coln

the column group number

rown

the row group number

retest

the results of individual retests

Author(s)

Boan Zhang

See Also

gtreg.mp for the corresponding function to fit the model.

Examples

# 5*6 and 4*5 matrix
set.seed(9128)
sa1a<-sim.mp(par=c(-7,0.1), n.row=c(5,4), n.col=c(6,5),
 sens=0.95, spec=0.95)
sa1<-sa1a$dframe

binGroup

Evaluation and Experimental Design for Binomial Group Testing

v2.2-1
GPL (>= 3)
Authors
Boan Zhang [aut], Christopher Bilder [aut], Brad Biggerstaff [aut], Frank Schaarschmidt [aut, cre], Brianna Hitt [aut]
Initial release
2018-08-24

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.