Generates prior testing data for positive subjects based on a prior testing distribution and prior testing probability

simPriorTests(ptest.dist, ptest.prob, ptest.dist2 = NULL)

Arguments

ptest.dist

A prior test result distribution function, which must have be a function of u which is an infection duration though it can ignore the u argument inside the function. An example is rnorm(1, mean=u).

ptest.prob

Probability of prior test result being available. Can instead be a function of u, the infection duration.

Examples

set.seed(101)
phi.func <- getTestRecentFunc(window=200, shadow=191)
sim <- simCrossSect(phi.func=phi.func,
                    incidence_type="linear", prevalence=0.29, baseline_incidence=0.032, rho=0.07)
df <- sim(100)
sim.pt <- simPriorTests(ptest.dist=function(u) runif(1, 0, 4),
                        ptest.prob=function(u) 0.5)
sim.pt(df[df$di == 1,])
#>     di        ui ri         ti qi deltai
#> 68   1 0.8343517  0         NA  0     NA
#> 69   1 0.2365448  1 3.61348548  1      0
#> 70   1 1.7296376  0 0.16764423  1      1
#> 71   1 2.7429372  0         NA  0     NA
#> 72   1 2.4740613  0         NA  0     NA
#> 73   1 1.5848479  0 3.93215902  1      0
#> 74   1 0.6184199  1         NA  0     NA
#> 75   1 0.3450447  0 2.97136426  1      0
#> 76   1 2.5811036  0         NA  0     NA
#> 77   1 2.9811139  0 3.95352061  1      0
#> 78   1 0.9283701  0         NA  0     NA
#> 79   1 0.3638139  0         NA  0     NA
#> 80   1 2.1525414  0 3.75893825  1      0
#> 81   1 2.7953630  0 2.68650793  1      1
#> 82   1 2.7631551  0         NA  0     NA
#> 83   1 2.9584120  0         NA  0     NA
#> 84   1 2.7794670  0 1.94533154  1      1
#> 85   1 2.0258751  0         NA  0     NA
#> 86   1 1.5704534  0 1.43617887  1      1
#> 87   1 2.2570080  0 0.03437442  1      1
#> 88   1 1.7446538  0         NA  0     NA
#> 89   1 0.9000694  0         NA  0     NA
#> 90   1 0.6068312  0         NA  0     NA
#> 91   1 2.1177505  0         NA  0     NA
#> 92   1 1.3458309  0         NA  0     NA
#> 93   1 2.6503013  0         NA  0     NA
#> 94   1 2.1053662  0         NA  0     NA
#> 95   1 1.9400066  0 1.07838110  1      1
#> 96   1 2.3632234  0         NA  0     NA
#> 97   1 0.6762937  1 1.67148722  1      0
#> 98   1 2.3358911  0 2.76226260  1      0
#> 99   1 1.6663302  0         NA  0     NA
#> 100  1 1.2970956  1         NA  0     NA