Using jointlyr

library(jointlyr)

Set up data

Incidence

incid <- c(45, 28, 91, 36, 43, 50, 77, 54, 44, 45)

Serial Interval Distribution

si_trunc <- 20
si_distr <- EpiEstim::discr_si(seq(0, si_trunc), 6.48, 3.83)
si_distr <- si_distr / sum(si_distr)
## Default args for iter and chains
jointlyr::jointly_estimate(10, 100, incid, si_distr)
#> 
#> SAMPLING FOR MODEL 'rti0_bayesian' NOW (CHAIN 1).
#> Chain 1: 
#> Chain 1: Gradient evaluation took 4.9e-05 seconds
#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.49 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.579 seconds (Warm-up)
#> Chain 1:                0.741 seconds (Sampling)
#> Chain 1:                1.32 seconds (Total)
#> Chain 1: 
#> 
#> SAMPLING FOR MODEL 'rti0_bayesian' NOW (CHAIN 2).
#> Chain 2: 
#> Chain 2: Gradient evaluation took 1.9e-05 seconds
#> Chain 2: 1000 transitions using 10 leapfrog steps per transition would take 0.19 seconds.
#> Chain 2: Adjust your expectations accordingly!
#> Chain 2: 
#> Chain 2: 
#> Chain 2: Iteration:    1 / 2000 [  0%]  (Warmup)
#> Chain 2: Iteration:  200 / 2000 [ 10%]  (Warmup)
#> Chain 2: Iteration:  400 / 2000 [ 20%]  (Warmup)
#> Chain 2: Iteration:  600 / 2000 [ 30%]  (Warmup)
#> Chain 2: Iteration:  800 / 2000 [ 40%]  (Warmup)
#> Chain 2: Iteration: 1000 / 2000 [ 50%]  (Warmup)
#> Chain 2: Iteration: 1001 / 2000 [ 50%]  (Sampling)
#> Chain 2: Iteration: 1200 / 2000 [ 60%]  (Sampling)
#> Chain 2: Iteration: 1400 / 2000 [ 70%]  (Sampling)
#> Chain 2: Iteration: 1600 / 2000 [ 80%]  (Sampling)
#> Chain 2: Iteration: 1800 / 2000 [ 90%]  (Sampling)
#> Chain 2: Iteration: 2000 / 2000 [100%]  (Sampling)
#> Chain 2: 
#> Chain 2:  Elapsed Time: 0.645 seconds (Warm-up)
#> Chain 2:                0.622 seconds (Sampling)
#> Chain 2:                1.267 seconds (Total)
#> Chain 2: 
#> 
#> SAMPLING FOR MODEL 'rti0_bayesian' NOW (CHAIN 3).
#> Chain 3: 
#> Chain 3: Gradient evaluation took 1.9e-05 seconds
#> Chain 3: 1000 transitions using 10 leapfrog steps per transition would take 0.19 seconds.
#> Chain 3: Adjust your expectations accordingly!
#> Chain 3: 
#> Chain 3: 
#> Chain 3: Iteration:    1 / 2000 [  0%]  (Warmup)
#> Chain 3: Iteration:  200 / 2000 [ 10%]  (Warmup)
#> Chain 3: Iteration:  400 / 2000 [ 20%]  (Warmup)
#> Chain 3: Iteration:  600 / 2000 [ 30%]  (Warmup)
#> Chain 3: Iteration:  800 / 2000 [ 40%]  (Warmup)
#> Chain 3: Iteration: 1000 / 2000 [ 50%]  (Warmup)
#> Chain 3: Iteration: 1001 / 2000 [ 50%]  (Sampling)
#> Chain 3: Iteration: 1200 / 2000 [ 60%]  (Sampling)
#> Chain 3: Iteration: 1400 / 2000 [ 70%]  (Sampling)
#> Chain 3: Iteration: 1600 / 2000 [ 80%]  (Sampling)
#> Chain 3: Iteration: 1800 / 2000 [ 90%]  (Sampling)
#> Chain 3: Iteration: 2000 / 2000 [100%]  (Sampling)
#> Chain 3: 
#> Chain 3:  Elapsed Time: 0.536 seconds (Warm-up)
#> Chain 3:                0.665 seconds (Sampling)
#> Chain 3:                1.201 seconds (Total)
#> Chain 3: 
#> 
#> SAMPLING FOR MODEL 'rti0_bayesian' NOW (CHAIN 4).
#> Chain 4: 
#> Chain 4: Gradient evaluation took 1.9e-05 seconds
#> Chain 4: 1000 transitions using 10 leapfrog steps per transition would take 0.19 seconds.
#> Chain 4: Adjust your expectations accordingly!
#> Chain 4: 
#> Chain 4: 
#> Chain 4: Iteration:    1 / 2000 [  0%]  (Warmup)
#> Chain 4: Iteration:  200 / 2000 [ 10%]  (Warmup)
#> Chain 4: Iteration:  400 / 2000 [ 20%]  (Warmup)
#> Chain 4: Iteration:  600 / 2000 [ 30%]  (Warmup)
#> Chain 4: Iteration:  800 / 2000 [ 40%]  (Warmup)
#> Chain 4: Iteration: 1000 / 2000 [ 50%]  (Warmup)
#> Chain 4: Iteration: 1001 / 2000 [ 50%]  (Sampling)
#> Chain 4: Iteration: 1200 / 2000 [ 60%]  (Sampling)
#> Chain 4: Iteration: 1400 / 2000 [ 70%]  (Sampling)
#> Chain 4: Iteration: 1600 / 2000 [ 80%]  (Sampling)
#> Chain 4: Iteration: 1800 / 2000 [ 90%]  (Sampling)
#> Chain 4: Iteration: 2000 / 2000 [100%]  (Sampling)
#> Chain 4: 
#> Chain 4:  Elapsed Time: 0.595 seconds (Warm-up)
#> Chain 4:                0.608 seconds (Sampling)
#> Chain 4:                1.203 seconds (Total)
#> Chain 4:
#> Inference for Stan model: rti0_bayesian.
#> 4 chains, each with iter=2000; warmup=1000; thin=1; 
#> post-warmup draws per chain=1000, total post-warmup draws=4000.
#> 
#>                   mean se_mean     sd    2.5%     25%     50%     75%   97.5%
#> log_i0            4.94    0.06   1.42    2.25    3.95    4.95    5.90    7.67
#> rt_est            1.05    0.00   0.09    0.89    0.99    1.05    1.11    1.23
#> incid_est[1]    376.09   39.38 809.29    9.52   51.83  141.76  364.02 2140.69
#> incid_est[2]      6.17    0.58  11.90    0.20    1.01    2.61    6.32   33.21
#> incid_est[3]     30.42    2.84  58.63    1.01    4.99   12.86   31.18  163.72
#> incid_est[4]     45.45    4.23  87.42    1.52    7.48   19.26   46.63  244.34
#> incid_est[5]     51.22    4.74  97.93    1.74    8.52   21.84   52.72  274.48
#> incid_est[6]     53.14    4.87 100.57    1.85    8.99   22.89   54.98  283.22
#> incid_est[7]     53.58    4.84 100.08    1.93    9.26   23.39   55.80  283.57
#> incid_est[8]     53.48    4.76  98.40    2.00    9.47   23.69   56.08  280.74
#> incid_est[9]     53.18    4.65  96.30    2.07    9.65   23.93   56.20  276.78
#> incid_est[10]    52.82    4.54  94.08    2.14    9.84   24.13   56.23  272.44
#> incid_est[11]    52.45    4.43  91.86    2.22   10.02   24.34   56.28  268.01
#> incid_est[12]    52.08    4.32  89.68    2.29   10.21   24.56   56.32  263.61
#> incid_est[13]    51.72    4.21  87.55    2.37   10.40   24.77   56.34  259.39
#> incid_est[14]    51.37    4.11  85.47    2.45   10.58   24.98   56.33  255.32
#> incid_est[15]    51.03    4.01  83.45    2.54   10.77   25.18   56.30  251.30
#> incid_est[16]    50.70    3.91  81.49    2.62   10.96   25.39   56.27  247.35
#> incid_est[17]    50.38    3.82  79.57    2.71   11.16   25.61   56.23  243.46
#> incid_est[18]    50.07    3.72  77.71    2.81   11.37   25.84   56.22  239.64
#> incid_est[19]    49.77    3.63  75.90    2.90   11.58   26.06   56.21  235.87
#> incid_est[20]    49.48    3.54  74.14    3.00   11.80   26.29   56.20  232.16
#> incid_est[21]    49.20    3.46  72.42    3.10   12.01   26.52   56.23  228.51
#> incid_est[22]    48.32    3.32  69.58    3.19   12.13   26.50   55.61  221.64
#> incid_est[23]    48.21    3.25  68.25    3.30   12.38   26.79   55.79  218.71
#> incid_est[24]    47.98    3.18  66.74    3.42   12.62   27.02   55.83  215.20
#> incid_est[25]    47.71    3.10  65.16    3.53   12.84   27.23   55.76  211.42
#> incid_est[26]    47.43    3.02  63.60    3.65   13.06   27.44   55.71  207.56
#> incid_est[27]    47.16    2.94  62.07    3.78   13.30   27.66   55.64  203.75
#> incid_est[28]    46.89    2.87  60.58    3.90   13.53   27.87   55.53  200.00
#> incid_est[29]    46.64    2.80  59.13    4.04   13.77   28.09   55.46  196.36
#> incid_est[30]    46.40    2.73  57.72    4.17   14.00   28.32   55.46  192.75
#> incid_est[31]    46.16    2.66  56.35    4.32   14.25   28.55   55.44  189.21
#> incid_est[32]    45.94    2.59  55.01    4.46   14.51   28.79   55.46  185.74
#> incid_est[33]    45.72    2.53  53.71    4.62   14.76   29.03   55.36  182.34
#> incid_est[34]    45.51    2.47  52.44    4.78   15.01   29.24   55.31  179.00
#> incid_est[35]    45.32    2.40  51.20    4.95   15.29   29.46   55.23  175.72
#> incid_est[36]    45.12    2.34  49.99    5.13   15.54   29.68   55.17  172.50
#> incid_est[37]    44.94    2.29  48.82    5.31   15.82   29.90   55.13  169.33
#> incid_est[38]    44.77    2.23  47.67    5.49   16.11   30.13   55.05  166.26
#> incid_est[39]    44.60    2.17  46.55    5.69   16.41   30.36   54.96  163.60
#> incid_est[40]    44.45    2.12  45.46    5.89   16.70   30.59   54.91  161.06
#> incid_est[41]    44.30    2.07  44.39    6.09   17.00   30.83   54.85  158.34
#> incid_est[42]    44.16    2.02  43.35    6.29   17.31   31.07   54.84  155.51
#> incid_est[43]    44.02    1.97  42.33    6.50   17.62   31.33   54.78  152.72
#> incid_est[44]    43.90    1.92  41.34    6.72   17.92   31.60   54.76  150.03
#> incid_est[45]    43.78    1.87  40.37    6.96   18.24   31.85   54.67  147.57
#> incid_est[46]    43.67    1.82  39.42    7.20   18.56   32.10   54.65  145.13
#> incid_est[47]    43.57    1.78  38.49    7.45   18.89   32.36   54.60  142.51
#> incid_est[48]    43.48    1.74  37.58    7.70   19.21   32.64   54.52  139.93
#> incid_est[49]    43.39    1.69  36.69    7.96   19.54   32.90   54.36  137.57
#> incid_est[50]    43.32    1.65  35.82    8.23   19.87   33.15   54.30  135.29
#> incid_est[51]    43.25    1.61  34.97    8.51   20.20   33.41   54.24  133.00
#> incid_est[52]    43.18    1.57  34.13    8.79   20.56   33.67   54.17  130.59
#> incid_est[53]    43.13    1.53  33.31    9.09   20.92   33.96   54.09  128.35
#> incid_est[54]    43.08    1.49  32.51    9.40   21.29   34.26   54.05  126.19
#> incid_est[55]    43.04    1.45  31.72    9.72   21.67   34.54   54.05  123.97
#> incid_est[56]    43.01    1.41  30.95   10.06   22.03   34.83   54.06  121.93
#> incid_est[57]    42.99    1.38  30.19   10.41   22.43   35.13   53.93  119.81
#> incid_est[58]    42.97    1.34  29.45   10.76   22.85   35.38   53.92  117.89
#> incid_est[59]    42.96    1.31  28.71   11.12   23.27   35.63   53.83  115.97
#> incid_est[60]    42.96    1.27  27.99   11.47   23.64   35.93   53.73  113.93
#> incid_est[61]    42.96    1.24  27.28   11.86   24.02   36.24   53.71  111.79
#> incid_est[62]    42.98    1.21  26.59   12.26   24.43   36.52   53.66  109.59
#> incid_est[63]    43.00    1.17  25.90   12.67   24.85   36.79   53.66  107.62
#> incid_est[64]    43.03    1.14  25.22   13.09   25.29   37.09   53.59  105.83
#> incid_est[65]    43.06    1.11  24.56   13.53   25.74   37.36   53.53  104.06
#> incid_est[66]    43.11    1.08  23.90   13.99   26.17   37.67   53.43  102.33
#> incid_est[67]    43.16    1.05  23.25   14.48   26.62   37.96   53.37  100.78
#> incid_est[68]    43.22    1.02  22.61   14.97   27.09   38.27   53.32   99.17
#> incid_est[69]    43.29    0.99  21.97   15.46   27.55   38.56   53.27   97.42
#> incid_est[70]    43.36    0.96  21.35   15.94   28.02   38.86   53.23   95.88
#> incid_est[71]    43.45    0.93  20.73   16.44   28.50   39.18   53.15   94.35
#> incid_est[72]    43.54    0.90  20.11   16.96   29.04   39.50   53.06   92.72
#> incid_est[73]    43.64    0.87  19.50   17.50   29.55   39.84   53.01   91.08
#> incid_est[74]    43.74    0.85  18.90   18.08   30.03   40.16   53.01   89.49
#> incid_est[75]    43.86    0.82  18.30   18.72   30.56   40.50   52.86   88.09
#> incid_est[76]    43.98    0.79  17.71   19.34   31.08   40.82   52.81   86.55
#> incid_est[77]    44.11    0.76  17.12   19.97   31.63   41.17   52.83   85.17
#> incid_est[78]    44.25    0.74  16.54   20.63   32.19   41.51   52.81   83.69
#> incid_est[79]    44.40    0.71  15.96   21.35   32.76   41.79   52.76   82.41
#> incid_est[80]    44.56    0.68  15.38   22.07   33.34   42.10   52.75   81.04
#> incid_est[81]    44.73    0.66  14.80   22.75   33.96   42.44   52.72   79.62
#> incid_est[82]    44.90    0.63  14.23   23.49   34.56   42.78   52.70   78.28
#> incid_est[83]    45.08    0.60  13.66   24.28   35.14   43.10   52.67   76.87
#> incid_est[84]    45.28    0.58  13.09   25.07   35.75   43.47   52.70   75.58
#> incid_est[85]    45.48    0.55  12.53   25.95   36.40   43.87   52.67   74.17
#> incid_est[86]    45.69    0.52  11.96   26.79   37.00   44.18   52.64   73.02
#> incid_est[87]    45.91    0.50  11.40   27.70   37.62   44.56   52.70   71.93
#> incid_est[88]    46.14    0.47  10.83   28.65   38.32   44.97   52.66   70.82
#> incid_est[89]    46.37    0.45  10.27   29.58   39.04   45.32   52.62   69.74
#> incid_est[90]    46.62    0.42   9.71   30.54   39.74   45.69   52.59   68.55
#> incid_est[91]    46.88    0.39   9.15   31.49   40.41   46.07   52.55   67.53
#> incid_est[92]    47.15    0.37   8.60   32.60   41.05   46.44   52.50   66.40
#> incid_est[93]    47.42    0.34   8.05   33.70   41.73   46.83   52.47   65.34
#> incid_est[94]    47.71    0.31   7.50   34.68   42.37   47.20   52.42   64.28
#> incid_est[95]    48.01    0.29   6.96   35.80   43.11   47.57   52.47   63.24
#> incid_est[96]    48.32    0.26   6.42   36.84   43.87   47.96   52.48   62.19
#> incid_est[97]    48.64    0.23   5.90   37.80   44.59   48.35   52.55   61.22
#> incid_est[98]    48.97    0.20   5.40   38.84   45.21   48.79   52.56   60.39
#> incid_est[99]    49.31    0.18   4.92   39.86   45.90   49.19   52.55   59.50
#> incid_est[100]   49.67    0.15   4.47   40.99   46.59   49.63   52.65   58.67
#> incid_est[101]   50.03    0.12   4.08   42.06   47.22   50.07   52.79   58.07
#> incid_est[102]   50.41    0.10   3.76   42.99   47.84   50.49   52.95   57.69
#> incid_est[103]   50.80    0.07   3.53   43.76   48.38   50.87   53.22   57.55
#> incid_est[104]   51.20    0.06   3.43   44.42   48.82   51.27   53.55   57.85
#> incid_est[105]   51.61    0.06   3.46   44.87   49.23   51.66   53.95   58.42
#> incid_est[106]   52.04    0.07   3.63   45.19   49.49   51.96   54.42   59.29
#> incid_est[107]   52.48    0.10   3.92   45.16   49.71   52.38   55.02   60.72
#> incid_est[108]   52.93    0.12   4.33   45.11   49.85   52.74   55.71   62.31
#> incid_est[109]   53.39    0.16   4.82   44.66   49.97   53.11   56.44   63.94
#> incid_est[110]   53.87    0.19   5.38   44.32   50.06   53.53   57.21   65.71
#> incid_est[111]   54.37    0.22   6.00   43.73   50.10   53.92   58.05   67.58
#> incid_est[112]   54.88    0.26   6.67   43.13   50.05   54.39   58.98   69.61
#> incid_est[113]   55.40    0.29   7.37   42.65   50.06   54.85   59.91   71.69
#> incid_est[114]   55.94    0.33   8.11   41.98   50.08   55.31   60.90   73.94
#> incid_est[115]   56.49    0.37   8.88   41.29   50.07   55.76   61.94   76.25
#> incid_est[116]   57.06    0.41   9.68   40.68   50.01   56.22   62.98   78.84
#> incid_est[117]   57.65    0.45  10.51   40.05   50.01   56.69   63.99   81.28
#> lp__           1507.21    0.03   0.95 1504.55 1506.83 1507.49 1507.90 1508.17
#>                n_eff Rhat
#> log_i0           489 1.00
#> rt_est           486 1.00
#> incid_est[1]     422 1.01
#> incid_est[2]     426 1.01
#> incid_est[3]     426 1.01
#> incid_est[4]     426 1.01
#> incid_est[5]     426 1.01
#> incid_est[6]     427 1.01
#> incid_est[7]     427 1.01
#> incid_est[8]     428 1.01
#> incid_est[9]     429 1.01
#> incid_est[10]    429 1.00
#> incid_est[11]    430 1.00
#> incid_est[12]    431 1.00
#> incid_est[13]    431 1.00
#> incid_est[14]    432 1.00
#> incid_est[15]    433 1.00
#> incid_est[16]    434 1.00
#> incid_est[17]    435 1.00
#> incid_est[18]    436 1.00
#> incid_est[19]    437 1.00
#> incid_est[20]    437 1.00
#> incid_est[21]    438 1.00
#> incid_est[22]    440 1.00
#> incid_est[23]    440 1.00
#> incid_est[24]    441 1.00
#> incid_est[25]    442 1.00
#> incid_est[26]    444 1.00
#> incid_est[27]    445 1.00
#> incid_est[28]    446 1.00
#> incid_est[29]    447 1.00
#> incid_est[30]    448 1.00
#> incid_est[31]    449 1.00
#> incid_est[32]    450 1.00
#> incid_est[33]    451 1.00
#> incid_est[34]    452 1.00
#> incid_est[35]    454 1.00
#> incid_est[36]    455 1.00
#> incid_est[37]    456 1.00
#> incid_est[38]    457 1.00
#> incid_est[39]    458 1.00
#> incid_est[40]    459 1.00
#> incid_est[41]    461 1.00
#> incid_est[42]    462 1.00
#> incid_est[43]    463 1.00
#> incid_est[44]    464 1.00
#> incid_est[45]    465 1.00
#> incid_est[46]    467 1.00
#> incid_est[47]    468 1.00
#> incid_est[48]    469 1.00
#> incid_est[49]    470 1.00
#> incid_est[50]    472 1.00
#> incid_est[51]    473 1.00
#> incid_est[52]    474 1.00
#> incid_est[53]    475 1.00
#> incid_est[54]    476 1.00
#> incid_est[55]    477 1.00
#> incid_est[56]    479 1.00
#> incid_est[57]    480 1.00
#> incid_est[58]    481 1.00
#> incid_est[59]    482 1.00
#> incid_est[60]    483 1.00
#> incid_est[61]    484 1.00
#> incid_est[62]    485 1.00
#> incid_est[63]    486 1.00
#> incid_est[64]    488 1.00
#> incid_est[65]    489 1.00
#> incid_est[66]    490 1.00
#> incid_est[67]    491 1.00
#> incid_est[68]    492 1.00
#> incid_est[69]    493 1.00
#> incid_est[70]    494 1.00
#> incid_est[71]    495 1.00
#> incid_est[72]    496 1.00
#> incid_est[73]    497 1.00
#> incid_est[74]    499 1.00
#> incid_est[75]    500 1.00
#> incid_est[76]    501 1.00
#> incid_est[77]    502 1.00
#> incid_est[78]    504 1.00
#> incid_est[79]    505 1.00
#> incid_est[80]    507 1.00
#> incid_est[81]    508 1.00
#> incid_est[82]    510 1.00
#> incid_est[83]    512 1.00
#> incid_est[84]    514 1.00
#> incid_est[85]    517 1.00
#> incid_est[86]    519 1.00
#> incid_est[87]    522 1.00
#> incid_est[88]    526 1.00
#> incid_est[89]    531 1.00
#> incid_est[90]    536 1.00
#> incid_est[91]    542 1.00
#> incid_est[92]    551 1.00
#> incid_est[93]    561 1.00
#> incid_est[94]    574 1.00
#> incid_est[95]    591 1.00
#> incid_est[96]    615 1.00
#> incid_est[97]    648 1.00
#> incid_est[98]    697 1.00
#> incid_est[99]    770 1.00
#> incid_est[100]   890 1.00
#> incid_est[101]  1096 1.00
#> incid_est[102]  1479 1.00
#> incid_est[103]  2307 1.00
#> incid_est[104]  3625 1.00
#> incid_est[105]  3748 1.00
#> incid_est[106]  2802 1.00
#> incid_est[107]  1700 1.00
#> incid_est[108]  1219 1.00
#> incid_est[109]   966 1.00
#> incid_est[110]   821 1.00
#> incid_est[111]   732 1.00
#> incid_est[112]   674 1.00
#> incid_est[113]   634 1.00
#> incid_est[114]   605 1.00
#> incid_est[115]   583 1.00
#> incid_est[116]   566 1.00
#> incid_est[117]   553 1.01
#> lp__             871 1.00
#> 
#> Samples were drawn using NUTS(diag_e) at Sat Oct 26 04:43:09 2024.
#> For each parameter, n_eff is a crude measure of effective sample size,
#> and Rhat is the potential scale reduction factor on split chains (at 
#> convergence, Rhat=1).