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 2.4e-05 seconds
#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.24 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.592 seconds (Warm-up)
#> Chain 1:                0.591 seconds (Sampling)
#> Chain 1:                1.183 seconds (Total)
#> Chain 1: 
#> 
#> SAMPLING FOR MODEL 'rti0_bayesian' NOW (CHAIN 2).
#> Chain 2: 
#> Chain 2: Gradient evaluation took 2.5e-05 seconds
#> Chain 2: 1000 transitions using 10 leapfrog steps per transition would take 0.25 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.63 seconds (Warm-up)
#> Chain 2:                0.613 seconds (Sampling)
#> Chain 2:                1.243 seconds (Total)
#> Chain 2: 
#> 
#> SAMPLING FOR MODEL 'rti0_bayesian' NOW (CHAIN 3).
#> Chain 3: 
#> Chain 3: Gradient evaluation took 1.8e-05 seconds
#> Chain 3: 1000 transitions using 10 leapfrog steps per transition would take 0.18 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.525 seconds (Warm-up)
#> Chain 3:                0.599 seconds (Sampling)
#> Chain 3:                1.124 seconds (Total)
#> Chain 3: 
#> 
#> SAMPLING FOR MODEL 'rti0_bayesian' NOW (CHAIN 4).
#> Chain 4: 
#> Chain 4: Gradient evaluation took 1.8e-05 seconds
#> Chain 4: 1000 transitions using 10 leapfrog steps per transition would take 0.18 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.631 seconds (Warm-up)
#> Chain 4:                0.642 seconds (Sampling)
#> Chain 4:                1.273 seconds (Total)
#> Chain 4:
#> Warning: Bulk Effective Samples Size (ESS) is too low, indicating posterior means and medians may be unreliable.
#> Running the chains for more iterations may help. See
#> https://mc-stan.org/misc/warnings.html#bulk-ess
#> 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.99    0.08   1.49    2.02    3.95    4.99    6.00    7.89
#> rt_est            1.05    0.01   0.09    0.88    0.99    1.05    1.12    1.24
#> incid_est[1]    420.76   44.68 838.06    7.52   51.91  146.43  403.97 2676.75
#> incid_est[2]      6.86    0.67  12.42    0.16    1.01    2.69    6.97   41.29
#> incid_est[3]     33.80    3.31  61.21    0.81    4.99   13.26   34.35  203.53
#> incid_est[4]     50.49    4.94  91.28    1.22    7.49   19.85   51.37  303.70
#> incid_est[5]     56.88    5.54 102.29    1.40    8.52   22.50   58.04  341.01
#> incid_est[6]     58.97    5.70 105.12    1.49    8.99   23.56   60.49  351.59
#> incid_est[7]     59.41    5.68 104.70    1.56    9.26   24.05   61.33  351.65
#> incid_est[8]     59.23    5.60 103.04    1.63    9.47   24.34   61.59  347.73
#> incid_est[9]     58.84    5.50 100.95    1.69    9.65   24.58   61.62  342.36
#> incid_est[10]    58.38    5.38  98.73    1.75    9.84   24.80   61.57  336.40
#> incid_est[11]    57.91    5.27  96.50    1.82   10.03   25.00   61.50  330.35
#> incid_est[12]    57.43    5.16  94.30    1.89   10.22   25.18   61.40  324.44
#> incid_est[13]    56.97    5.05  92.16    1.96   10.41   25.38   61.34  318.66
#> incid_est[14]    56.51    4.94  90.06    2.03   10.61   25.58   61.29  312.99
#> incid_est[15]    56.07    4.84  88.02    2.11   10.81   25.79   61.19  307.41
#> incid_est[16]    55.64    4.74  86.03    2.19   11.00   26.02   61.16  301.93
#> incid_est[17]    55.23    4.64  84.09    2.27   11.21   26.25   61.07  296.55
#> incid_est[18]    54.82    4.54  82.20    2.35   11.41   26.49   60.99  291.26
#> incid_est[19]    54.43    4.44  80.35    2.44   11.62   26.73   60.89  286.07
#> incid_est[20]    54.04    4.35  78.56    2.53   11.84   26.96   60.84  280.97
#> incid_est[21]    53.67    4.26  76.80    2.63   12.06   27.19   60.76  275.96
#> incid_est[22]    52.63    4.10  73.87    2.71   12.18   27.15   60.01  266.92
#> incid_est[23]    52.45    4.03  72.50    2.82   12.42   27.43   60.13  262.86
#> incid_est[24]    52.14    3.95  70.95    2.93   12.66   27.68   60.11  258.42
#> incid_est[25]    51.78    3.86  69.32    3.03   12.87   27.91   60.00  253.69
#> incid_est[26]    51.41    3.78  67.71    3.15   13.09   28.14   59.89  248.94
#> incid_est[27]    51.05    3.69  66.12    3.26   13.31   28.35   59.81  244.22
#> incid_est[28]    50.70    3.61  64.58    3.38   13.56   28.55   59.65  239.30
#> incid_est[29]    50.36    3.53  63.07    3.50   13.80   28.77   59.53  234.47
#> incid_est[30]    50.03    3.45  61.60    3.62   14.05   28.97   59.42  229.74
#> incid_est[31]    49.72    3.37  60.17    3.75   14.30   29.19   59.30  225.12
#> incid_est[32]    49.41    3.30  58.77    3.89   14.56   29.39   59.19  220.75
#> incid_est[33]    49.11    3.22  57.41    4.03   14.82   29.60   59.07  216.63
#> incid_est[34]    48.83    3.15  56.07    4.18   15.07   29.82   58.95  212.60
#> incid_est[35]    48.55    3.08  54.77    4.34   15.34   30.03   58.83  208.64
#> incid_est[36]    48.28    3.01  53.50    4.50   15.61   30.25   58.69  204.75
#> incid_est[37]    48.03    2.94  52.26    4.67   15.87   30.49   58.57  200.94
#> incid_est[38]    47.78    2.88  51.05    4.85   16.15   30.73   58.44  197.19
#> incid_est[39]    47.54    2.81  49.86    5.03   16.44   30.96   58.30  193.51
#> incid_est[40]    47.31    2.75  48.70    5.22   16.74   31.21   58.15  189.64
#> incid_est[41]    47.10    2.68  47.57    5.39   17.03   31.46   58.06  185.84
#> incid_est[42]    46.89    2.62  46.46    5.58   17.32   31.69   57.99  182.12
#> incid_est[43]    46.69    2.56  45.38    5.77   17.63   31.93   57.92  178.47
#> incid_est[44]    46.49    2.50  44.32    5.99   17.93   32.17   57.78  174.90
#> incid_est[45]    46.31    2.45  43.28    6.21   18.24   32.42   57.72  171.50
#> incid_est[46]    46.14    2.39  42.27    6.44   18.57   32.69   57.63  168.41
#> incid_est[47]    45.97    2.33  41.27    6.68   18.92   32.97   57.52  165.41
#> incid_est[48]    45.82    2.28  40.30    6.91   19.26   33.21   57.43  162.46
#> incid_est[49]    45.67    2.22  39.34    7.17   19.60   33.47   57.34  159.37
#> incid_est[50]    45.53    2.17  38.41    7.43   19.94   33.73   57.22  155.99
#> incid_est[51]    45.40    2.12  37.49    7.69   20.32   34.00   57.14  152.73
#> incid_est[52]    45.28    2.07  36.59    7.97   20.66   34.26   57.00  149.82
#> incid_est[53]    45.17    2.02  35.70    8.26   21.02   34.52   56.88  147.11
#> incid_est[54]    45.07    1.97  34.84    8.56   21.42   34.79   56.77  144.45
#> incid_est[55]    44.97    1.92  33.99    8.87   21.79   35.08   56.76  141.67
#> incid_est[56]    44.88    1.87  33.15    9.18   22.19   35.35   56.69  138.62
#> incid_est[57]    44.80    1.83  32.33    9.50   22.56   35.62   56.58  135.71
#> incid_est[58]    44.73    1.78  31.52    9.84   22.93   35.91   56.43  133.22
#> incid_est[59]    44.67    1.74  30.73   10.18   23.34   36.16   56.32  130.65
#> incid_est[60]    44.62    1.69  29.95   10.56   23.75   36.48   56.28  128.11
#> incid_est[61]    44.57    1.65  29.18   10.94   24.15   36.76   56.17  125.26
#> incid_est[62]    44.54    1.60  28.43   11.34   24.55   37.05   56.05  122.63
#> incid_est[63]    44.51    1.56  27.68   11.76   24.95   37.34   55.93  120.11
#> incid_est[64]    44.49    1.52  26.95   12.20   25.40   37.61   55.73  117.64
#> incid_est[65]    44.48    1.48  26.22   12.65   25.83   37.84   55.61  115.02
#> incid_est[66]    44.47    1.44  25.51   13.12   26.25   38.09   55.56  112.86
#> incid_est[67]    44.48    1.40  24.81   13.60   26.71   38.39   55.44  110.54
#> incid_est[68]    44.49    1.36  24.11   14.09   27.17   38.68   55.33  108.28
#> incid_est[69]    44.51    1.32  23.43   14.59   27.63   38.97   55.21  106.26
#> incid_est[70]    44.54    1.28  22.75   15.12   28.09   39.28   55.11  104.28
#> incid_est[71]    44.58    1.24  22.08   15.66   28.56   39.60   54.99  102.14
#> incid_est[72]    44.63    1.20  21.41   16.22   29.07   39.94   54.86  100.13
#> incid_est[73]    44.69    1.16  20.76   16.80   29.60   40.25   54.72   98.18
#> incid_est[74]    44.75    1.12  20.11   17.41   30.12   40.57   54.64   96.31
#> incid_est[75]    44.82    1.09  19.46   18.03   30.62   40.85   54.52   94.47
#> incid_est[76]    44.91    1.05  18.82   18.65   31.18   41.18   54.44   92.68
#> incid_est[77]    45.00    1.01  18.19   19.26   31.69   41.45   54.30   90.88
#> incid_est[78]    45.10    0.98  17.56   19.90   32.24   41.78   54.21   88.73
#> incid_est[79]    45.20    0.94  16.93   20.65   32.81   42.09   54.10   86.94
#> incid_est[80]    45.32    0.90  16.31   21.43   33.39   42.43   54.02   85.37
#> incid_est[81]    45.45    0.87  15.69   22.21   33.98   42.75   53.92   83.82
#> incid_est[82]    45.59    0.83  15.08   22.98   34.58   43.11   53.84   82.29
#> incid_est[83]    45.73    0.80  14.47   23.76   35.16   43.40   53.79   80.85
#> incid_est[84]    45.89    0.76  13.86   24.63   35.77   43.71   53.72   79.34
#> incid_est[85]    46.05    0.73  13.25   25.53   36.39   44.10   53.67   77.63
#> incid_est[86]    46.22    0.69  12.65   26.41   37.04   44.43   53.56   76.00
#> incid_est[87]    46.41    0.66  12.05   27.31   37.69   44.80   53.50   74.32
#> incid_est[88]    46.60    0.62  11.45   28.25   38.32   45.16   53.47   73.08
#> incid_est[89]    46.80    0.59  10.85   29.17   38.96   45.53   53.37   71.62
#> incid_est[90]    47.02    0.55  10.25   30.08   39.64   45.90   53.30   70.25
#> incid_est[91]    47.24    0.52   9.66   31.12   40.27   46.24   53.24   68.77
#> incid_est[92]    47.47    0.48   9.07   32.17   40.94   46.61   53.05   67.42
#> incid_est[93]    47.72    0.44   8.48   33.26   41.61   46.95   52.97   66.31
#> incid_est[94]    47.97    0.41   7.90   34.29   42.28   47.28   52.89   65.21
#> incid_est[95]    48.24    0.37   7.32   35.52   42.96   47.67   52.86   64.15
#> incid_est[96]    48.52    0.34   6.76   36.63   43.61   48.09   52.83   63.12
#> incid_est[97]    48.81    0.30   6.20   37.82   44.32   48.47   52.80   62.12
#> incid_est[98]    49.11    0.27   5.66   38.95   45.06   48.85   52.76   61.20
#> incid_est[99]    49.42    0.23   5.15   40.15   45.71   49.13   52.77   60.46
#> incid_est[100]   49.74    0.19   4.67   41.25   46.40   49.50   52.80   59.78
#> incid_est[101]   50.08    0.16   4.24   42.31   47.08   49.94   52.86   59.02
#> incid_est[102]   50.42    0.12   3.88   43.18   47.69   50.30   53.03   58.66
#> incid_est[103]   50.78    0.09   3.62   44.08   48.25   50.66   53.19   58.31
#> incid_est[104]   51.15    0.06   3.49   44.77   48.72   51.06   53.41   58.21
#> incid_est[105]   51.54    0.06   3.50   45.11   49.12   51.43   53.79   58.73
#> incid_est[106]   51.94    0.07   3.66   45.10   49.43   51.79   54.29   59.41
#> incid_est[107]   52.35    0.10   3.96   44.99   49.63   52.21   54.82   60.51
#> incid_est[108]   52.78    0.14   4.37   44.63   49.75   52.57   55.46   61.86
#> incid_est[109]   53.22    0.18   4.88   44.12   49.90   52.99   56.21   63.60
#> incid_est[110]   53.67    0.22   5.47   43.66   49.92   53.35   57.01   65.54
#> incid_est[111]   54.14    0.26   6.11   43.07   49.90   53.78   57.98   67.44
#> incid_est[112]   54.62    0.31   6.80   42.44   49.83   54.20   58.84   69.66
#> incid_est[113]   55.12    0.35   7.54   42.01   49.80   54.58   59.81   71.60
#> incid_est[114]   55.63    0.40   8.31   41.19   49.76   54.99   60.73   73.89
#> incid_est[115]   56.16    0.44   9.11   40.51   49.68   55.38   61.77   76.23
#> incid_est[116]   56.71    0.49   9.95   39.91   49.55   55.81   62.80   78.85
#> incid_est[117]   57.27    0.54  10.81   39.16   49.41   56.20   63.83   81.44
#> lp__           1507.14    0.04   1.03 1504.38 1506.73 1507.46 1507.89 1508.17
#>                n_eff Rhat
#> log_i0           333 1.01
#> rt_est           338 1.01
#> incid_est[1]     352 1.02
#> incid_est[2]     342 1.02
#> incid_est[3]     342 1.02
#> incid_est[4]     342 1.02
#> incid_est[5]     341 1.02
#> incid_est[6]     340 1.02
#> incid_est[7]     340 1.02
#> incid_est[8]     338 1.02
#> incid_est[9]     337 1.02
#> incid_est[10]    336 1.02
#> incid_est[11]    335 1.02
#> incid_est[12]    334 1.02
#> incid_est[13]    333 1.02
#> incid_est[14]    332 1.02
#> incid_est[15]    331 1.02
#> incid_est[16]    330 1.02
#> incid_est[17]    329 1.02
#> incid_est[18]    328 1.02
#> incid_est[19]    327 1.02
#> incid_est[20]    326 1.02
#> incid_est[21]    325 1.02
#> incid_est[22]    324 1.02
#> incid_est[23]    324 1.02
#> incid_est[24]    323 1.02
#> incid_est[25]    322 1.02
#> incid_est[26]    321 1.02
#> incid_est[27]    321 1.02
#> incid_est[28]    320 1.02
#> incid_est[29]    320 1.02
#> incid_est[30]    319 1.02
#> incid_est[31]    318 1.02
#> incid_est[32]    318 1.02
#> incid_est[33]    317 1.02
#> incid_est[34]    317 1.02
#> incid_est[35]    316 1.02
#> incid_est[36]    316 1.02
#> incid_est[37]    316 1.02
#> incid_est[38]    315 1.02
#> incid_est[39]    315 1.02
#> incid_est[40]    315 1.02
#> incid_est[41]    314 1.02
#> incid_est[42]    314 1.02
#> incid_est[43]    314 1.02
#> incid_est[44]    314 1.02
#> incid_est[45]    313 1.02
#> incid_est[46]    313 1.02
#> incid_est[47]    313 1.02
#> incid_est[48]    313 1.02
#> incid_est[49]    313 1.02
#> incid_est[50]    313 1.02
#> incid_est[51]    313 1.02
#> incid_est[52]    313 1.02
#> incid_est[53]    313 1.02
#> incid_est[54]    313 1.02
#> incid_est[55]    313 1.02
#> incid_est[56]    313 1.02
#> incid_est[57]    313 1.02
#> incid_est[58]    313 1.02
#> incid_est[59]    313 1.02
#> incid_est[60]    314 1.02
#> incid_est[61]    314 1.02
#> incid_est[62]    314 1.02
#> incid_est[63]    314 1.02
#> incid_est[64]    315 1.02
#> incid_est[65]    315 1.02
#> incid_est[66]    315 1.02
#> incid_est[67]    316 1.02
#> incid_est[68]    316 1.01
#> incid_est[69]    317 1.01
#> incid_est[70]    317 1.01
#> incid_est[71]    318 1.01
#> incid_est[72]    318 1.01
#> incid_est[73]    319 1.01
#> incid_est[74]    320 1.01
#> incid_est[75]    320 1.01
#> incid_est[76]    321 1.01
#> incid_est[77]    322 1.01
#> incid_est[78]    323 1.01
#> incid_est[79]    324 1.01
#> incid_est[80]    325 1.01
#> incid_est[81]    326 1.01
#> incid_est[82]    328 1.01
#> incid_est[83]    329 1.01
#> incid_est[84]    331 1.01
#> incid_est[85]    333 1.01
#> incid_est[86]    335 1.01
#> incid_est[87]    337 1.01
#> incid_est[88]    340 1.01
#> incid_est[89]    343 1.01
#> incid_est[90]    347 1.01
#> incid_est[91]    352 1.01
#> incid_est[92]    358 1.01
#> incid_est[93]    365 1.01
#> incid_est[94]    374 1.01
#> incid_est[95]    385 1.01
#> incid_est[96]    401 1.01
#> incid_est[97]    423 1.01
#> incid_est[98]    454 1.01
#> incid_est[99]    502 1.01
#> incid_est[100]   584 1.01
#> incid_est[101]   731 1.00
#> incid_est[102]  1044 1.00
#> incid_est[103]  1683 1.00
#> incid_est[104]  3070 1.00
#> incid_est[105]  3562 1.00
#> incid_est[106]  2702 1.00
#> incid_est[107]  1492 1.00
#> incid_est[108]  1003 1.01
#> incid_est[109]   736 1.01
#> incid_est[110]   607 1.01
#> incid_est[111]   536 1.01
#> incid_est[112]   491 1.01
#> incid_est[113]   460 1.01
#> incid_est[114]   439 1.01
#> incid_est[115]   424 1.01
#> incid_est[116]   413 1.01
#> incid_est[117]   405 1.01
#> lp__             638 1.01
#> 
#> Samples were drawn using NUTS(diag_e) at Sun Jul 19 04:58:04 2026.
#> 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).