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 0.000251 seconds
#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 2.51 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: 1.796 seconds (Warm-up)
#> Chain 1:                1.343 seconds (Sampling)
#> Chain 1:                3.139 seconds (Total)
#> Chain 1: 
#> $info
#>                    mean      se_mean          sd          2.5%           25%
#> est_se     9.581929e-01 0.0001609135 0.005230293  9.479660e-01  9.547228e-01
#> est_sp     8.069757e-01 0.0002828964 0.011044871  7.854039e-01  7.996085e-01
#> theta[1]   1.706464e-02 0.0003758854 0.014989311  3.690544e-04  5.921739e-03
#> theta[2]   4.384368e-02 0.0009200557 0.031159439  2.121645e-03  2.001407e-02
#> theta[3]   3.850694e-02 0.0008826740 0.029991391  1.972698e-03  1.513077e-02
#> theta[4]   1.431935e-01 0.0012414607 0.045817055  5.786349e-02  1.125689e-01
#> theta[5]   3.165637e-01 0.0012872042 0.045617903  2.288035e-01  2.846881e-01
#> theta[6]   4.444701e-01 0.0009451693 0.045250540  3.599190e-01  4.125157e-01
#> theta[7]   4.626891e-01 0.0013201546 0.048348387  3.614287e-01  4.320284e-01
#> theta[8]   6.106122e-01 0.0011822001 0.050639289  5.022235e-01  5.767448e-01
#> theta[9]   7.175997e-01 0.0011008843 0.044719614  6.230635e-01  6.873996e-01
#> theta[10]  6.419766e-01 0.0012393796 0.048736983  5.461536e-01  6.081532e-01
#> theta[11]  7.220485e-01 0.0012029224 0.047430010  6.271027e-01  6.869883e-01
#> theta[12]  8.227953e-01 0.0009076172 0.036852851  7.482824e-01  7.975976e-01
#> theta[13]  7.627398e-01 0.0010626785 0.041669972  6.753443e-01  7.362022e-01
#> theta[14]  8.587556e-01 0.0007333958 0.037123956  7.792670e-01  8.357116e-01
#> theta[15]  7.731065e-01 0.0016930107 0.063281557  6.296218e-01  7.332235e-01
#> theta[16]  8.355733e-01 0.0014522080 0.061611408  7.059238e-01  7.936201e-01
#> theta[17]  9.129714e-01 0.0011670213 0.043390142  8.209613e-01  8.833520e-01
#> theta[18]  8.774053e-01 0.0012095021 0.049055119  7.736844e-01  8.467484e-01
#> theta[19]  8.809649e-01 0.0010927956 0.039403502  7.980845e-01  8.579858e-01
#> theta[20]  8.529601e-01 0.0016385553 0.057174064  7.312159e-01  8.165787e-01
#> theta[21]  9.138139e-01 0.0012630170 0.041859407  8.244294e-01  8.863258e-01
#> theta[22]  8.259165e-01 0.0011436089 0.045601968  7.285091e-01  7.944683e-01
#> theta[23]  9.467582e-01 0.0009523828 0.032369969  8.707946e-01  9.287364e-01
#> theta[24]  9.445504e-01 0.0011926430 0.037324845  8.608275e-01  9.213222e-01
#> theta[25]  9.711767e-01 0.0006479416 0.023911199  9.087006e-01  9.593204e-01
#> theta[26]  9.389326e-01 0.0010738197 0.035526856  8.598293e-01  9.175298e-01
#> theta[27]  9.225048e-01 0.0011609875 0.037619498  8.388538e-01  8.993849e-01
#> theta[28]  9.572464e-01 0.0007611328 0.031613624  8.734294e-01  9.417387e-01
#> theta[29]  9.094723e-01 0.0012455871 0.045441053  8.093298e-01  8.818336e-01
#> theta[30]  9.172450e-01 0.0015495416 0.049401780  8.019122e-01  8.886713e-01
#> theta[31]  8.592529e-01 0.0015215384 0.059760216  7.247602e-01  8.216484e-01
#> theta[32]  9.402675e-01 0.0012045051 0.047141758  8.193893e-01  9.149402e-01
#> theta[33]  9.380364e-01 0.0012494314 0.049443567  8.147240e-01  9.118179e-01
#> theta[34]  9.459028e-01 0.0012373057 0.043407912  8.408670e-01  9.244129e-01
#> theta[35]  8.926621e-01 0.0014595882 0.069482239  7.300403e-01  8.516782e-01
#> theta[36]  9.566368e-01 0.0009100621 0.037218304  8.524151e-01  9.398737e-01
#> theta[37]  9.402055e-01 0.0012889185 0.049025151  8.190774e-01  9.158457e-01
#> theta[38]  8.972827e-01 0.0016245163 0.061436648  7.584656e-01  8.581675e-01
#> theta[39]  9.211567e-01 0.0016407994 0.058707430  7.744334e-01  8.893928e-01
#> theta[40]  9.356209e-01 0.0014752568 0.054909867  7.951714e-01  9.050129e-01
#> theta[41]  9.533126e-01 0.0010332280 0.045038095  8.376966e-01  9.334340e-01
#> theta[42]  9.198561e-01 0.0017652536 0.060365376  7.740165e-01  8.866775e-01
#> theta[43]  9.078516e-01 0.0017433479 0.067439029  7.451051e-01  8.692745e-01
#> theta[44]  9.380297e-01 0.0015528750 0.063675966  7.669778e-01  9.133157e-01
#> lp__      -2.762598e+03 0.2749034942 5.360660152 -2.774227e+03 -2.766007e+03
#>                     50%           75%         97.5%     n_eff      Rhat
#> est_se     9.584447e-01  9.619761e-01  9.678106e-01 1056.4936 0.9991695
#> est_sp     8.071410e-01  8.149658e-01  8.271894e-01 1524.2856 0.9991034
#> theta[1]   1.352593e-02  2.376979e-02  5.650053e-02 1590.2027 0.9991373
#> theta[2]   3.755705e-02  6.215776e-02  1.134722e-01 1146.9674 0.9996657
#> theta[3]   3.145086e-02  5.565008e-02  1.094077e-01 1154.4965 0.9992727
#> theta[4]   1.417909e-01  1.728511e-01  2.383082e-01 1362.0354 0.9993613
#> theta[5]   3.164776e-01  3.466235e-01  4.045569e-01 1255.9597 1.0003572
#> theta[6]   4.445659e-01  4.749955e-01  5.303761e-01 2292.0723 1.0010897
#> theta[7]   4.620885e-01  4.952945e-01  5.543290e-01 1341.2644 0.9997882
#> theta[8]   6.118090e-01  6.456523e-01  7.084200e-01 1834.8188 0.9993449
#> theta[9]   7.198536e-01  7.483989e-01  7.985096e-01 1650.1096 0.9995444
#> theta[10]  6.432274e-01  6.749764e-01  7.378660e-01 1546.3529 0.9990159
#> theta[11]  7.255408e-01  7.561061e-01  8.119058e-01 1554.6448 0.9990106
#> theta[12]  8.249793e-01  8.473920e-01  8.917033e-01 1648.6814 0.9990383
#> theta[13]  7.645160e-01  7.923548e-01  8.382969e-01 1537.5972 1.0000083
#> theta[14]  8.590567e-01  8.849603e-01  9.248671e-01 2562.3100 0.9999734
#> theta[15]  7.756140e-01  8.165988e-01  8.883877e-01 1397.1238 0.9999912
#> theta[16]  8.413271e-01  8.815836e-01  9.387800e-01 1799.9673 0.9990116
#> theta[17]  9.171108e-01  9.465813e-01  9.850605e-01 1382.3708 1.0025188
#> theta[18]  8.811083e-01  9.135804e-01  9.610183e-01 1644.9601 0.9997443
#> theta[19]  8.837311e-01  9.088757e-01  9.482833e-01 1300.1449 0.9995279
#> theta[20]  8.556595e-01  8.959927e-01  9.531399e-01 1217.5194 1.0001435
#> theta[21]  9.187279e-01  9.435835e-01  9.833824e-01 1098.4182 0.9993065
#> theta[22]  8.277229e-01  8.569425e-01  9.096893e-01 1590.0549 0.9990819
#> theta[23]  9.507876e-01  9.707137e-01  9.942870e-01 1155.2115 1.0018554
#> theta[24]  9.493524e-01  9.729901e-01  9.976023e-01  979.4339 0.9990053
#> theta[25]  9.769145e-01  9.884179e-01  9.991942e-01 1361.8555 1.0003647
#> theta[26]  9.432770e-01  9.652616e-01  9.929998e-01 1094.5883 0.9994120
#> theta[27]  9.254389e-01  9.486743e-01  9.859532e-01 1049.9555 0.9990119
#> theta[28]  9.627506e-01  9.808278e-01  9.982050e-01 1725.1534 1.0001250
#> theta[29]  9.124451e-01  9.432541e-01  9.840203e-01 1330.9098 0.9990845
#> theta[30]  9.235671e-01  9.524745e-01  9.913246e-01 1016.4329 0.9990045
#> theta[31]  8.668765e-01  9.022011e-01  9.551086e-01 1542.6183 0.9991644
#> theta[32]  9.497947e-01  9.767184e-01  9.970982e-01 1531.7726 1.0000293
#> theta[33]  9.500388e-01  9.752579e-01  9.980635e-01 1566.0108 0.9998868
#> theta[34]  9.559917e-01  9.783305e-01  9.969428e-01 1230.7894 0.9990017
#> theta[35]  9.048680e-01  9.455510e-01  9.909934e-01 2266.1410 0.9990055
#> theta[36]  9.677596e-01  9.849612e-01  9.981735e-01 1672.5193 0.9994178
#> theta[37]  9.515684e-01  9.783618e-01  9.979456e-01 1446.7284 0.9998791
#> theta[38]  9.082948e-01  9.460790e-01  9.867077e-01 1430.2333 0.9990185
#> theta[39]  9.329785e-01  9.659220e-01  9.960304e-01 1280.1922 0.9990404
#> theta[40]  9.526373e-01  9.780353e-01  9.973468e-01 1385.3693 0.9990002
#> theta[41]  9.669428e-01  9.871043e-01  9.986769e-01 1900.0616 0.9992308
#> theta[42]  9.334860e-01  9.675611e-01  9.962890e-01 1169.3961 0.9993389
#> theta[43]  9.246035e-01  9.588806e-01  9.940502e-01 1496.4234 0.9989997
#> theta[44]  9.580634e-01  9.846834e-01  9.988281e-01 1681.4273 0.9991492
#> lp__      -2.762095e+03 -2.758919e+03 -2.753363e+03  380.2560 0.9997653
#> 
#> $corrected_se
#>            age       sero        pos tot
#> theta[1]   1.5 0.01706464   3.515315 206
#> theta[2]   2.5 0.04384368   6.401178 146
#> theta[3]   3.5 0.03850694   6.469165 168
#> theta[4]   4.5 0.14319346  27.063563 189
#> theta[5]   5.5 0.31656368  69.327445 219
#> theta[6]   6.5 0.44447008  86.671666 195
#> theta[7]   7.5 0.46268911  75.881014 164
#> theta[8]   8.5 0.61061222  88.538772 145
#> theta[9]   9.5 0.71759969 129.167944 180
#> theta[10] 10.5 0.64197659 102.716254 160
#> theta[11] 11.5 0.72204847 106.863174 148
#> theta[12] 12.5 0.82279530 146.457563 178
#> theta[13] 13.5 0.76273979 135.004942 177
#> theta[14] 14.5 0.85875564 141.694681 165
#> theta[15] 15.5 0.77310653  51.798138  67
#> theta[16] 16.5 0.83557326  48.463249  58
#> theta[17] 17.5 0.91297138  73.950682  81
#> theta[18] 18.5 0.87740525  69.315015  79
#> theta[19] 19.5 0.88096489  97.787103 111
#> theta[20] 20.5 0.85296012  64.824969  76
#> theta[21] 21.5 0.91381393  74.932742  82
#> theta[22] 22.5 0.82591646  83.417563 101
#> theta[23] 23.5 0.94675817  83.314719  88
#> theta[24] 24.5 0.94455038  80.286783  85
#> theta[25] 25.5 0.97117667  91.290607  94
#> theta[26] 26.5 0.93893261  85.442867  91
#> theta[27] 27.5 0.92250475  82.102923  89
#> theta[28] 28.5 0.95724644  72.750729  76
#> theta[29] 29.5 0.90947233  71.848314  79
#> theta[30] 30.5 0.91724503  51.365722  56
#> theta[31] 31.5 0.85925291  44.681151  52
#> theta[32] 32.5 0.94026753  45.132841  48
#> theta[33] 33.5 0.93803638  34.707346  37
#> theta[34] 34.5 0.94590280  38.782015  41
#> theta[35] 35.5 0.89266213  35.706485  40
#> theta[36] 36.5 0.95663683  36.352200  38
#> theta[37] 37.5 0.94020554  36.668016  39
#> theta[38] 38.5 0.89728275  36.788593  41
#> theta[39] 39.5 0.92115665  27.634700  30
#> theta[40] 40.5 0.93562086  25.261763  27
#> theta[41] 41.5 0.95331258  23.832814  25
#> theta[42] 42.5 0.91985610  20.236834  22
#> theta[43] 43.5 0.90785161  17.249181  19
#> theta[44] 44.5 0.93802974  16.884535  18
#>