Skip to contents

Estimate the true sero prevalence using Bayesian estimation

Usage

correct_prevalence(
  age,
  pos = NULL,
  tot = NULL,
  status = NULL,
  init_se = 0.95,
  init_sp = 0.8,
  study_size_se = 1000,
  study_size_sp = 1000,
  chains = 1,
  warmup = 1000,
  iter = 2000
)

Arguments

age

the age vector

pos

the positive count vector (optional if status is provided).

tot

the total count vector (optional if status is provided).

status

the serostatus vector (optional if pos & tot are provided).

init_se

sensitivity of the serological test

init_sp

specificity of the serological test

study_size_se

study size for sensitivity validation study (i.e., number of confirmed infected patients in the study)

study_size_sp

study size for specificity validation study (i.e., number of confirmed non-infected patients in the study)

chains

number of Markov chains

warmup

number of warm up runs

iter

number of iterations

Value

a list of 2 items

info

estimated parameters

corrected_sero

data.frame containing age, the corresponding estimated seroprevalance, adjusted tot and pos

Examples

data <- rubella_uk_1986_1987
correct_prevalence(data$age, pos = data$pos, tot = data$tot)
#> 
#> SAMPLING FOR MODEL 'prevalence_correction' NOW (CHAIN 1).
#> Chain 1: 
#> Chain 1: Gradient evaluation took 2.5e-05 seconds
#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.25 seconds.
#> Chain 1: Adjust your expectations accordingly!
#> Chain 1: 
#> Chain 1: 
#> Chain 1: Iteration:    1 / 2000 [  0%]  (Warmup)
#> Chain 1: Iteration:  200 / 2000 [ 10%]  (Warmup)
#> Chain 1: Iteration:  400 / 2000 [ 20%]  (Warmup)
#> Chain 1: Iteration:  600 / 2000 [ 30%]  (Warmup)
#> Chain 1: Iteration:  800 / 2000 [ 40%]  (Warmup)
#> Chain 1: Iteration: 1000 / 2000 [ 50%]  (Warmup)
#> Chain 1: Iteration: 1001 / 2000 [ 50%]  (Sampling)
#> Chain 1: Iteration: 1200 / 2000 [ 60%]  (Sampling)
#> Chain 1: Iteration: 1400 / 2000 [ 70%]  (Sampling)
#> Chain 1: Iteration: 1600 / 2000 [ 80%]  (Sampling)
#> Chain 1: Iteration: 1800 / 2000 [ 90%]  (Sampling)
#> Chain 1: Iteration: 2000 / 2000 [100%]  (Sampling)
#> Chain 1: 
#> Chain 1:  Elapsed Time: 0.368 seconds (Warm-up)
#> Chain 1:                0.292 seconds (Sampling)
#> Chain 1:                0.66 seconds (Total)
#> Chain 1: 
#> $info
#>                    mean      se_mean          sd          2.5%           25%
#> est_se     9.580822e-01 0.0001677009 0.005291766  9.474431e-01  9.546114e-01
#> est_sp     8.074432e-01 0.0002727824 0.010293202  7.879326e-01  8.003633e-01
#> theta[1]   1.665906e-02 0.0004114001 0.014915046  4.470735e-04  5.027980e-03
#> theta[2]   4.446571e-02 0.0008003960 0.032307490  2.946000e-03  2.031588e-02
#> theta[3]   4.033849e-02 0.0008822391 0.029878917  1.446891e-03  1.699614e-02
#> theta[4]   1.460278e-01 0.0011752978 0.042118190  6.516402e-02  1.178951e-01
#> theta[5]   3.163587e-01 0.0010950553 0.044710676  2.282073e-01  2.868205e-01
#> theta[6]   4.461688e-01 0.0009682181 0.047028068  3.522789e-01  4.136844e-01
#> theta[7]   4.624928e-01 0.0010882358 0.051244607  3.588082e-01  4.279892e-01
#> theta[8]   6.102896e-01 0.0009369177 0.048987343  5.148583e-01  5.780589e-01
#> theta[9]   7.169041e-01 0.0009088274 0.044192481  6.267072e-01  6.853081e-01
#> theta[10]  6.441565e-01 0.0010869773 0.053649351  5.305130e-01  6.095803e-01
#> theta[11]  7.241735e-01 0.0009225447 0.047654990  6.286940e-01  6.921916e-01
#> theta[12]  8.224332e-01 0.0008361334 0.039776184  7.370909e-01  7.990787e-01
#> theta[13]  7.645448e-01 0.0009357397 0.040334238  6.831493e-01  7.396098e-01
#> theta[14]  8.602990e-01 0.0008224877 0.036694751  7.822392e-01  8.365051e-01
#> theta[15]  7.696229e-01 0.0014413184 0.066191371  6.432757e-01  7.262503e-01
#> theta[16]  8.382780e-01 0.0012817349 0.059233712  7.010630e-01  8.004274e-01
#> theta[17]  9.125376e-01 0.0012039606 0.044762969  8.175760e-01  8.871747e-01
#> theta[18]  8.767165e-01 0.0011510410 0.048709425  7.708718e-01  8.440557e-01
#> theta[19]  8.821519e-01 0.0008613922 0.039283011  8.007685e-01  8.578043e-01
#> theta[20]  8.531544e-01 0.0011158580 0.053455664  7.393866e-01  8.181030e-01
#> theta[21]  9.120147e-01 0.0010323369 0.041036862  8.237412e-01  8.865657e-01
#> theta[22]  8.269462e-01 0.0009323689 0.045833384  7.292499e-01  7.995566e-01
#> theta[23]  9.472939e-01 0.0009469101 0.035552854  8.658989e-01  9.261789e-01
#> theta[24]  9.445664e-01 0.0010044896 0.035162878  8.622421e-01  9.240897e-01
#> theta[25]  9.701647e-01 0.0006227046 0.025261812  9.113874e-01  9.566521e-01
#> theta[26]  9.391715e-01 0.0008478956 0.035030943  8.582779e-01  9.188163e-01
#> theta[27]  9.243407e-01 0.0011262384 0.039888793  8.343587e-01  8.988866e-01
#> theta[28]  9.589846e-01 0.0007236672 0.031158433  8.763660e-01  9.425749e-01
#> theta[29]  9.096108e-01 0.0013232844 0.044875733  8.113606e-01  8.835232e-01
#> theta[30]  9.165345e-01 0.0011586078 0.049047010  8.026214e-01  8.875614e-01
#> theta[31]  8.599559e-01 0.0015387598 0.065212290  7.144827e-01  8.214934e-01
#> theta[32]  9.372633e-01 0.0012014984 0.046203975  8.242861e-01  9.098596e-01
#> theta[33]  9.359540e-01 0.0010341964 0.049270000  8.184358e-01  9.097596e-01
#> theta[34]  9.439138e-01 0.0011298579 0.043857617  8.416949e-01  9.201564e-01
#> theta[35]  8.949250e-01 0.0014343679 0.065221257  7.350569e-01  8.560160e-01
#> theta[36]  9.570296e-01 0.0009469318 0.038216763  8.531427e-01  9.414531e-01
#> theta[37]  9.424748e-01 0.0009861636 0.046008427  8.347117e-01  9.172013e-01
#> theta[38]  9.016027e-01 0.0015786867 0.058449543  7.616728e-01  8.681172e-01
#> theta[39]  9.198288e-01 0.0014622409 0.062854455  7.592456e-01  8.878378e-01
#> theta[40]  9.382487e-01 0.0013360424 0.052923971  8.031185e-01  9.123606e-01
#> theta[41]  9.524841e-01 0.0012642555 0.046850860  8.344275e-01  9.334619e-01
#> theta[42]  9.203959e-01 0.0014741926 0.064005751  7.538865e-01  8.870096e-01
#> theta[43]  9.054694e-01 0.0018592371 0.079995055  7.053635e-01  8.640245e-01
#> theta[44]  9.398381e-01 0.0015168301 0.059400498  7.935919e-01  9.152837e-01
#> lp__      -2.762763e+03 0.3723095862 5.980963874 -2.775599e+03 -2.766236e+03
#>                     50%           75%         97.5%     n_eff      Rhat
#> est_se     9.582065e-01  9.617356e-01  9.674997e-01  995.7041 0.9990116
#> est_sp     8.075349e-01  8.141697e-01  8.293521e-01 1423.8631 0.9990033
#> theta[1]   1.319507e-02  2.347917e-02  5.530626e-02 1314.3784 0.9993005
#> theta[2]   3.760763e-02  6.107277e-02  1.243571e-01 1629.2836 0.9992908
#> theta[3]   3.377140e-02  5.937305e-02  1.092119e-01 1146.9833 1.0000724
#> theta[4]   1.448780e-01  1.750683e-01  2.260392e-01 1284.2322 0.9991804
#> theta[5]   3.164987e-01  3.465573e-01  4.008304e-01 1667.0568 0.9990138
#> theta[6]   4.475848e-01  4.790213e-01  5.362937e-01 2359.2168 0.9990800
#> theta[7]   4.654187e-01  4.961354e-01  5.609067e-01 2217.4320 0.9998677
#> theta[8]   6.087411e-01  6.444279e-01  7.048676e-01 2733.7885 1.0006807
#> theta[9]   7.167308e-01  7.481016e-01  8.007058e-01 2364.4707 0.9993092
#> theta[10]  6.454541e-01  6.802877e-01  7.441940e-01 2436.0601 0.9991624
#> theta[11]  7.243507e-01  7.582121e-01  8.108004e-01 2668.3444 1.0000274
#> theta[12]  8.236176e-01  8.482542e-01  8.975830e-01 2263.0551 0.9990002
#> theta[13]  7.654113e-01  7.909668e-01  8.378039e-01 1857.9655 1.0012950
#> theta[14]  8.624993e-01  8.856324e-01  9.265868e-01 1990.4399 0.9992797
#> theta[15]  7.723260e-01  8.176870e-01  8.900496e-01 2109.0306 1.0012365
#> theta[16]  8.418818e-01  8.785714e-01  9.423628e-01 2135.7060 0.9990384
#> theta[17]  9.160096e-01  9.455393e-01  9.854278e-01 1382.3348 0.9990387
#> theta[18]  8.803974e-01  9.123397e-01  9.569319e-01 1790.7890 0.9990391
#> theta[19]  8.835304e-01  9.095966e-01  9.545395e-01 2079.7337 0.9991114
#> theta[20]  8.574111e-01  8.910876e-01  9.459229e-01 2294.9309 0.9994774
#> theta[21]  9.158318e-01  9.412503e-01  9.795411e-01 1580.1758 0.9990402
#> theta[22]  8.307917e-01  8.579621e-01  9.098851e-01 2416.5084 0.9990325
#> theta[23]  9.539527e-01  9.741822e-01  9.971524e-01 1409.7155 0.9991723
#> theta[24]  9.500680e-01  9.705381e-01  9.959156e-01 1225.4001 0.9993520
#> theta[25]  9.767115e-01  9.889895e-01  9.989495e-01 1645.7539 1.0002200
#> theta[26]  9.415557e-01  9.646443e-01  9.921506e-01 1706.9424 0.9995324
#> theta[27]  9.300208e-01  9.524267e-01  9.894799e-01 1254.4148 0.9991461
#> theta[28]  9.649456e-01  9.825285e-01  9.980265e-01 1853.8449 0.9995199
#> theta[29]  9.134935e-01  9.411331e-01  9.853984e-01 1150.0500 0.9991689
#> theta[30]  9.219956e-01  9.529422e-01  9.909736e-01 1792.0586 0.9997941
#> theta[31]  8.666501e-01  9.089361e-01  9.660925e-01 1796.0451 0.9994872
#> theta[32]  9.475452e-01  9.737303e-01  9.967317e-01 1478.8096 0.9990261
#> theta[33]  9.448753e-01  9.755974e-01  9.971338e-01 2269.6511 0.9995909
#> theta[34]  9.551519e-01  9.766556e-01  9.968077e-01 1506.7542 0.9996925
#> theta[35]  9.046023e-01  9.430230e-01  9.903739e-01 2067.5556 0.9990049
#> theta[36]  9.657940e-01  9.860136e-01  9.984955e-01 1628.8100 0.9990131
#> theta[37]  9.526012e-01  9.778939e-01  9.981827e-01 2176.5909 1.0000563
#> theta[38]  9.093435e-01  9.444921e-01  9.894880e-01 1370.7882 0.9989998
#> theta[39]  9.338862e-01  9.695528e-01  9.964630e-01 1847.7119 0.9991342
#> theta[40]  9.518235e-01  9.790494e-01  9.983187e-01 1569.1496 0.9990092
#> theta[41]  9.667780e-01  9.858340e-01  9.982205e-01 1373.3000 0.9993270
#> theta[42]  9.367858e-01  9.669280e-01  9.959764e-01 1885.0789 0.9990012
#> theta[43]  9.266005e-01  9.652812e-01  9.974887e-01 1851.2145 0.9990077
#> theta[44]  9.577977e-01  9.831545e-01  9.989427e-01 1533.5795 0.9990006
#> lp__      -2.762367e+03 -2.758555e+03 -2.752517e+03  258.0679 1.0044855
#> 
#> $corrected_se
#>            age       sero        pos tot
#> theta[1]   1.5 0.01665906   3.431767 206
#> theta[2]   2.5 0.04446571   6.491993 146
#> theta[3]   3.5 0.04033849   6.776867 168
#> theta[4]   4.5 0.14602776  27.599246 189
#> theta[5]   5.5 0.31635871  69.282557 219
#> theta[6]   6.5 0.44616879  87.002913 195
#> theta[7]   7.5 0.46249280  75.848818 164
#> theta[8]   8.5 0.61028960  88.491992 145
#> theta[9]   9.5 0.71690405 129.042729 180
#> theta[10] 10.5 0.64415648 103.065037 160
#> theta[11] 11.5 0.72417345 107.177671 148
#> theta[12] 12.5 0.82243321 146.393111 178
#> theta[13] 13.5 0.76454476 135.324422 177
#> theta[14] 14.5 0.86029897 141.949330 165
#> theta[15] 15.5 0.76962286  51.564732  67
#> theta[16] 16.5 0.83827804  48.620126  58
#> theta[17] 17.5 0.91253760  73.915546  81
#> theta[18] 18.5 0.87671652  69.260605  79
#> theta[19] 19.5 0.88215195  97.918866 111
#> theta[20] 20.5 0.85315445  64.839738  76
#> theta[21] 21.5 0.91201471  74.785206  82
#> theta[22] 22.5 0.82694622  83.521568 101
#> theta[23] 23.5 0.94729391  83.361864  88
#> theta[24] 24.5 0.94456641  80.288145  85
#> theta[25] 25.5 0.97016474  91.195486  94
#> theta[26] 26.5 0.93917148  85.464604  91
#> theta[27] 27.5 0.92434068  82.266320  89
#> theta[28] 28.5 0.95898458  72.882828  76
#> theta[29] 29.5 0.90961080  71.859253  79
#> theta[30] 30.5 0.91653450  51.325932  56
#> theta[31] 31.5 0.85995587  44.717705  52
#> theta[32] 32.5 0.93726332  44.988639  48
#> theta[33] 33.5 0.93595396  34.630297  37
#> theta[34] 34.5 0.94391377  38.700464  41
#> theta[35] 35.5 0.89492502  35.797001  40
#> theta[36] 36.5 0.95702955  36.367123  38
#> theta[37] 37.5 0.94247483  36.756518  39
#> theta[38] 38.5 0.90160269  36.965710  41
#> theta[39] 39.5 0.91982884  27.594865  30
#> theta[40] 40.5 0.93824871  25.332715  27
#> theta[41] 41.5 0.95248410  23.812102  25
#> theta[42] 42.5 0.92039595  20.248711  22
#> theta[43] 43.5 0.90546939  17.203918  19
#> theta[44] 44.5 0.93983807  16.917085  18
#>