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.3e-05 seconds
#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.23 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.494 seconds (Warm-up)
#> Chain 1:                0.64 seconds (Sampling)
#> Chain 1:                1.134 seconds (Total)
#> Chain 1: 
#> 
#> SAMPLING FOR MODEL 'rti0_bayesian' NOW (CHAIN 2).
#> Chain 2: 
#> Chain 2: Gradient evaluation took 1.8e-05 seconds
#> Chain 2: 1000 transitions using 10 leapfrog steps per transition would take 0.18 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.526 seconds (Warm-up)
#> Chain 2:                0.605 seconds (Sampling)
#> Chain 2:                1.131 seconds (Total)
#> Chain 2: 
#> 
#> SAMPLING FOR MODEL 'rti0_bayesian' NOW (CHAIN 3).
#> Chain 3: 
#> Chain 3: Gradient evaluation took 2.2e-05 seconds
#> Chain 3: 1000 transitions using 10 leapfrog steps per transition would take 0.22 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.513 seconds (Warm-up)
#> Chain 3:                0.752 seconds (Sampling)
#> Chain 3:                1.265 seconds (Total)
#> Chain 3: 
#> 
#> SAMPLING FOR MODEL 'rti0_bayesian' NOW (CHAIN 4).
#> Chain 4: 
#> Chain 4: Gradient evaluation took 1.7e-05 seconds
#> Chain 4: 1000 transitions using 10 leapfrog steps per transition would take 0.17 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.558 seconds (Warm-up)
#> Chain 4:                0.698 seconds (Sampling)
#> Chain 4:                1.256 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.89    0.07   1.38    2.08    3.95    4.94    5.82    7.56
#> rt_est            1.06    0.00   0.09    0.90    1.00    1.05    1.12    1.24
#> incid_est[1]    335.97   33.96 985.85    7.98   51.73  139.52  336.33 1928.68
#> incid_est[2]      5.55    0.49  13.57    0.17    1.01    2.57    5.87   30.26
#> incid_est[3]     27.35    2.41  66.85    0.85    4.98   12.68   28.94  149.15
#> incid_est[4]     40.87    3.59  99.58    1.28    7.46   18.98   43.28  222.63
#> incid_est[5]     46.08    4.02 111.24    1.46    8.49   21.52   48.93  250.21
#> incid_est[6]     47.84    4.12 113.68    1.56    8.95   22.56   51.02  258.39
#> incid_est[7]     48.29    4.10 112.40    1.63    9.22   23.06   51.79  258.97
#> incid_est[8]     48.25    4.02 109.72    1.70    9.42   23.37   52.10  256.69
#> incid_est[9]     48.03    3.93 106.56    1.76    9.61   23.61   52.24  253.39
#> incid_est[10]    47.77    3.83 103.30    1.83    9.78   23.84   52.32  249.80
#> incid_est[11]    47.49    3.73 100.08    1.89    9.97   24.06   52.38  246.12
#> incid_est[12]    47.21    3.64  96.96    1.96   10.15   24.26   52.42  242.45
#> incid_est[13]    46.95    3.55  93.95    2.04   10.33   24.49   52.46  238.83
#> incid_est[14]    46.69    3.46  91.06    2.11   10.52   24.72   52.50  235.25
#> incid_est[15]    46.44    3.37  88.28    2.19   10.72   24.93   52.54  231.72
#> incid_est[16]    46.20    3.29  85.61    2.27   10.91   25.16   52.60  228.25
#> incid_est[17]    45.96    3.20  83.04    2.35   11.12   25.41   52.61  224.83
#> incid_est[18]    45.74    3.13  80.58    2.43   11.32   25.65   52.65  221.46
#> incid_est[19]    45.53    3.05  78.21    2.52   11.54   25.89   52.72  217.93
#> incid_est[20]    45.32    2.98  75.93    2.62   11.75   26.14   52.79  214.27
#> incid_est[21]    45.13    2.90  73.74    2.71   11.96   26.39   52.86  211.01
#> incid_est[22]    44.39    2.79  70.31    2.79   12.07   26.37   52.31  204.79
#> incid_est[23]    44.34    2.73  68.61    2.89   12.32   26.69   52.45  202.36
#> incid_est[24]    44.19    2.67  66.75    3.00   12.54   26.94   52.47  199.40
#> incid_est[25]    44.00    2.61  64.85    3.10   12.76   27.14   52.44  196.22
#> incid_est[26]    43.80    2.54  62.98    3.21   12.98   27.34   52.41  193.01
#> incid_est[27]    43.61    2.48  61.18    3.32   13.21   27.57   52.39  189.83
#> incid_est[28]    43.43    2.42  59.45    3.44   13.44   27.80   52.35  186.70
#> incid_est[29]    43.25    2.36  57.77    3.56   13.69   28.01   52.34  183.63
#> incid_est[30]    43.09    2.31  56.17    3.69   13.94   28.26   52.34  180.60
#> incid_est[31]    42.93    2.26  54.62    3.82   14.19   28.49   52.33  177.63
#> incid_est[32]    42.78    2.21  53.12    3.96   14.44   28.72   52.31  174.66
#> incid_est[33]    42.64    2.16  51.69    4.10   14.69   28.96   52.31  171.84
#> incid_est[34]    42.50    2.11  50.30    4.24   14.95   29.21   52.31  169.02
#> incid_est[35]    42.37    2.06  48.96    4.39   15.21   29.46   52.30  166.24
#> incid_est[36]    42.25    2.02  47.66    4.55   15.47   29.70   52.26  163.51
#> incid_est[37]    42.14    1.97  46.41    4.71   15.75   29.94   52.24  160.72
#> incid_est[38]    42.03    1.93  45.21    4.88   16.03   30.17   52.22  158.07
#> incid_est[39]    41.93    1.89  44.04    5.07   16.32   30.43   52.16  155.40
#> incid_est[40]    41.84    1.85  42.91    5.25   16.61   30.68   52.18  152.68
#> incid_est[41]    41.76    1.81  41.81    5.45   16.91   30.96   52.18  150.00
#> incid_est[42]    41.68    1.77  40.75    5.65   17.22   31.22   52.16  147.38
#> incid_est[43]    41.61    1.73  39.73    5.86   17.52   31.49   52.15  144.80
#> incid_est[44]    41.54    1.69  38.73    6.08   17.85   31.77   52.12  142.26
#> incid_est[45]    41.49    1.66  37.77    6.30   18.17   32.02   52.08  139.77
#> incid_est[46]    41.44    1.62  36.83    6.53   18.48   32.28   52.04  137.55
#> incid_est[47]    41.39    1.58  35.92    6.77   18.83   32.56   52.03  135.37
#> incid_est[48]    41.36    1.55  35.04    7.02   19.17   32.83   52.08  133.21
#> incid_est[49]    41.33    1.52  34.18    7.28   19.47   33.10   52.06  131.09
#> incid_est[50]    41.30    1.48  33.34    7.55   19.80   33.39   51.99  129.03
#> incid_est[51]    41.29    1.45  32.52    7.82   20.14   33.67   51.93  127.04
#> incid_est[52]    41.28    1.42  31.73    8.10   20.48   33.93   51.91  125.08
#> incid_est[53]    41.28    1.39  30.95    8.39   20.83   34.20   51.90  123.16
#> incid_est[54]    41.28    1.36  30.19    8.69   21.20   34.45   51.90  121.26
#> incid_est[55]    41.29    1.33  29.45    9.01   21.58   34.72   51.86  119.34
#> incid_est[56]    41.31    1.30  28.73    9.33   21.96   35.00   51.85  117.51
#> incid_est[57]    41.33    1.27  28.03    9.66   22.36   35.27   51.87  115.73
#> incid_est[58]    41.36    1.24  27.33    9.99   22.74   35.54   51.88  113.91
#> incid_est[59]    41.40    1.22  26.66   10.33   23.16   35.82   51.89  111.90
#> incid_est[60]    41.45    1.19  25.99   10.71   23.59   36.07   51.83  109.93
#> incid_est[61]    41.50    1.17  25.34   11.11   23.98   36.36   51.85  108.18
#> incid_est[62]    41.56    1.14  24.70   11.52   24.38   36.62   51.86  106.46
#> incid_est[63]    41.62    1.12  24.07   11.95   24.83   36.89   51.85  104.74
#> incid_est[64]    41.69    1.10  23.45   12.39   25.26   37.16   51.80  102.90
#> incid_est[65]    41.77    1.07  22.84   12.83   25.71   37.47   51.80  101.38
#> incid_est[66]    41.86    1.05  22.24   13.27   26.16   37.79   51.73   99.87
#> incid_est[67]    41.95    1.03  21.65   13.77   26.64   38.08   51.69   98.29
#> incid_est[68]    42.05    1.00  21.07   14.27   27.10   38.41   51.76   96.68
#> incid_est[69]    42.16    0.98  20.49   14.79   27.58   38.72   51.77   95.09
#> incid_est[70]    42.27    0.96  19.92   15.27   28.07   38.99   51.76   93.53
#> incid_est[71]    42.39    0.93  19.36   15.79   28.57   39.25   51.77   92.00
#> incid_est[72]    42.52    0.91  18.81   16.32   29.12   39.52   51.75   90.49
#> incid_est[73]    42.65    0.89  18.25   16.88   29.61   39.81   51.77   89.04
#> incid_est[74]    42.80    0.86  17.71   17.48   30.14   40.12   51.84   87.54
#> incid_est[75]    42.95    0.84  17.17   18.08   30.67   40.47   51.90   86.11
#> incid_est[76]    43.11    0.82  16.63   18.72   31.20   40.79   51.93   84.61
#> incid_est[77]    43.27    0.79  16.09   19.36   31.76   41.10   51.93   82.88
#> incid_est[78]    43.45    0.77  15.56   20.05   32.30   41.43   51.92   81.39
#> incid_est[79]    43.63    0.74  15.03   20.73   32.84   41.74   51.92   79.80
#> incid_est[80]    43.82    0.71  14.50   21.51   33.40   42.08   51.91   78.67
#> incid_est[81]    44.02    0.69  13.98   22.26   33.95   42.41   51.89   77.31
#> incid_est[82]    44.22    0.66  13.46   23.01   34.57   42.75   51.90   76.06
#> incid_est[83]    44.44    0.63  12.93   23.77   35.16   43.10   51.86   74.89
#> incid_est[84]    44.66    0.61  12.41   24.56   35.77   43.43   51.82   73.74
#> incid_est[85]    44.89    0.58  11.89   25.43   36.36   43.77   51.80   72.59
#> incid_est[86]    45.13    0.55  11.37   26.28   36.99   44.17   51.87   71.36
#> incid_est[87]    45.38    0.53  10.85   27.18   37.63   44.49   51.85   70.07
#> incid_est[88]    45.64    0.50  10.33   28.05   38.25   44.84   51.94   69.02
#> incid_est[89]    45.90    0.47   9.81   28.98   38.92   45.19   51.95   68.00
#> incid_est[90]    46.18    0.45   9.29   30.05   39.53   45.50   51.96   66.85
#> incid_est[91]    46.46    0.42   8.77   31.05   40.20   45.86   51.98   65.76
#> incid_est[92]    46.76    0.39   8.26   32.08   40.91   46.25   52.01   64.66
#> incid_est[93]    47.06    0.36   7.74   33.13   41.60   46.65   51.98   63.62
#> incid_est[94]    47.38    0.34   7.23   34.24   42.31   47.01   51.96   62.73
#> incid_est[95]    47.70    0.31   6.72   35.41   43.02   47.36   51.96   61.81
#> incid_est[96]    48.04    0.28   6.22   36.48   43.73   47.75   52.03   61.10
#> incid_est[97]    48.38    0.25   5.73   37.59   44.46   48.16   52.02   60.24
#> incid_est[98]    48.74    0.22   5.26   38.78   45.15   48.55   52.08   59.44
#> incid_est[99]    49.10    0.19   4.81   39.87   45.80   48.95   52.16   58.93
#> incid_est[100]   49.48    0.16   4.39   40.92   46.45   49.41   52.30   58.32
#> incid_est[101]   49.87    0.13   4.01   41.95   47.18   49.75   52.50   57.95
#> incid_est[102]   50.27    0.11   3.70   42.86   47.84   50.17   52.72   57.65
#> incid_est[103]   50.68    0.08   3.48   43.75   48.35   50.64   52.99   57.65
#> incid_est[104]   51.11    0.06   3.37   44.52   48.84   51.04   53.26   58.00
#> incid_est[105]   51.54    0.06   3.39   44.89   49.32   51.52   53.65   58.51
#> incid_est[106]   51.99    0.07   3.55   45.19   49.67   51.91   54.23   59.36
#> incid_est[107]   52.45    0.09   3.82   45.21   49.93   52.30   54.90   60.48
#> incid_est[108]   52.93    0.12   4.21   45.14   50.04   52.81   55.62   61.76
#> incid_est[109]   53.42    0.15   4.68   44.95   50.18   53.26   56.42   63.36
#> incid_est[110]   53.92    0.19   5.22   44.62   50.30   53.66   57.23   65.18
#> incid_est[111]   54.44    0.22   5.82   44.24   50.40   54.09   58.05   67.08
#> incid_est[112]   54.97    0.26   6.47   43.81   50.43   54.54   58.84   69.12
#> incid_est[113]   55.51    0.30   7.15   43.30   50.48   54.95   59.84   71.22
#> incid_est[114]   56.07    0.35   7.88   42.80   50.52   55.41   60.80   73.46
#> incid_est[115]   56.65    0.39   8.64   42.20   50.53   55.89   61.75   75.99
#> incid_est[116]   57.24    0.43   9.43   41.46   50.59   56.35   62.84   78.70
#> incid_est[117]   57.85    0.48  10.25   40.88   50.61   56.91   63.90   81.24
#> lp__           1507.25    0.03   0.94 1504.78 1506.88 1507.56 1507.94 1508.18
#>                n_eff Rhat
#> log_i0           388 1.01
#> rt_est           386 1.01
#> incid_est[1]     843 1.01
#> incid_est[2]     770 1.01
#> incid_est[3]     770 1.01
#> incid_est[4]     769 1.01
#> incid_est[5]     765 1.01
#> incid_est[6]     760 1.01
#> incid_est[7]     753 1.01
#> incid_est[8]     745 1.01
#> incid_est[9]     736 1.01
#> incid_est[10]    728 1.01
#> incid_est[11]    719 1.01
#> incid_est[12]    711 1.01
#> incid_est[13]    702 1.01
#> incid_est[14]    694 1.01
#> incid_est[15]    687 1.01
#> incid_est[16]    679 1.01
#> incid_est[17]    672 1.01
#> incid_est[18]    664 1.01
#> incid_est[19]    658 1.01
#> incid_est[20]    651 1.01
#> incid_est[21]    644 1.01
#> incid_est[22]    636 1.01
#> incid_est[23]    631 1.01
#> incid_est[24]    625 1.01
#> incid_est[25]    619 1.01
#> incid_est[26]    613 1.01
#> incid_est[27]    608 1.01
#> incid_est[28]    602 1.01
#> incid_est[29]    597 1.01
#> incid_est[30]    592 1.01
#> incid_est[31]    586 1.01
#> incid_est[32]    580 1.01
#> incid_est[33]    575 1.01
#> incid_est[34]    569 1.01
#> incid_est[35]    564 1.01
#> incid_est[36]    559 1.01
#> incid_est[37]    554 1.01
#> incid_est[38]    549 1.01
#> incid_est[39]    545 1.01
#> incid_est[40]    541 1.01
#> incid_est[41]    536 1.01
#> incid_est[42]    532 1.01
#> incid_est[43]    528 1.01
#> incid_est[44]    524 1.01
#> incid_est[45]    521 1.01
#> incid_est[46]    517 1.01
#> incid_est[47]    514 1.01
#> incid_est[48]    511 1.01
#> incid_est[49]    508 1.01
#> incid_est[50]    505 1.01
#> incid_est[51]    502 1.01
#> incid_est[52]    499 1.01
#> incid_est[53]    497 1.01
#> incid_est[54]    494 1.01
#> incid_est[55]    492 1.01
#> incid_est[56]    489 1.01
#> incid_est[57]    487 1.01
#> incid_est[58]    485 1.01
#> incid_est[59]    480 1.01
#> incid_est[60]    475 1.01
#> incid_est[61]    470 1.01
#> incid_est[62]    466 1.01
#> incid_est[63]    462 1.01
#> incid_est[64]    458 1.01
#> incid_est[65]    453 1.01
#> incid_est[66]    449 1.01
#> incid_est[67]    445 1.01
#> incid_est[68]    441 1.01
#> incid_est[69]    437 1.01
#> incid_est[70]    434 1.01
#> incid_est[71]    430 1.01
#> incid_est[72]    427 1.01
#> incid_est[73]    424 1.01
#> incid_est[74]    421 1.01
#> incid_est[75]    418 1.01
#> incid_est[76]    416 1.01
#> incid_est[77]    414 1.01
#> incid_est[78]    414 1.01
#> incid_est[79]    414 1.01
#> incid_est[80]    415 1.01
#> incid_est[81]    416 1.01
#> incid_est[82]    416 1.01
#> incid_est[83]    418 1.01
#> incid_est[84]    419 1.01
#> incid_est[85]    421 1.01
#> incid_est[86]    422 1.01
#> incid_est[87]    424 1.01
#> incid_est[88]    426 1.01
#> incid_est[89]    428 1.01
#> incid_est[90]    432 1.01
#> incid_est[91]    437 1.01
#> incid_est[92]    443 1.01
#> incid_est[93]    452 1.01
#> incid_est[94]    464 1.01
#> incid_est[95]    480 1.00
#> incid_est[96]    502 1.00
#> incid_est[97]    535 1.00
#> incid_est[98]    579 1.00
#> incid_est[99]    637 1.00
#> incid_est[100]   733 1.00
#> incid_est[101]   903 1.00
#> incid_est[102]  1234 1.00
#> incid_est[103]  2013 1.00
#> incid_est[104]  3188 1.00
#> incid_est[105]  3415 1.00
#> incid_est[106]  2609 1.00
#> incid_est[107]  1828 1.00
#> incid_est[108]  1301 1.00
#> incid_est[109]   973 1.00
#> incid_est[110]   786 1.00
#> incid_est[111]   671 1.00
#> incid_est[112]   600 1.00
#> incid_est[113]   553 1.01
#> incid_est[114]   520 1.01
#> incid_est[115]   495 1.01
#> incid_est[116]   477 1.01
#> incid_est[117]   462 1.01
#> lp__             779 1.01
#> 
#> Samples were drawn using NUTS(diag_e) at Tue Aug 18 02:45: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).