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.6e-05 seconds
#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.46 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.881 seconds (Warm-up)
#> Chain 1:                0.693 seconds (Sampling)
#> Chain 1:                1.574 seconds (Total)
#> Chain 1: 
#> 
#> SAMPLING FOR MODEL 'rti0_bayesian' NOW (CHAIN 2).
#> Chain 2: 
#> Chain 2: Gradient evaluation took 2e-05 seconds
#> Chain 2: 1000 transitions using 10 leapfrog steps per transition would take 0.2 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.592 seconds (Warm-up)
#> Chain 2:                0.651 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.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.575 seconds (Warm-up)
#> Chain 3:                0.748 seconds (Sampling)
#> Chain 3:                1.323 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.657 seconds (Warm-up)
#> Chain 4:                0.612 seconds (Sampling)
#> Chain 4:                1.269 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            5.09    0.06    1.43    2.57    4.09    5.00    6.06    7.99
#> rt_est            1.05    0.00    0.09    0.87    0.98    1.05    1.11    1.21
#> incid_est[1]    493.73   65.68 1437.75   13.08   59.75  148.39  426.80 2948.41
#> incid_est[2]      7.86    0.92   19.94    0.28    1.16    2.73    7.35   45.29
#> incid_est[3]     38.75    4.51   98.27    1.36    5.70   13.45   36.25  223.22
#> incid_est[4]     57.87    6.72  146.39    2.04    8.54   20.15   54.20  332.99
#> incid_est[5]     65.12    7.51  163.55    2.34    9.72   22.84   61.21  373.58
#> incid_est[6]     67.38    7.68  167.18    2.49   10.25   23.94   63.74  384.61
#> incid_est[7]     67.72    7.60  165.35    2.59   10.56   24.46   64.56  383.94
#> incid_est[8]     67.34    7.42  161.44    2.67   10.78   24.77   64.80  378.84
#> incid_est[9]     66.71    7.21  156.82    2.76   10.97   25.01   64.81  372.15
#> incid_est[10]    66.00    6.99  152.03    2.84   11.17   25.23   64.73  364.96
#> incid_est[11]    65.27    6.78  147.29    2.93   11.36   25.44   64.63  357.97
#> incid_est[12]    64.56    6.57  142.67    3.02   11.55   25.64   64.56  351.10
#> incid_est[13]    63.86    6.36  138.20    3.11   11.75   25.84   64.50  344.45
#> incid_est[14]    63.19    6.17  133.88    3.20   11.95   26.05   64.40  337.88
#> incid_est[15]    62.53    5.97  129.72    3.30   12.16   26.28   64.27  331.42
#> incid_est[16]    61.89    5.79  125.70    3.40   12.37   26.49   64.14  325.08
#> incid_est[17]    61.27    5.61  121.82    3.51   12.58   26.71   64.05  318.86
#> incid_est[18]    60.67    5.44  118.08    3.62   12.80   26.94   63.98  312.76
#> incid_est[19]    60.09    5.27  114.47    3.73   13.04   27.17   63.92  306.76
#> incid_est[20]    59.52    5.11  110.99    3.85   13.26   27.40   63.84  300.74
#> incid_est[21]    58.98    4.96  107.63    3.97   13.47   27.64   63.76  294.85
#> incid_est[22]    57.67    4.72  102.43    4.08   13.59   27.61   62.92  284.57
#> incid_est[23]    57.35    4.59   99.78    4.22   13.85   27.93   63.05  280.00
#> incid_est[24]    56.89    4.46   96.90    4.35   14.08   28.18   62.98  274.71
#> incid_est[25]    56.38    4.32   93.94    4.49   14.31   28.40   62.78  269.11
#> incid_est[26]    55.86    4.19   91.04    4.64   14.54   28.63   62.56  263.51
#> incid_est[27]    55.35    4.05   88.22    4.78   14.77   28.86   62.41  258.00
#> incid_est[28]    54.87    3.93   85.50    4.92   15.00   29.08   62.24  252.60
#> incid_est[29]    54.39    3.80   82.88    5.07   15.25   29.30   62.08  247.32
#> incid_est[30]    53.94    3.69   80.35    5.21   15.49   29.52   61.91  242.15
#> incid_est[31]    53.50    3.57   77.91    5.38   15.74   29.74   61.78  237.09
#> incid_est[32]    53.07    3.46   75.55    5.55   16.01   29.97   61.67  232.14
#> incid_est[33]    52.66    3.35   73.27    5.72   16.28   30.21   61.53  227.29
#> incid_est[34]    52.26    3.25   71.07    5.89   16.55   30.43   61.36  222.54
#> incid_est[35]    51.88    3.15   68.95    6.08   16.80   30.63   61.20  217.89
#> incid_est[36]    51.51    3.05   66.89    6.27   17.08   30.84   61.00  213.34
#> incid_est[37]    51.16    2.96   64.91    6.46   17.35   31.08   60.78  208.88
#> incid_est[38]    50.81    2.87   62.98    6.66   17.63   31.32   60.63  204.52
#> incid_est[39]    50.49    2.78   61.13    6.87   17.89   31.58   60.57  200.35
#> incid_est[40]    50.17    2.70   59.33    7.09   18.17   31.85   60.49  196.27
#> incid_est[41]    49.86    2.61   57.59    7.31   18.48   32.10   60.31  192.27
#> incid_est[42]    49.57    2.53   55.90    7.54   18.78   32.31   60.10  188.35
#> incid_est[43]    49.29    2.46   54.27    7.77   19.09   32.56   59.90  184.51
#> incid_est[44]    49.03    2.38   52.69    8.01   19.40   32.83   59.79  180.75
#> incid_est[45]    48.77    2.31   51.16    8.26   19.71   33.06   59.67  177.08
#> incid_est[46]    48.53    2.24   49.67    8.51   20.01   33.31   59.54  173.47
#> incid_est[47]    48.29    2.17   48.23    8.77   20.31   33.59   59.38  169.88
#> incid_est[48]    48.07    2.11   46.84    9.04   20.61   33.84   59.24  166.32
#> incid_est[49]    47.86    2.04   45.48    9.32   20.95   34.09   59.05  162.84
#> incid_est[50]    47.66    1.98   44.17    9.61   21.28   34.32   58.86  159.64
#> incid_est[51]    47.47    1.92   42.89    9.92   21.60   34.59   58.68  156.51
#> incid_est[52]    47.29    1.86   41.65   10.22   21.94   34.86   58.53  153.32
#> incid_est[53]    47.12    1.80   40.44   10.52   22.29   35.13   58.39  150.31
#> incid_est[54]    46.97    1.75   39.26   10.84   22.62   35.36   58.28  147.19
#> incid_est[55]    46.82    1.69   38.12   11.18   22.97   35.58   58.18  144.23
#> incid_est[56]    46.68    1.64   37.01   11.52   23.33   35.82   58.06  141.52
#> incid_est[57]    46.55    1.59   35.93   11.87   23.70   36.13   57.91  138.85
#> incid_est[58]    46.44    1.54   34.87   12.23   24.09   36.43   57.75  136.09
#> incid_est[59]    46.33    1.49   33.85   12.58   24.47   36.68   57.62  133.26
#> incid_est[60]    46.23    1.44   32.84   12.92   24.87   36.95   57.50  130.49
#> incid_est[61]    46.14    1.40   31.86   13.28   25.27   37.22   57.46  127.78
#> incid_est[62]    46.06    1.35   30.91   13.70   25.68   37.50   57.29  125.14
#> incid_est[63]    45.99    1.31   29.98   14.13   26.09   37.78   57.12  122.58
#> incid_est[64]    45.93    1.27   29.06   14.57   26.52   38.02   56.99  120.03
#> incid_est[65]    45.88    1.22   28.17   15.03   26.95   38.27   56.87  117.50
#> incid_est[66]    45.84    1.18   27.30   15.48   27.40   38.56   56.67  115.06
#> incid_est[67]    45.81    1.14   26.45   15.92   27.84   38.83   56.50  112.67
#> incid_est[68]    45.79    1.10   25.61   16.40   28.28   39.11   56.36  110.40
#> incid_est[69]    45.77    1.07   24.79   16.91   28.72   39.44   56.14  108.24
#> incid_est[70]    45.77    1.03   23.98   17.40   29.16   39.72   55.93  106.12
#> incid_est[71]    45.78    0.99   23.19   17.88   29.64   40.02   55.77  104.05
#> incid_est[72]    45.79    0.96   22.42   18.38   30.11   40.32   55.67  101.96
#> incid_est[73]    45.81    0.92   21.65   18.98   30.59   40.64   55.59   99.59
#> incid_est[74]    45.85    0.89   20.90   19.58   31.10   40.94   55.38   97.49
#> incid_est[75]    45.89    0.85   20.17   20.15   31.61   41.25   55.29   95.63
#> incid_est[76]    45.94    0.82   19.44   20.74   32.13   41.54   55.12   93.66
#> incid_est[77]    46.00    0.79   18.72   21.35   32.65   41.82   54.97   91.86
#> incid_est[78]    46.07    0.75   18.02   22.04   33.23   42.11   54.78   90.14
#> incid_est[79]    46.15    0.72   17.32   22.73   33.72   42.46   54.66   88.28
#> incid_est[80]    46.23    0.69   16.63   23.48   34.28   42.77   54.57   86.43
#> incid_est[81]    46.33    0.66   15.95   24.19   34.85   43.11   54.43   84.59
#> incid_est[82]    46.44    0.63   15.28   24.94   35.40   43.44   54.31   82.84
#> incid_est[83]    46.55    0.60   14.62   25.76   36.00   43.77   54.20   81.10
#> incid_est[84]    46.68    0.57   13.96   26.53   36.64   44.09   54.10   79.54
#> incid_est[85]    46.81    0.54   13.31   27.34   37.27   44.47   53.97   77.80
#> incid_est[86]    46.95    0.51   12.66   28.10   37.89   44.83   53.88   76.46
#> incid_est[87]    47.11    0.48   12.02   28.97   38.46   45.16   53.80   74.97
#> incid_est[88]    47.27    0.46   11.39   29.84   39.09   45.53   53.69   73.57
#> incid_est[89]    47.44    0.43   10.76   30.78   39.72   45.90   53.55   72.12
#> incid_est[90]    47.63    0.40   10.14   31.60   40.34   46.21   53.42   70.70
#> incid_est[91]    47.82    0.37    9.53   32.70   40.92   46.54   53.31   69.29
#> incid_est[92]    48.02    0.34    8.92   33.62   41.55   46.89   53.20   67.91
#> incid_est[93]    48.23    0.32    8.32   34.71   42.21   47.20   53.09   66.56
#> incid_est[94]    48.45    0.29    7.72   35.74   42.89   47.54   53.01   65.33
#> incid_est[95]    48.69    0.26    7.14   36.69   43.61   47.95   53.00   64.15
#> incid_est[96]    48.93    0.23    6.57   37.74   44.29   48.34   52.95   62.95
#> incid_est[97]    49.18    0.21    6.02   38.85   44.94   48.74   52.93   61.98
#> incid_est[98]    49.45    0.18    5.48   39.88   45.61   49.12   52.86   60.91
#> incid_est[99]    49.72    0.16    4.98   40.81   46.25   49.47   52.87   59.98
#> incid_est[100]   50.00    0.13    4.52   41.85   46.84   49.84   52.87   59.27
#> incid_est[101]   50.30    0.11    4.11   42.76   47.50   50.15   52.91   58.66
#> incid_est[102]   50.61    0.08    3.78   43.53   48.04   50.49   53.06   58.44
#> incid_est[103]   50.93    0.07    3.54   44.25   48.55   50.83   53.24   58.13
#> incid_est[104]   51.26    0.06    3.43   44.75   48.98   51.15   53.45   58.18
#> incid_est[105]   51.60    0.06    3.46   45.15   49.27   51.51   53.80   58.58
#> incid_est[106]   51.95    0.07    3.63   45.18   49.44   51.81   54.27   59.37
#> incid_est[107]   52.32    0.10    3.92   45.04   49.58   52.14   54.84   60.28
#> incid_est[108]   52.69    0.12    4.32   44.65   49.71   52.55   55.53   61.39
#> incid_est[109]   53.08    0.15    4.81   44.10   49.77   52.89   56.23   62.84
#> incid_est[110]   53.48    0.18    5.35   43.56   49.79   53.24   56.99   64.45
#> incid_est[111]   53.90    0.20    5.95   42.88   49.86   53.59   57.85   66.04
#> incid_est[112]   54.33    0.23    6.59   42.21   49.87   53.95   58.70   67.87
#> incid_est[113]   54.77    0.26    7.27   41.44   49.77   54.34   59.55   69.67
#> incid_est[114]   55.22    0.29    7.97   40.61   49.72   54.79   60.47   71.57
#> incid_est[115]   55.69    0.32    8.70   39.90   49.68   55.22   61.36   73.66
#> incid_est[116]   56.17    0.36    9.46   39.12   49.54   55.68   62.32   75.84
#> incid_est[117]   56.67    0.39   10.24   38.43   49.36   56.12   63.23   78.04
#> lp__           1507.18    0.04    1.03 1504.48 1506.79 1507.49 1507.92 1508.18
#>                n_eff Rhat
#> log_i0           614 1.01
#> rt_est           621 1.00
#> incid_est[1]     479 1.01
#> incid_est[2]     474 1.01
#> incid_est[3]     474 1.01
#> incid_est[4]     474 1.01
#> incid_est[5]     474 1.01
#> incid_est[6]     474 1.01
#> incid_est[7]     474 1.01
#> incid_est[8]     473 1.01
#> incid_est[9]     473 1.01
#> incid_est[10]    472 1.01
#> incid_est[11]    472 1.01
#> incid_est[12]    472 1.01
#> incid_est[13]    472 1.01
#> incid_est[14]    472 1.01
#> incid_est[15]    471 1.01
#> incid_est[16]    471 1.01
#> incid_est[17]    471 1.01
#> incid_est[18]    471 1.01
#> incid_est[19]    471 1.01
#> incid_est[20]    471 1.01
#> incid_est[21]    472 1.01
#> incid_est[22]    472 1.01
#> incid_est[23]    472 1.01
#> incid_est[24]    472 1.01
#> incid_est[25]    473 1.01
#> incid_est[26]    473 1.01
#> incid_est[27]    474 1.01
#> incid_est[28]    474 1.01
#> incid_est[29]    475 1.01
#> incid_est[30]    475 1.01
#> incid_est[31]    476 1.01
#> incid_est[32]    477 1.01
#> incid_est[33]    477 1.01
#> incid_est[34]    478 1.01
#> incid_est[35]    479 1.01
#> incid_est[36]    480 1.01
#> incid_est[37]    481 1.01
#> incid_est[38]    482 1.01
#> incid_est[39]    483 1.01
#> incid_est[40]    484 1.01
#> incid_est[41]    485 1.01
#> incid_est[42]    487 1.01
#> incid_est[43]    488 1.01
#> incid_est[44]    489 1.01
#> incid_est[45]    491 1.01
#> incid_est[46]    492 1.01
#> incid_est[47]    493 1.01
#> incid_est[48]    495 1.01
#> incid_est[49]    497 1.01
#> incid_est[50]    498 1.01
#> incid_est[51]    500 1.01
#> incid_est[52]    502 1.01
#> incid_est[53]    503 1.01
#> incid_est[54]    505 1.01
#> incid_est[55]    507 1.01
#> incid_est[56]    509 1.01
#> incid_est[57]    511 1.01
#> incid_est[58]    513 1.01
#> incid_est[59]    515 1.01
#> incid_est[60]    517 1.01
#> incid_est[61]    520 1.01
#> incid_est[62]    522 1.01
#> incid_est[63]    524 1.01
#> incid_est[64]    527 1.01
#> incid_est[65]    529 1.01
#> incid_est[66]    532 1.01
#> incid_est[67]    534 1.01
#> incid_est[68]    537 1.01
#> incid_est[69]    540 1.01
#> incid_est[70]    543 1.01
#> incid_est[71]    546 1.01
#> incid_est[72]    549 1.01
#> incid_est[73]    552 1.01
#> incid_est[74]    555 1.01
#> incid_est[75]    559 1.01
#> incid_est[76]    562 1.01
#> incid_est[77]    566 1.01
#> incid_est[78]    570 1.01
#> incid_est[79]    574 1.01
#> incid_est[80]    578 1.01
#> incid_est[81]    583 1.01
#> incid_est[82]    587 1.01
#> incid_est[83]    593 1.01
#> incid_est[84]    598 1.01
#> incid_est[85]    604 1.01
#> incid_est[86]    611 1.00
#> incid_est[87]    618 1.00
#> incid_est[88]    627 1.00
#> incid_est[89]    636 1.00
#> incid_est[90]    647 1.00
#> incid_est[91]    660 1.00
#> incid_est[92]    675 1.00
#> incid_est[93]    694 1.00
#> incid_est[94]    716 1.00
#> incid_est[95]    745 1.00
#> incid_est[96]    783 1.00
#> incid_est[97]    835 1.00
#> incid_est[98]    910 1.00
#> incid_est[99]   1021 1.00
#> incid_est[100]  1200 1.00
#> incid_est[101]  1508 1.00
#> incid_est[102]  2035 1.00
#> incid_est[103]  2852 1.00
#> incid_est[104]  3610 1.00
#> incid_est[105]  3622 1.00
#> incid_est[106]  2407 1.00
#> incid_est[107]  1683 1.00
#> incid_est[108]  1280 1.00
#> incid_est[109]  1057 1.00
#> incid_est[110]   930 1.00
#> incid_est[111]   851 1.00
#> incid_est[112]   799 1.00
#> incid_est[113]   764 1.00
#> incid_est[114]   740 1.00
#> incid_est[115]   723 1.00
#> incid_est[116]   710 1.00
#> incid_est[117]   701 1.00
#> lp__             752 1.00
#> 
#> Samples were drawn using NUTS(diag_e) at Mon May 25 06:12:37 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).