Skip to contents

Evaluate the model on data, either summarised (per data-row) or per draw. You can use draws from the prior (prior = TRUE), select the parameter to predict from (“)

Usage

# S3 method for class 'mcpfit'
predict(
  object,
  newdata = NULL,
  summary = TRUE,
  probs = TRUE,
  rate = TRUE,
  prior = FALSE,
  varying = TRUE,
  arma = TRUE,
  ndraws = NULL,
  samples_format = "tidy",
  nsamples = lifecycle::deprecated(),
  ...
)

# S3 method for class 'mcpfit'
fitted(
  object,
  newdata = NULL,
  summary = TRUE,
  probs = TRUE,
  rate = TRUE,
  prior = FALSE,
  dpar = "epred",
  varying = TRUE,
  arma = TRUE,
  ndraws = NULL,
  samples_format = "tidy",
  scale = "response",
  nsamples = lifecycle::deprecated(),
  ...
)

# S3 method for class 'mcpfit'
log_lik(
  object,
  newdata = NULL,
  summary = TRUE,
  probs = TRUE,
  rate = TRUE,
  prior = FALSE,
  varying = TRUE,
  arma = TRUE,
  ndraws = NULL,
  samples_format = "tidy",
  nsamples = lifecycle::deprecated(),
  ...
)

# S3 method for class 'mcpfit'
residuals(
  object,
  newdata = NULL,
  summary = TRUE,
  probs = TRUE,
  prior = FALSE,
  varying = TRUE,
  arma = TRUE,
  ndraws = NULL,
  nsamples = lifecycle::deprecated(),
  ...
)

Arguments

object

An mcpfit object.

newdata

A tibble or a data.frame containing predictors in the model. Weighted Gaussian predictions and log-likelihoods also require the weights column. If NULL (default), the original data is used.

summary

Summarise at each x-value

probs

Vector of quantiles. Only in effect when summary == TRUE.

rate

Boolean. For binomial models, plot on raw data (rate = FALSE) or response divided by number of trials (rate = TRUE). If FALSE, linear interpolation on trial number is used to infer trials at a particular x.

prior

TRUE/FALSE. Plot using prior samples? Useful for mcp(..., sample = "both")

varying

One of:

  • TRUE All varying effects (fit$pars$varying).

  • FALSE No varying effects (c()).

  • "cp" or "predictor": All varying effects belonging to that part of the model.

  • Character vector: Only include specified varying parameters - see fit$pars$varying.

arma

Whether to include AR and MA effects.

  • TRUE Compute the GARMA residual recurrence. Requires the response variable in newdata.

  • FALSE Disregard AR and MA effects. For family = gaussian(), predict() uses only sigma for residuals.

ndraws

Integer or NULL. Number of posterior draws to return/summarise. If there are varying effects, this is the number of draws from each varying group. NULL means "all". Ignored if both are FALSE. More samples trade speed for accuracy.

samples_format

One of "tidy" or "matrix". Controls the output format when summary == FALSE. See more under "value"

nsamples

Deprecated. Use ndraws instead.

...

Currently ignored.

dpar

What distributional parameter to evaluate. This is only relevant when type == "fitted". E.g.,

  • "epred" (default): Expected value of the full model (or NULL for compatibility with brms etc.).

  • "mu": The central tendency which is often the mean after applying the link function.

  • "sigma": The standard deviation of the residuals.

  • "ar1", "ar2", "ma1", "ma2", etc. depending on which AR or MA coefficient you want to evaluate.

scale

One of

  • "response": return on the observed scale, i.e., after applying the inverse link function.

  • "linear": return on the parameter scale (where the linear trends are modelled). A linear scale is only applicable when type == "fitted" and dpar is not NULL.

Value

  • If summary = TRUE: A tibble with the posterior mean for each row in newdata, If newdata is NULL, the data in fit$data is used.

  • If summary = FALSE and samples_format = "tidy": A tidybayes tibble with all the posterior draws (Nd) evaluated at each row in newdata (Nn), i.e., with Nd x Nn rows. If there are varying effects, the returned data is expanded with the relevant levels for each row.

    The return columns are:

    • Predictors from newdata.

    • Draw descriptors: ".chain", ".iteration", ".draw" (see the posterior and tidybayes packages), and data_row, the row number in the evaluated newdata.

    • Draw values: one column for each parameter in the model.

    • The estimate. Either ".epred", ".prediction", ".residual", or ".loglik" (matching tidybayes/ggdist conventions).

  • If summary = FALSE and samples_format = "matrix": An N_draws X nrows(newdata) matrix with fitted/predicted values (depending on type). This format is used by brms and it's useful as yrep in bayesplot::ppc_* functions.

Details

residuals(fit) is equivalent to fit$data[, fit$data$yvar] - fitted(fit, ...) (or newdata[, fit$data$yvar] - fitted(fit, ...)), but with fixed arguments for fitted: rate = FALSE, dpar = 'epred', samples_format = 'tidy'.

Functions

  • predict(mcpfit): Predictive Distribution

  • fitted(mcpfit): Expected distribution

  • log_lik(mcpfit): Pointwise log-likelihood

  • residuals(mcpfit): Residual distribution

See also

fitted.mcpfit predict.mcpfit residuals.mcpfit log_lik.mcpfit

Author

Jonas Kristoffer Lindeløv jonas@lindeloev.dk

Examples

fitted(demo_fit)  # Expected value at each demo_fit$data at response-level
#>          time      fitted      error         Q2.5     Q97.5
#> 1   68.358202  -3.8734294  92.628899 -133.2366255  81.35973
#> 2   87.290378  -9.8013811 125.729855 -185.3273679 106.15168
#> 3   69.011729  -4.0780587  93.771515 -135.0347082  82.21553
#> 4   11.593608   9.8180335   4.322743    6.6647600  15.94916
#> 5   19.500912  11.4245293   7.236348    1.1935233  17.37858
#> 6   46.120086   3.0896621  53.748939  -72.0472322  52.23857
#> 7   20.353524  11.1575634   8.721308   -1.1516080  18.49442
#> 8   59.084924  -0.9698255  76.415749 -107.7206029  69.21623
#> 9   37.388807   5.8235579  38.484680  -48.0238146  40.80409
#> 10  14.129812  11.4773893   5.608786    5.0367011  18.75771
#> 11   9.615594   8.6550135   3.633588    5.5358827  13.76527
#> 12  70.287391  -4.4774879  96.001865 -138.5445034  83.88603
#> 13   7.758767   8.3515674   3.208319    5.5358827  12.84692
#> 14  23.489634  10.1755998  14.193764   -9.7796423  22.60122
#> 15  95.950016 -12.5128451 140.870447 -209.1546414 117.49160
#> 16  79.510013  -7.3652307 112.126640 -163.9196128  95.96318
#> 17  38.656645   5.4265785  40.701066  -51.5118738  42.46458
#> 18  97.626665 -13.0378292 143.801921 -213.7680579 119.68720
#> 19   9.528992   8.6232241   3.588992    5.5358827  13.66969
#> 20  58.190133  -0.6896529  74.851333 -105.2583819  68.04449
#> 21  47.231485   2.7416661  55.691988  -75.1057775  53.69397
#> 22  30.234626   8.0636406  25.979124  -28.3380198  31.43461
#> 23  11.030142   9.3300641   4.237057    5.9920158  15.32706
#> 24  57.175893  -0.3720790  73.078081 -102.4675097  66.71633
#> 25  79.074135  -7.2287506 111.364551 -162.7203456  95.39239
#> 26  63.825217  -2.4540831  84.703523 -120.7645981  75.42372
#> 27  31.130653   7.7830808  27.545234  -30.8031660  32.60781
#> 28  69.271777  -4.1594836  94.226179 -135.7501908  82.55607
#> 29  67.461543  -3.5926718  91.061195 -130.7696011  80.18554
#> 30  75.820274  -6.2099175 105.675510 -153.7675175  91.13142
#> 31  84.125595  -8.8104395 120.196532 -176.6197010 102.00735
#> 32  24.045424  10.0015736  15.164423  -11.3085981  23.32887
#> 33  67.976066  -3.7537768  91.960778 -132.1852347  80.85931
#> 34   7.044360   8.3515674   3.208319    5.5358827  12.84692
#> 35  64.656088  -2.7142414  86.156197 -123.0507995  76.51175
#> 36  10.212172   8.8740023   3.941022    5.5358827  14.42362
#> 37  95.576188 -12.3957940 140.216843 -208.1260287 117.00207
#> 38  74.823152  -5.8977035 103.932148 -151.0239758  89.82567
#> 39  15.022671   8.8780327   4.056311    3.0899120  12.04735
#> 40  30.762584   7.8983289  26.901902  -29.7907117  32.12590
#> 41  90.793112 -10.8981401 131.854062 -194.9650581 110.73856
#> 42  17.802365  11.9563699   4.290018    5.8663741  15.15422
#> 43  27.616005   8.8835704  21.402650  -21.1333337  28.00481
#> 44  40.488992   4.8528429  43.904365  -56.5536977  44.86440
#> 45  94.644115 -12.1039476 138.587195 -205.5613632 115.78151
#> 46  19.772106  11.3396143   7.708434    0.4477718  17.73351
#> 47  13.292427  11.2892356   4.737037    6.6647600  17.83037
#> 48  50.809429   1.6213574  61.947343  -84.9508097  58.37934
#> 49   7.211989   8.3515674   3.208319    5.5358827  12.84692
#> 50  57.526802  -0.4819538  73.691594 -103.4330744  67.17585
#> 51  76.796331  -6.5155358 107.382045 -156.4532272  92.40958
#> 52  31.227352   7.7528031  27.714251  -31.0691557  32.73442
#> 53   5.366188   8.3515674   3.208319    5.5358827  12.84692
#> 54  63.865112  -2.4665748  84.773274 -120.8743777  75.47596
#> 55  63.008080  -2.1982251  83.274862 -118.5160598  74.35366
#> 56  82.319290  -8.2448579 117.038382 -171.6497662  99.64197
#> 57  77.662850  -6.7868561 108.897064 -158.8373567  93.54430
#> 58  55.083675   0.2830263  69.420153  -96.7109822  63.97653
#> 59   3.189323   8.3515674   3.208319    5.5358827  12.84692
#> 60  25.126159   9.6631790  17.052232  -14.2823287  24.74422
#> 61  78.557222  -7.0668975 110.460782 -161.2981207  94.71549
#> 62  27.685278   8.8618800  21.523705  -21.3239577  28.09550
#> 63   9.996686   8.7949029   3.829933    5.5358827  14.18594
#> 64  51.781429   1.3170096  63.646714  -87.6251819  59.65219
#> 65  21.773154  10.7130559  11.197224   -5.0570638  20.35357
#> 66  51.064176   1.5415925  62.392722  -85.6517221  58.71294
#> 67  92.483152 -11.4273174 134.808944 -199.6153230 112.95170
#> 68  29.042409   8.4369417  23.895432  -25.0575333  29.87291
#> 69  40.717051   4.7814341  44.303061  -57.1811645  45.16308
#> 70  89.238087 -10.4112384 129.135244 -190.6863460 108.70224
#> 71  72.979633  -5.3204696 100.708952 -145.9518061  87.41156
#> 72  79.431137  -7.3405334 111.988733 -163.7025945  95.85989
#> 73   7.235543   8.3515674   3.208319    5.5358827  12.84692
#> 74  69.091993  -4.1031905  93.911847 -135.2555420  82.32064
#> 75  59.590785  -1.1282181  77.300176 -109.1125940  69.87867
#> 76  78.769829  -7.1334678 110.832503 -161.8830830  94.99390
#> 77  37.547305   5.7739299  38.761758  -48.4598716  41.01168
#> 78  17.174328  12.1530180   3.211577    7.5933816  14.59553
#> 79  80.493271  -7.6731037 113.845769 -166.6251029  97.25077
#> 80  68.500986  -3.9181375  92.878541 -133.6294765  81.54670
#> 81  91.055087 -10.9801686 132.312102 -195.6859021 111.08162
#> 82  88.064602 -10.0438024 127.083514 -187.4575887 107.16554
#> 83  62.383069  -2.0025247  82.182111 -116.7962000  73.53520
#> 84   8.269692   8.3515674   3.208319    5.5358827  12.84692
#> 85  97.959449 -13.1420289 144.383764 -214.6837357 120.12298
#> 86  78.931894  -7.1842128 111.115857 -162.3289862  95.20613
#> 87  42.760674   4.1415449  47.875788  -62.8042592  47.83937
#> 88  88.407677 -10.1512243 127.683348 -188.4015330 107.61480
#> 89   6.891265   8.3515674   3.208319    5.5358827  12.84692
#> 90  80.352612  -7.6290612 113.599840 -166.2380502  97.06658
#> 91  65.437734  -2.9589866  87.522808 -125.2013919  77.53533
#> 92  64.337373  -2.6144470  85.598964 -122.1738942  76.09439
#> 93  94.175260 -11.9571421 137.767444 -204.2712762 115.16754
#> 94  23.897683  10.0478334  14.906387  -10.9022589  23.13561
#> 95  89.799917 -10.5871559 130.117552 -192.2322147 109.43796
#> 96  36.277399   6.1715566  36.541794  -44.9658378  39.34849
#> 97  19.175607  11.5263873   6.670457    2.0882992  16.95257
#> 98  19.530958  11.4151215   7.288637    1.1108899  17.41794
#> 99  64.090664  -2.5371987  85.167624 -121.4950369  75.77132
#> 100 24.494405   9.8609909  15.948644  -12.5440553  23.91675
residuals(demo_fit)  # Residuals at each demo_fit$data at response-level
#>       response      time   residuals      error         Q2.5       Q97.5
#> 1   32.8426510 68.358202 36.71608039  92.628899  -48.5170750 166.0792764
#> 2   -1.1600031 87.290378  8.64137798 125.729855 -107.3116863 184.1673648
#> 3   27.5642483 69.011729 31.64230698  93.771515  -54.6512808 162.5989565
#> 4   10.0629707 11.593608  0.24493721   4.322743   -5.8861897   3.3982107
#> 5   14.0568587 19.500912  2.63232944   7.236348   -3.3217204  12.8633355
#> 6   18.2926399 46.120086 15.20297781  53.748939  -33.9459327  90.3398721
#> 7   19.0731820 20.353524  7.91561851   8.721308    0.5787627  20.2247899
#> 8   27.3770747 59.084924 28.34690022  76.415749  -41.8391590 135.0976777
#> 9   19.9843186 37.388807 14.16076070  38.484680  -20.8197748  68.0081332
#> 10  13.5488092 14.129812  2.07141984   5.608786   -5.2089020   8.5121081
#> 11   4.3533234  9.615594 -4.30169005   3.633588   -9.4119506  -1.1825593
#> 12   3.1576223 70.287391  7.63511018  96.001865  -80.7284050 141.7021257
#> 13   7.7904784  7.758767 -0.56108899   3.208319   -5.0564437   2.2545957
#> 14  11.7029532 23.489634  1.52735343  14.193764  -10.8982622  21.4825955
#> 15  -8.2719018 95.950016  4.24094330 140.870447 -125.7635053 200.8827397
#> 16  -4.4163499 79.510013  2.94888085 112.126640 -100.3795331 159.5032630
#> 17  14.2547640 38.656645  8.82818544  40.701066  -28.2098128  65.7666378
#> 18  -8.1652295 97.626665  4.87259978 143.801921 -127.8524287 205.6028284
#> 19   7.9582854  9.528992 -0.66493876   3.588992   -5.7114041   2.4224026
#> 20  26.6805483 58.190133 27.37020118  74.851333  -41.3639427 131.9389302
#> 21  16.7518560 47.231485 14.01018981  55.691988  -36.9421114  91.8576334
#> 22  15.6191542 30.234626  7.55551360  25.979124  -15.8154543  43.9571740
#> 23  14.7903983 11.030142  5.46033419   4.237057   -0.5366606   8.7983825
#> 24  21.1226275 57.175893 21.49470653  73.078081  -45.5937003 123.5901372
#> 25  -5.9706120 79.074135  1.25813862 111.364551 -101.3630064 156.7497336
#> 26  28.5108064 63.825217 30.96488951  84.703523  -46.9129108 149.2754045
#> 27  11.4476501 31.130653  3.66456928  27.545234  -21.1601584  42.2508161
#> 28  31.2250526 69.271777 35.38453619  94.226179  -51.3310128 166.9752435
#> 29  28.8388901 67.461543 32.43156190  91.061195  -51.3466478 159.6084912
#> 30   3.7722367 75.820274  9.98215421 105.675510  -87.3591806 157.5397541
#> 31  -2.7026836 84.125595  6.10775590 120.196532 -104.7100379 173.9170174
#> 32   4.5443436 24.045424 -5.45722993  15.164423  -18.7845286  15.8529417
#> 33  32.6078478 67.976066 36.36162461  91.960778  -48.2514654 164.7930825
#> 34   1.7222868  7.044360 -6.62928064   3.208319  -11.1246353  -3.8135959
#> 35  28.1791974 64.656088 30.89343877  86.156197  -48.3325571 151.2299969
#> 36  10.4960910 10.212172  1.62208867   3.941022   -3.9275300   4.9602082
#> 37  -4.9011144 95.576188  7.49467961 140.216843 -121.9031853 203.2249143
#> 38   0.3555765 74.823152  6.25328008 103.932148  -89.4700952 151.3795523
#> 39  16.6597318 15.022671  7.78169912   4.056311    4.6123809  13.5698198
#> 40   9.1642145 30.762584  1.26588562  26.901902  -22.9616841  38.9549262
#> 41  -9.8059185 90.793112  1.09222157 131.854062 -120.5444816 185.1591396
#> 42  15.6857499 17.802365  3.72938001   4.290018    0.5315263   9.8193758
#> 43   7.3890213 27.616005 -1.49454915  21.402650  -20.6157873  28.5223550
#> 44   8.5578125 40.488992  3.70496960  43.904365  -36.3065830  65.1115102
#> 45  -8.4186683 94.644115  3.68527933 138.587195 -124.2001756 197.1426949
#> 46  13.3568900 19.772106  2.01727569   7.708434   -4.3766174  12.9091182
#> 47   5.3279844 13.292427 -5.96125120   4.737037  -12.5023835  -1.3367755
#> 48  24.7543133 50.809429 23.13295593  61.947343  -33.6250292 109.7051231
#> 49  13.4366959  7.211989  5.08512847   3.208319    0.5897738   7.9008132
#> 50  23.3419988 57.526802 23.82395256  73.691594  -43.8338493 126.7750732
#> 51  -2.0139841 76.796331  4.50155167 107.382045  -94.4235622 154.4392430
#> 52   8.9270024 31.227352  1.17419929  27.714251  -23.8074202  39.9961581
#> 53  10.7452890  5.366188  2.39372160   3.208319   -2.1016331   5.2094063
#> 54  40.5875962 63.865112 43.05417098  84.773274  -34.8883638 161.4619739
#> 55  26.0241438 63.008080 28.22236885  83.274862  -48.3295207 144.5402035
#> 56  -4.8721557 82.319290  3.37270218 117.038382 -104.5141272 166.7776105
#> 57  -1.6331467 77.662850  5.15370938 108.897064  -95.1774438 157.2042100
#> 58  18.9480923 55.083675 18.66506594  69.420153  -45.0284424 115.6590745
#> 59   8.6060001  3.189323  0.25443270   3.208319   -4.2409220   3.0701174
#> 60   8.6427626 25.126159 -1.02041643  17.052232  -16.1014617  22.9250913
#> 61  -0.3479691 78.557222  6.71892842 110.460782  -95.0634593 160.9501516
#> 62  18.0435545 27.685278  9.18167454  21.523705  -10.0519466  39.3675123
#> 63   4.0044802  9.996686 -4.79042271   3.829933  -10.1814567  -1.5314025
#> 64  26.6364888 51.781429 25.31947916  63.646714  -33.0157024 114.2616707
#> 65   8.9374981 21.773154 -1.77555775  11.197224  -11.4160698  13.9945619
#> 66  17.9469358 51.064176 16.40534332  62.392722  -40.7660011 103.5986579
#> 67  -6.1992171 92.483152  5.22810030 134.808944 -119.1509126 193.4161059
#> 68   8.7363741 29.042409  0.29943237  23.895432  -21.1365361  33.7939074
#> 69  15.2315282 40.717051 10.45009406  44.303061  -29.9315556  72.4126927
#> 70  -7.6489856 89.238087  2.76225273 129.135244 -116.3512220 183.0373603
#> 71  -1.2016871 72.979633  4.11878250 100.708952  -88.6132437 144.7501190
#> 72  -3.8955827 79.431137  3.44495068 111.988733  -99.7554765 159.8070117
#> 73   4.8871989  7.235543 -3.46436852   3.208319   -7.9597232  -0.6486838
#> 74  27.2192476 69.091993 31.32243804  93.911847  -55.1013881 162.4747896
#> 75  23.1955844 59.590785 24.32380248  77.300176  -46.6830819 132.3081783
#> 76   0.9611046 78.769829  8.09457233 110.832503  -94.0327966 162.8441876
#> 77  13.2325313 37.547305  7.45860150  38.761758  -27.7791461  61.6924030
#> 78  11.3143540 17.174328 -0.83866401   3.211577   -3.2811734   3.7209724
#> 79   3.1298922 80.493271 10.80299595 113.845769  -94.1208817 169.7549951
#> 80  35.6749054 68.500986 39.59304290  92.878541  -45.8717992 169.3043819
#> 81  -4.4014973 91.055087  6.57867131 132.312102 -115.4831211 191.2844048
#> 82   3.9102359 88.064602 13.95403827 127.083514 -103.2553051 191.3678245
#> 83  26.8709589 62.383069 28.87348360  82.182111  -46.6642446 143.6671589
#> 84  11.8761325  8.269692  3.52456506   3.208319   -0.9707896   6.3402498
#> 85  -8.3734162 97.959449  4.76861270 144.383764 -128.4964006 206.3103196
#> 86   0.3784719 78.931894  7.56268469 111.115857  -94.8276558 162.7074581
#> 87  10.4305875 42.760674  6.28904263  47.875788  -37.4087818  73.2348467
#> 88   6.8704414 88.407677 17.02166569 127.683348 -100.7443606 195.2719745
#> 89  10.2799624  6.891265  1.92839497   3.208319   -2.5669597   4.7440797
#> 90  -7.5972620 80.352612  0.03179923 113.599840 -104.6638405 158.6407883
#> 91  29.0637171 65.437734 32.02270369  87.522808  -48.4716139 154.2651090
#> 92  26.1320993 64.337373 28.74654629  85.598964  -49.9622937 148.3059936
#> 93  -2.7574434 94.175260  9.19969868 137.767444 -117.9249785 201.5138328
#> 94  11.8948541 23.897683  1.84702071  14.906387  -11.2407511  22.7971130
#> 95  -0.8707143 89.799917  9.71644159 130.117552 -110.3086753 191.3615004
#> 96  17.2185637 36.277399 11.04700709  36.541794  -22.1299224  62.1844016
#> 97  12.6436194 19.175607  1.11723215   6.670457   -4.3089483  10.5553202
#> 98   8.6858310 19.530958 -2.72929049   7.288637   -8.7321069   7.5749411
#> 99  25.0445932 64.090664 27.58179187  85.167624  -50.7267313 146.5396301
#> 100  6.3817913 24.494405 -3.47919955  15.948644  -17.5349538  18.9258466
log_lik(demo_fit)  # Log-likelihood at each demo_fit$data
#>       response      time      loglik       error        Q2.5      Q97.5
#> 1   32.8426510 68.358202  -47.895545 41.55288998 -103.991230  -3.485247
#> 2   -1.1600031 87.290378 -104.872110 65.26311213 -177.254790 -15.929801
#> 3   27.5642483 69.011729  -49.817625 38.94069062  -99.816221  -4.040797
#> 4   10.0629707 11.593608   -3.295855  0.09602768   -3.423112  -3.182886
#> 5   14.0568587 19.500912   -3.349059  0.47663443   -3.982758  -2.818061
#> 6   18.2926399 46.120086  -18.751537 11.90917345  -33.148513  -3.791788
#> 7   19.0731820 20.353524   -3.603060  0.92388450   -4.871174  -2.672073
#> 8   27.3770747 59.084924  -33.735520 27.24612300  -69.954839  -3.548886
#> 9   19.9843186 37.388807  -10.813859  6.99028830  -20.248988  -3.333293
#> 10  13.5488092 14.129812   -3.327884  0.23608768   -3.644332  -3.065058
#> 11   4.3533234  9.615594   -3.544326  0.32948017   -4.005562  -3.230737
#> 12   3.1576223 70.287391  -61.714813 37.26891882 -101.468285 -10.323806
#> 13   7.7904784  7.758767   -3.230022  0.13552758   -3.385755  -3.052725
#> 14  11.7029532 23.489634   -4.289120  0.67533524   -5.062492  -3.404049
#> 15  -8.2719018 95.950016 -135.981570 87.24306257 -242.453091 -22.305707
#> 16  -4.4163499 79.510013  -87.506566 55.35173123 -155.422123 -15.618658
#> 17  14.2547640 38.656645  -12.401920  6.34859455  -19.155705  -3.825757
#> 18  -8.1652295 97.626665 -141.048210 90.35811934 -250.485788 -22.756662
#> 19   7.9582854  9.528992   -3.266719  0.09285138   -3.387231  -3.155678
#> 20  26.6805483 58.190133  -32.534203 25.93638400  -66.878036  -3.569245
#> 21  16.7518560 47.231485  -20.211163 12.31706868  -34.157099  -4.034949
#> 22  15.6191542 30.234626   -6.690531  2.87267961  -10.426993  -3.372952
#> 23  14.7903983 11.030142   -3.300787  0.44309274   -3.620950  -2.670978
#> 24  21.1226275 57.175893  -31.962262 22.30097324  -59.096666  -4.110858
#> 25  -5.9706120 79.074135  -87.671913 56.09516349 -158.428783 -16.289031
#> 26  28.5108064 63.825217  -40.829623 33.16494563  -84.659898  -3.654372
#> 27  11.4476501 31.130653   -7.606575  2.74110265   -9.890532  -3.727420
#> 28  31.2250526 69.271777  -49.691296 41.63123394 -105.079076  -3.654453
#> 29  28.8388901 67.461543  -46.856806 37.76333276  -96.301987  -3.801675
#> 30   3.7722367 75.820274  -73.175284 44.49911768 -118.367434 -11.149659
#> 31  -2.7026836 84.125595  -97.746200 61.17460643 -168.889733 -15.911986
#> 32   4.5443436 24.045424   -5.435909  1.73378468   -8.015200  -4.118892
#> 33  32.6078478 67.976066  -47.258694 40.89670690 -102.438757  -3.488415
#> 34   1.7222868  7.044360   -3.766513  0.54575757   -4.541825  -3.296411
#> 35  28.1791974 64.656088  -42.224115 33.94421200  -86.801981  -3.725557
#> 36  10.4960910 10.212172   -3.227216  0.23349814   -3.434490  -2.896685
#> 37  -4.9011144 95.576188 -131.672543 83.18004004 -227.961278 -20.183647
#> 38   0.3555765 74.823152  -73.144628 44.93502717 -124.024202 -12.348857
#> 39  16.6597318 15.022671   -3.483601  0.41126715   -4.050236  -3.067870
#> 40   9.1642145 30.762584   -7.755868  2.74074915  -10.658670  -3.958052
#> 41  -9.8059185 90.793112 -122.151669 79.40730116 -222.960815 -21.672638
#> 42  15.6857499 17.802365   -3.211513  0.43038897   -3.731049  -2.671248
#> 43   7.3890213 27.616005   -6.417236  2.01027021   -9.109130  -3.983108
#> 44   8.5578125 40.488992  -15.191236  7.45460255  -22.647857  -4.761666
#> 45  -8.4186683 94.644115 -132.164589 84.93086098 -236.527997 -21.996885
#> 46  13.3568900 19.772106   -3.395874  0.43470634   -3.987062  -2.932022
#> 47   5.3279844 13.292427   -3.902467  0.78593089   -5.033846  -3.305948
#> 48  24.7543133 50.809429  -23.181277 18.02854489  -47.278789  -3.440178
#> 49  13.4366959  7.211989   -3.252354  0.40792385   -3.547740  -2.672299
#> 50  23.3419988 57.526802  -32.061642 23.60277631  -62.005225  -3.861147
#> 51  -2.0139841 76.796331  -79.265473 49.38242218 -137.833112 -13.828703
#> 52   8.9270024 31.227352   -8.069031  2.94292562  -11.258488  -4.015528
#> 53  10.7452890  5.366188   -3.179005  0.31471662   -3.441654  -2.733308
#> 54  40.5875962 63.865112  -40.431920 41.27347026  -98.474369  -3.234150
#> 55  26.0241438 63.008080  -39.892406 30.80232028  -79.584890  -3.866786
#> 56  -4.8721557 82.319290  -94.849758 60.10847196 -168.266005 -16.555145
#> 57  -1.6331467 77.662850  -81.011152 50.36572195 -140.000651 -13.852543
#> 58  18.9480923 55.083675  -29.483857 19.51044183  -52.175457  -4.266766
#> 59   8.6060001  3.189323   -3.202186  0.19159695   -3.394844  -2.938244
#> 60   8.6427626 25.126159   -5.161542  1.13035895   -6.596637  -3.708712
#> 61  -0.3479691 78.557222  -82.202020 50.78992329 -139.673087 -13.471307
#> 62  18.0435545 27.685278   -5.455171  2.53325932   -9.031911  -3.239923
#> 63   4.0044802  9.996686   -3.623482  0.43204674   -4.234201  -3.235480
#> 64  26.6364888 51.781429  -24.181672 19.76162253  -51.001349  -3.358936
#> 65   8.9374981 21.773154   -4.072378  0.42706765   -4.642125  -3.535462
#> 66  17.9469358 51.064176  -24.461046 15.65480860  -42.528960  -4.127955
#> 67  -6.1992171 92.483152 -123.689551 78.65611140 -217.900555 -20.041977
#> 68   8.7363741 29.042409   -6.891968  2.20992262   -9.438719  -3.907324
#> 69  15.2315282 40.717051  -13.999003  7.66303388  -22.505731  -3.831241
#> 70  -7.6489856 89.238087 -115.722672 74.31573072 -207.902117 -19.944256
#> 71  -1.2016871 72.979633  -70.132708 43.42885044 -121.709272 -12.621450
#> 72  -3.8955827 79.431137  -86.912213 54.78667045 -153.529001 -15.342480
#> 73   4.8871989  7.235543   -3.414252  0.16181200   -3.626691  -3.225832
#> 74  27.2192476 69.091993  -50.028794 38.83585898  -99.668961  -4.090372
#> 75  23.1955844 59.590785  -35.099154 25.64681093  -67.233567  -3.999619
#> 76   0.9611046 78.769829  -81.793046 50.27706698 -136.719263 -12.937194
#> 77  13.2325313 37.547305  -11.677578  5.64901116  -17.261020  -3.877886
#> 78  11.3143540 17.174328   -3.170304  0.26724167   -3.430495  -2.798186
#> 79   3.1298922 80.493271  -84.436922 51.70909126 -136.972383 -12.370795
#> 80  35.6749054 68.500986  -47.917399 43.75806221 -107.938170  -3.325619
#> 81  -4.4014973 91.055087 -117.976824 74.41108436 -204.854436 -18.625517
#> 82   3.9102359 88.064602 -103.135874 63.63704457 -164.309059 -13.688455
#> 83  26.8709589 62.383069  -38.770660 30.56251641  -78.667369  -3.743103
#> 84  11.8761325  8.269692   -3.195909  0.36249964   -3.479830  -2.680941
#> 85  -8.3734162 97.959449 -142.291631 91.23146245 -252.988482 -22.989876
#> 86   0.3784719 78.931894  -82.580272 50.87808682 -138.994834 -13.230092
#> 87  10.4305875 42.760674  -16.896245  8.62894530  -23.879760  -4.635275
#> 88   6.8704414 88.407677 -102.000293 63.15464244 -156.541461 -12.458369
#> 89  10.2799624  6.891265   -3.177905  0.29147761   -3.428642  -2.766096
#> 90  -7.5972620 80.352612  -92.144525 59.63262331 -168.737991 -17.465029
#> 91  29.0637171 65.437734  -43.388647 35.41541901  -90.184566  -3.677702
#> 92  26.1320993 64.337373  -42.028224 32.39238598  -83.606983  -3.930709
#> 93  -2.7574434 94.175260 -125.586878 78.71337211 -213.497928 -18.578053
#> 94  11.8948541 23.897683   -4.396498  0.76073507   -5.274834  -3.404789
#> 95  -0.8707143 89.799917 -111.493677 69.38818659 -187.143820 -16.416998
#> 96  17.2185637 36.277399  -10.221470  5.69432393  -17.483431  -3.459155
#> 97  12.6436194 19.175607   -3.330335  0.34755468   -3.785655  -2.926262
#> 98   8.6858310 19.530958   -3.618499  0.13240976   -3.822428  -3.470924
#> 99  25.0445932 64.090664  -41.820950 31.51905893  -81.707302  -4.049219
#> 100  6.3817913 24.494405   -5.270505  1.40136672   -7.327654  -3.917343

# All of the above take a range of arguments. E.g.,:
# \donttest{
predict(demo_fit)  # Pointwise posterior predictive
#>          time     predict      error       Q2.5     Q97.5
#> 1   68.358202  -4.0657629  93.093027 -149.70814  88.43254
#> 2   87.290378  -9.6798235 126.002185 -202.19702 113.12770
#> 3   69.011729  -4.3005440  94.384904 -152.46861  89.60782
#> 4   11.593608  10.0024037  10.328177  -11.78021  28.57860
#> 5   19.500912  11.5264674  12.126087  -16.65276  31.13856
#> 6   46.120086   3.1660870  54.725907  -88.74548  59.87680
#> 7   20.353524  11.0295838  12.881439  -18.62562  31.71073
#> 8   59.084924  -1.1783482  77.432325 -125.30974  76.68757
#> 9   37.388807   5.9124009  39.517530  -63.42641  48.81414
#> 10  14.129812  11.3805802  10.655249  -11.74100  28.77485
#> 11   9.615594   8.6568784  10.233898  -13.29145  26.36729
#> 12  70.287391  -4.4863207  96.349673 -154.91777  91.48804
#> 13   7.758767   8.4537861   9.902162  -12.93541  25.92746
#> 14  23.489634  10.1224599  17.023126  -27.25523  34.90695
#> 15  95.950016 -12.4165917 141.232967 -226.15018 124.38848
#> 16  79.510013  -7.1739900 112.257794 -180.04676 103.22083
#> 17  38.656645   5.2097515  41.951360  -69.27828  50.70292
#> 18  97.626665 -13.1284863 144.192726 -229.46528 126.79710
#> 19   9.528992   8.6260034  10.090844  -12.86144  26.73391
#> 20  58.190133  -0.4559627  75.370193 -123.15702  76.21201
#> 21  47.231485   2.9721343  56.440710  -91.95071  61.39366
#> 22  30.234626   7.9163538  27.621331  -45.44702  40.32635
#> 23  11.030142   9.2476194  10.354847  -12.26431  27.02823
#> 24  57.175893  -0.2375677  73.792824 -119.28284  74.61400
#> 25  79.074135  -7.3734015 112.204589 -179.46667 102.89677
#> 26  63.825217  -2.5631142  85.627443 -137.97430  83.27228
#> 27  31.130653   7.6778889  29.151358  -47.46613  41.30351
#> 28  69.271777  -4.0842445  94.439351 -152.15388  89.49524
#> 29  67.461543  -3.4251034  91.580223 -146.21513  87.74595
#> 30  75.820274  -6.3460731 106.292405 -170.03702  98.50334
#> 31  84.125595  -8.6869691 120.456454 -192.90623 108.93452
#> 32  24.045424   9.8486160  17.699913  -27.39649  34.20929
#> 33  67.976066  -3.9538967  92.436684 -149.81556  88.30388
#> 34   7.044360   8.4453465  10.018945  -12.57958  26.32568
#> 35  64.656088  -2.6615872  86.843497 -140.32097  83.89105
#> 36  10.212172   8.9626952  10.366288  -13.18275  26.60715
#> 37  95.576188 -12.5995902 140.592820 -225.51201 124.29958
#> 38  74.823152  -6.0544955 104.322039 -167.58611  97.09284
#> 39  15.022671   8.6477986  10.621896  -15.53133  27.83082
#> 40  30.762584   7.8918412  28.251956  -45.64572  40.92317
#> 41  90.793112 -10.6782328 131.895347 -211.14987 118.09718
#> 42  17.802365  11.9258815  10.423240  -10.93421  30.29716
#> 43  27.616005   8.7789377  23.379516  -39.39651  37.56119
#> 44  40.488992   4.4355742  45.327745  -75.39274  52.95720
#> 45  94.644115 -12.2190179 138.895095 -222.61033 122.43252
#> 46  19.772106  11.4601174  12.318720  -16.59352  32.04380
#> 47  13.292427  11.2967430  10.693392  -12.16205  29.40281
#> 48  50.809429   1.3893513  62.557346 -100.58000  66.09273
#> 49   7.211989   8.4096843   9.964065  -13.28762  26.31208
#> 50  57.526802  -0.8826112  74.582211 -120.00721  74.91218
#> 51  76.796331  -6.8263534 108.002286 -172.81430 100.01816
#> 52  31.227352   7.6230491  29.648695  -48.46265  41.85172
#> 53   5.366188   8.6553264  10.105572  -12.85745  27.19404
#> 54  63.865112  -2.3660723  85.347917 -137.69312  83.04094
#> 55  63.008080  -2.1639834  83.896135 -135.16723  82.34112
#> 56  82.319290  -8.0632068 117.371267 -187.57244 106.69978
#> 57  77.662850  -6.7715470 109.259309 -175.11675 101.09122
#> 58  55.083675   0.2553030  70.169117 -113.41942  71.81444
#> 59   3.189323   8.2889516  10.047235  -13.65173  26.19345
#> 60  25.126159   9.8528534  19.293921  -29.75716  35.98047
#> 61  78.557222  -7.3708596 111.180304 -179.66521 102.44083
#> 62  27.685278   8.9341177  23.584321  -37.60265  38.39332
#> 63   9.996686   8.8518214  10.159851  -13.06817  26.56015
#> 64  51.781429   1.5353362  64.217594 -103.67827  67.21865
#> 65  21.773154  10.5401443  14.589069  -21.22011  32.06547
#> 66  51.064176   1.4387654  63.146645 -103.47764  66.38952
#> 67  92.483152 -11.5581097 135.106919 -216.28080 120.13283
#> 68  29.042409   8.9119467  25.307628  -40.94355  39.87333
#> 69  40.717051   4.9682620  45.318834  -73.94195  53.36500
#> 70  89.238087  -9.9902623 129.314164 -206.31356 116.16586
#> 71  72.979633  -5.5063558 101.203509 -162.14679  94.83343
#> 72  79.431137  -7.3701538 112.245749 -179.23878 103.12375
#> 73   7.235543   8.3595820   9.942229  -13.88307  25.59875
#> 74  69.091993  -3.9362094  93.995294 -151.02182  88.91635
#> 75  59.590785  -1.0969526  77.478329 -124.43899  76.90448
#> 76  78.769829  -7.2060941 111.185075 -179.52086 102.20317
#> 77  37.547305   5.7188319  39.718305  -64.64614  49.18199
#> 78  17.174328  12.1067854  10.196436  -10.96890  30.88243
#> 79  80.493271  -7.8227315 114.239959 -183.45586 103.90658
#> 80  68.500986  -4.1415705  93.489881 -150.02579  88.50400
#> 81  91.055087 -10.8465980 132.728346 -212.15561 118.43296
#> 82  88.064602 -10.0657126 127.692905 -203.80492 114.55817
#> 83  62.383069  -2.0818651  82.467135 -133.25345  81.15474
#> 84   8.269692   8.3269318   9.856956  -12.87110  25.83082
#> 85  97.959449 -12.9266397 144.496738 -229.04578 126.70228
#> 86  78.931894  -7.0158632 111.194038 -177.51146 102.00352
#> 87  42.760674   4.2085408  48.953936  -80.13887  55.70044
#> 88  88.407677 -10.3050549 128.167339 -205.54183 114.72150
#> 89   6.891265   8.4159022   9.822859  -12.80957  26.40429
#> 90  80.352612  -7.4324290 113.972360 -182.39213 104.43725
#> 91  65.437734  -3.0787176  88.050027 -141.99947  84.09710
#> 92  64.337373  -2.7030322  85.764615 -137.86510  83.86526
#> 93  94.175260 -12.1433743 138.487325 -221.25885 122.23130
#> 94  23.897683   9.9028082  17.873970  -28.77143  33.96266
#> 95  89.799917 -10.5645377 130.908881 -208.79186 117.07192
#> 96  36.277399   6.2723495  37.644561  -61.24683  47.55421
#> 97  19.175607  11.5978853  11.461595  -13.78638  30.80601
#> 98  19.530958  11.3217770  12.187564  -16.18093  31.32000
#> 99  64.090664  -2.6331600  86.131909 -138.30806  82.94448
#> 100 24.494405  10.0138784  18.515909  -29.06135  35.03418
predict(demo_fit, probs = c(0.1, 0.5, 0.9))  # With median and 80% credible interval.
#>          time     predict      error         Q10       Q50       Q90
#> 1   68.358202  -3.7742291  93.025178 -139.355902 41.140026  83.64385
#> 2   87.290378  -9.9920780 126.353533 -191.041698 50.354728 108.35821
#> 3   69.011729  -4.4894157  94.491000 -140.951695 40.446278  83.92784
#> 4   11.593608   9.8465048  10.616076   -4.546222 11.194752  22.17783
#> 5   19.500912  11.7884947  11.920052   -5.582181 13.692694  25.07571
#> 6   46.120086   3.0649976  54.353299  -77.732589 29.047733  54.55312
#> 7   20.353524  11.3599080  13.021011   -7.526944 13.783840  25.46840
#> 8   59.084924  -1.1720525  76.936605 -113.669764 35.899564  71.08252
#> 9   37.388807   5.5786253  39.617255  -53.848337 24.178309  43.79137
#> 10  14.129812  11.2672051  10.870430   -3.759500 12.811687  23.55293
#> 11   9.615594   8.6505288  10.139828   -4.874596  9.539642  20.51206
#> 12  70.287391  -4.6178942  96.651730 -144.603783 42.074815  85.83873
#> 13   7.758767   8.5926877  10.198327   -5.217065  9.759107  20.37590
#> 14  23.489634  10.1347869  16.760571  -15.443078 15.055643  28.35515
#> 15  95.950016 -12.2169002 141.198624 -214.361980 55.669093 119.57429
#> 16  79.510013  -7.0725071 112.205347 -168.810064 46.806441  97.59093
#> 17  38.656645   5.2433433  42.032263  -57.799949 25.248471  45.22865
#> 18  97.626665 -12.9060425 144.135281 -218.978307 56.115809 121.31199
#> 19   9.528992   8.7099371   9.865165   -4.365635  9.681604  20.28608
#> 20  58.190133  -0.9282534  75.920789 -112.352112 36.235076  70.32501
#> 21  47.231485   2.7840707  56.566855  -81.348488 30.279488  56.23050
#> 22  30.234626   8.0187348  27.503319  -34.368970 20.576750  35.27012
#> 23  11.030142   9.2720189  10.505501   -5.580452 10.205265  21.69637
#> 24  57.175893  -0.3508768  73.501299 -107.811668 35.123187  68.88998
#> 25  79.074135  -7.0064158 111.650994 -168.352277 46.076660  97.67601
#> 26  63.825217  -2.6340287  85.350535 -127.002435 38.365041  77.45341
#> 27  31.130653   7.7552772  29.345143  -37.148807 21.257013  36.75371
#> 28  69.271777  -3.8124907  94.546496 -141.623114 41.689233  84.60053
#> 29  67.461543  -3.3776545  91.394815 -135.484377 40.558224  82.07251
#> 30  75.820274  -6.3078368 106.288164 -160.448839 44.848932  92.91547
#> 31  84.125595  -8.9045971 120.862825 -182.694657 49.321861 103.81153
#> 32  24.045424  10.1226998  17.784788  -17.086951 15.933170  29.01910
#> 33  67.976066  -3.6441625  92.280238 -137.650755 40.347976  82.92745
#> 34   7.044360   7.9865014  10.126699   -5.567449  9.021680  19.63211
#> 35  64.656088  -2.8724309  86.626253 -128.686303 38.774506  78.65355
#> 36  10.212172   8.9190754  10.207448   -4.869934 10.167058  20.57054
#> 37  95.576188 -12.5599136 140.585658 -213.792785 55.087253 118.35673
#> 38  74.823152  -6.1716780 104.846944 -157.563884 44.122090  91.63170
#> 39  15.022671   8.6388013  10.216073   -4.562714  9.446340  20.27606
#> 40  30.762584   7.6941636  28.596850  -35.786497 20.059007  36.38820
#> 41  90.793112 -10.9903165 132.436292 -201.102484 52.196826 112.58793
#> 42  17.802365  12.1465154  10.341410   -1.866310 12.938295  24.19703
#> 43  27.616005   8.7899485  23.482560  -26.900172 18.264205  32.95343
#> 44  40.488992   4.6636338  45.296313  -63.108728 26.518051  47.68441
#> 45  94.644115 -11.8807095 138.868408 -210.178388 54.610975 117.96329
#> 46  19.772106  11.3711976  11.984257   -5.814840 13.263109  24.80379
#> 47  13.292427  11.2919397  10.589639   -3.677330 12.707320  23.60925
#> 48  50.809429   1.7652996  62.441176  -90.212641 32.019679  60.74142
#> 49   7.211989   8.2807904  10.156420   -5.575243  9.306126  20.43373
#> 50  57.526802  -0.3050042  74.153466 -108.840632 35.894654  69.41096
#> 51  76.796331  -6.3369875 107.885872 -161.771600 44.920545  94.63336
#> 52  31.227352   7.8008725  29.267536  -37.019740 21.343052  36.77472
#> 53   5.366188   8.1049259   9.964406   -5.361185  8.988667  19.67924
#> 54  63.865112  -2.7056171  85.373328 -126.771254 38.283075  77.63190
#> 55  63.008080  -2.0353339  83.786652 -124.027900 38.193984  76.54948
#> 56  82.319290  -8.6801632 117.819208 -178.196002 47.747590 101.34136
#> 57  77.662850  -6.8988989 109.537585 -165.298902 45.790224  95.50007
#> 58  55.083675   0.5902695  69.736753 -101.177470 34.878124  66.42160
#> 59   3.189323   8.4458311  10.035864   -5.129468  9.378762  20.13241
#> 60  25.126159   9.7201224  19.598720  -20.094275 16.343949  30.45128
#> 61  78.557222  -7.3093266 111.268161 -167.727545 46.003831  96.47500
#> 62  27.685278   8.8324078  23.576072  -26.988003 18.545553  33.13409
#> 63   9.996686   8.9128073  10.233610   -4.735399  9.942420  20.98643
#> 64  51.781429   1.6973753  64.279189  -93.190484 32.674255  62.04719
#> 65  21.773154  10.4263325  14.950663  -11.750301 14.141857  26.52798
#> 66  51.064176   1.4571991  63.076483  -91.357533 32.256620  60.90513
#> 67  92.483152 -11.3681752 135.263154 -205.103919 53.058011 114.62584
#> 68  29.042409   8.5608625  25.588510  -31.334399 19.661717  34.27459
#> 69  40.717051   4.9796914  45.078354  -62.698705 26.785875  47.98148
#> 70  89.238087 -10.3021509 129.405285 -196.380129 52.257904 110.09152
#> 71  72.979633  -5.3714585 101.059277 -151.980222 43.069750  89.39320
#> 72  79.431137  -7.3062387 112.456748 -169.431801 46.499609  97.78733
#> 73   7.235543   8.5959420  10.017681   -4.657947  9.367502  20.22485
#> 74  69.091993  -4.1850169  94.266025 -140.892287 40.424782  84.51819
#> 75  59.590785  -1.0219372  77.776026 -114.277909 36.501506  72.01933
#> 76  78.769829  -6.8857923 110.967589 -166.718056 45.537907  96.83104
#> 77  37.547305   5.7405415  40.348528  -54.507887 25.325592  44.34580
#> 78  17.174328  11.7738312  10.097875   -1.470115 12.348654  23.87100
#> 79  80.493271  -7.7124568 114.134144 -172.786957 47.032580  99.14512
#> 80  68.500986  -3.9682201  93.846180 -140.713212 41.649409  83.85473
#> 81  91.055087 -10.6852107 132.773814 -200.845629 52.769159 112.93709
#> 82  88.064602 -10.4144231 127.527193 -193.272893 49.993233 109.08926
#> 83  62.383069  -1.8497969  82.803035 -122.336978 38.154617  75.67503
#> 84   8.269692   8.2440298  10.287553   -5.740191  9.165273  20.38824
#> 85  97.959449 -13.2306391 144.939735 -220.698782 56.545786 121.41300
#> 86  78.931894  -7.2112330 111.707402 -168.345812 46.296284  97.18926
#> 87  42.760674   4.1421007  48.824677  -67.990778 27.995341  50.25125
#> 88  88.407677 -10.0062591 127.863382 -193.764547 51.036518 109.38754
#> 89   6.891265   8.5066830  10.145973   -4.987590  9.541418  20.13295
#> 90  80.352612  -7.5187987 113.770772 -171.550896 46.836620  98.99178
#> 91  65.437734  -3.0053577  88.260768 -131.228719 39.341562  79.58317
#> 92  64.337373  -2.5855603  86.386984 -128.361467 38.915801  77.90018
#> 93  94.175260 -11.8968376 138.251473 -209.717561 54.544177 117.00700
#> 94  23.897683  10.1961068  17.597056  -16.749159 15.872591  28.97821
#> 95  89.799917 -10.3720316 130.077923 -196.766418 51.530681 111.38637
#> 96  36.277399   6.4067140  37.431438  -50.332098 23.924775  42.58407
#> 97  19.175607  11.3944063  11.967587   -4.931478 13.325483  24.60466
#> 98  19.530958  11.5152313  11.876071   -5.044795 13.266419  25.09048
#> 99  64.090664  -2.5774819  85.558688 -127.659215 38.514320  77.86022
#> 100 24.494405   9.8575461  18.510256  -18.705084 16.050884  29.20468
predict(demo_fit, prior = TRUE)  # Prior predictive
#>          time   predict    error      Q2.5    Q97.5
#> 1   68.358202  9.743556 37.16303 -56.18930 78.85524
#> 2   87.290378  9.812440 40.55113 -70.41119 87.91277
#> 3   69.011729 10.086329 35.05216 -58.44957 75.77600
#> 4   11.593608 10.473446 36.27339 -48.95286 70.55380
#> 5   19.500912 10.176890 32.58657 -44.84733 68.06819
#> 6   46.120086 10.404575 31.44677 -49.83854 70.59806
#> 7   20.353524 11.096997 34.45005 -43.78335 72.30008
#> 8   59.084924  9.206021 34.81511 -54.77243 72.52632
#> 9   37.388807 10.390022 32.73931 -49.21778 68.35006
#> 10  14.129812 10.444396 29.38805 -51.58558 67.75368
#> 11   9.615594 10.276259 32.85810 -49.39504 66.53651
#> 12  70.287391  9.262508 36.22981 -61.52042 77.43086
#> 13   7.758767 11.434315 30.71925 -41.36692 68.58081
#> 14  23.489634 10.599100 31.28526 -48.21091 71.19591
#> 15  95.950016 10.706792 41.51099 -72.01735 93.83137
#> 16  79.510013 10.536658 37.89305 -62.81165 82.50507
#> 17  38.656645 10.059224 30.41115 -53.68245 68.08615
#> 18  97.626665 10.915798 42.40087 -73.18353 96.37373
#> 19   9.528992 10.279652 30.06240 -49.84202 65.40713
#> 20  58.190133  9.770380 33.66179 -53.28615 78.87857
#> 21  47.231485 10.779436 37.97080 -50.36936 74.16369
#> 22  30.234626 10.627405 31.30327 -48.58394 68.52656
#> 23  11.030142 11.178326 40.16549 -46.31078 67.06393
#> 24  57.175893 10.022607 32.04901 -51.64380 70.38129
#> 25  79.074135 10.341016 37.03072 -65.44017 81.65660
#> 26  63.825217 10.825235 35.08402 -53.14017 78.84897
#> 27  31.130653 10.363310 37.95504 -46.56718 70.13397
#> 28  69.271777  9.655580 35.70965 -60.02748 76.62285
#> 29  67.461543  9.945820 34.97404 -52.57216 77.92734
#> 30  75.820274 10.769120 36.65072 -58.25171 79.79015
#> 31  84.125595 10.223658 44.12491 -68.23771 83.10604
#> 32  24.045424 10.883902 30.31207 -44.51700 71.66922
#> 33  67.976066 10.463106 35.68297 -58.68687 78.71433
#> 34   7.044360 10.799861 29.92389 -48.26465 64.96419
#> 35  64.656088 10.447385 37.24048 -52.98792 77.33977
#> 36  10.212172 10.367683 30.71453 -49.50184 69.76970
#> 37  95.576188 10.563090 43.88254 -77.07914 89.25352
#> 38  74.823152 10.502313 35.54646 -58.73366 80.59015
#> 39  15.022671 10.025445 32.89160 -47.78623 66.00418
#> 40  30.762584 11.268144 30.73525 -46.32109 68.15134
#> 41  90.793112 10.829702 42.91398 -70.46735 90.92354
#> 42  17.802365  9.999819 33.20960 -48.08909 64.43501
#> 43  27.616005 10.289344 29.95310 -46.15859 65.55654
#> 44  40.488992 10.591783 29.94056 -50.21962 68.72217
#> 45  94.644115 10.461549 41.19763 -72.03806 92.21211
#> 46  19.772106 10.957232 30.78776 -49.28956 67.17929
#> 47  13.292427 10.176046 32.25321 -47.06951 69.69505
#> 48  50.809429 10.020426 32.80589 -49.89173 70.52244
#> 49   7.211989 10.817030 32.16525 -45.20698 70.52538
#> 50  57.526802  9.575470 33.04511 -53.77783 72.81410
#> 51  76.796331  9.945328 35.80249 -64.26524 81.05487
#> 52  31.227352 10.694427 32.45519 -53.41747 71.50924
#> 53   5.366188 10.074967 29.29607 -48.47457 66.82704
#> 54  63.865112  9.790327 34.38807 -57.16644 73.45550
#> 55  63.008080  9.832690 38.22830 -57.01431 77.01556
#> 56  82.319290 10.287417 37.98531 -64.22191 81.75160
#> 57  77.662850 11.208780 40.48729 -60.94318 82.75461
#> 58  55.083675 11.002034 35.58499 -49.68598 73.62941
#> 59   3.189323  9.853684 39.66359 -46.83911 68.35389
#> 60  25.126159 10.537311 32.85235 -47.56962 66.24399
#> 61  78.557222 10.222541 40.41159 -62.76514 83.38859
#> 62  27.685278 10.308975 31.54166 -48.97727 68.54106
#> 63   9.996686 10.305577 31.61234 -45.96819 70.54068
#> 64  51.781429 10.522951 33.75987 -51.47781 74.62250
#> 65  21.773154 10.664626 33.20406 -46.12818 69.33087
#> 66  51.064176 10.499474 33.36636 -53.10088 73.31699
#> 67  92.483152 10.537248 39.64769 -68.06217 88.81349
#> 68  29.042409 10.888995 33.88791 -47.00960 71.00065
#> 69  40.717051 10.477293 32.65838 -47.17609 68.84190
#> 70  89.238087 11.017348 42.67954 -69.79644 89.22092
#> 71  72.979633 10.159116 35.99020 -60.88645 80.94141
#> 72  79.431137 10.041481 38.78152 -64.82215 80.03866
#> 73   7.235543 10.562063 31.78667 -46.27598 66.99007
#> 74  69.091993  9.584407 36.96397 -59.51089 75.41191
#> 75  59.590785  9.604742 35.01069 -55.44704 74.69574
#> 76  78.769829  9.996010 37.39721 -64.27808 81.07288
#> 77  37.547305  9.740625 32.74766 -52.66415 67.60825
#> 78  17.174328 10.346013 37.99592 -44.67010 67.67072
#> 79  80.493271  9.906018 37.09356 -63.61282 79.02506
#> 80  68.500986  9.162510 34.80583 -56.47226 73.79499
#> 81  91.055087 10.468991 41.83597 -67.28600 86.62746
#> 82  88.064602 11.227056 41.88453 -65.71747 89.18247
#> 83  62.383069  9.610829 38.17221 -50.91597 73.08635
#> 84   8.269692 10.774998 28.89768 -44.50904 65.98469
#> 85  97.959449 11.207650 41.21186 -70.25397 92.49589
#> 86  78.931894 11.077734 37.12163 -62.09847 81.62133
#> 87  42.760674 10.362778 31.85896 -51.19109 71.14144
#> 88  88.407677 10.340182 39.13167 -67.60022 86.99004
#> 89   6.891265 10.722479 29.28010 -47.09392 69.84873
#> 90  80.352612 10.873683 37.59785 -62.63101 85.32121
#> 91  65.437734  9.856516 32.86617 -56.43569 74.65461
#> 92  64.337373 10.535998 34.24074 -54.80088 76.83472
#> 93  94.175260 10.559264 40.34899 -73.05833 89.64461
#> 94  23.897683 10.604851 32.72603 -49.77998 67.47715
#> 95  89.799917 10.772920 42.81719 -71.82987 89.73499
#> 96  36.277399 11.078838 42.69688 -50.32571 72.50050
#> 97  19.175607 10.181057 28.89495 -46.93744 67.26000
#> 98  19.530958 10.469065 31.50456 -46.01769 69.05526
#> 99  64.090664 10.065627 34.16697 -57.10960 74.71038
#> 100 24.494405  9.857780 31.54406 -49.91552 66.57978
fitted(demo_fit, summary = FALSE)  # Samples instead of summary. Useful for plotting distributions.
#> # A tibble: 300,000 × 13
#>    .chain .iteration .draw  cp_1  cp_2 Intercept_1 time_2 Intercept_3 time_3
#>     <int>      <int> <int> <dbl> <dbl>       <dbl>  <dbl>       <dbl>  <dbl>
#>  1      1          1     1  10.7  16.2        5.54   1.52        14.1  0.533
#>  2      1          1     1  10.7  16.2        5.54   1.52        14.1  0.533
#>  3      1          1     1  10.7  16.2        5.54   1.52        14.1  0.533
#>  4      1          1     1  10.7  16.2        5.54   1.52        14.1  0.533
#>  5      1          1     1  10.7  16.2        5.54   1.52        14.1  0.533
#>  6      1          1     1  10.7  16.2        5.54   1.52        14.1  0.533
#>  7      1          1     1  10.7  16.2        5.54   1.52        14.1  0.533
#>  8      1          1     1  10.7  16.2        5.54   1.52        14.1  0.533
#>  9      1          1     1  10.7  16.2        5.54   1.52        14.1  0.533
#> 10      1          1     1  10.7  16.2        5.54   1.52        14.1  0.533
#> # ℹ 299,990 more rows
#> # ℹ 4 more variables: sigma_1 <dbl>, time <dbl>, data_row <int>, .epred <dbl>
fitted(demo_fit, dpar = "sigma")  # Another model parameter
#>          time  fitted    error     Q2.5    Q97.5
#> 1   68.358202 9.17495 2.507259 5.742978 11.73071
#> 2   87.290378 9.17495 2.507259 5.742978 11.73071
#> 3   69.011729 9.17495 2.507259 5.742978 11.73071
#> 4   11.593608 9.17495 2.507259 5.742978 11.73071
#> 5   19.500912 9.17495 2.507259 5.742978 11.73071
#> 6   46.120086 9.17495 2.507259 5.742978 11.73071
#> 7   20.353524 9.17495 2.507259 5.742978 11.73071
#> 8   59.084924 9.17495 2.507259 5.742978 11.73071
#> 9   37.388807 9.17495 2.507259 5.742978 11.73071
#> 10  14.129812 9.17495 2.507259 5.742978 11.73071
#> 11   9.615594 9.17495 2.507259 5.742978 11.73071
#> 12  70.287391 9.17495 2.507259 5.742978 11.73071
#> 13   7.758767 9.17495 2.507259 5.742978 11.73071
#> 14  23.489634 9.17495 2.507259 5.742978 11.73071
#> 15  95.950016 9.17495 2.507259 5.742978 11.73071
#> 16  79.510013 9.17495 2.507259 5.742978 11.73071
#> 17  38.656645 9.17495 2.507259 5.742978 11.73071
#> 18  97.626665 9.17495 2.507259 5.742978 11.73071
#> 19   9.528992 9.17495 2.507259 5.742978 11.73071
#> 20  58.190133 9.17495 2.507259 5.742978 11.73071
#> 21  47.231485 9.17495 2.507259 5.742978 11.73071
#> 22  30.234626 9.17495 2.507259 5.742978 11.73071
#> 23  11.030142 9.17495 2.507259 5.742978 11.73071
#> 24  57.175893 9.17495 2.507259 5.742978 11.73071
#> 25  79.074135 9.17495 2.507259 5.742978 11.73071
#> 26  63.825217 9.17495 2.507259 5.742978 11.73071
#> 27  31.130653 9.17495 2.507259 5.742978 11.73071
#> 28  69.271777 9.17495 2.507259 5.742978 11.73071
#> 29  67.461543 9.17495 2.507259 5.742978 11.73071
#> 30  75.820274 9.17495 2.507259 5.742978 11.73071
#> 31  84.125595 9.17495 2.507259 5.742978 11.73071
#> 32  24.045424 9.17495 2.507259 5.742978 11.73071
#> 33  67.976066 9.17495 2.507259 5.742978 11.73071
#> 34   7.044360 9.17495 2.507259 5.742978 11.73071
#> 35  64.656088 9.17495 2.507259 5.742978 11.73071
#> 36  10.212172 9.17495 2.507259 5.742978 11.73071
#> 37  95.576188 9.17495 2.507259 5.742978 11.73071
#> 38  74.823152 9.17495 2.507259 5.742978 11.73071
#> 39  15.022671 9.17495 2.507259 5.742978 11.73071
#> 40  30.762584 9.17495 2.507259 5.742978 11.73071
#> 41  90.793112 9.17495 2.507259 5.742978 11.73071
#> 42  17.802365 9.17495 2.507259 5.742978 11.73071
#> 43  27.616005 9.17495 2.507259 5.742978 11.73071
#> 44  40.488992 9.17495 2.507259 5.742978 11.73071
#> 45  94.644115 9.17495 2.507259 5.742978 11.73071
#> 46  19.772106 9.17495 2.507259 5.742978 11.73071
#> 47  13.292427 9.17495 2.507259 5.742978 11.73071
#> 48  50.809429 9.17495 2.507259 5.742978 11.73071
#> 49   7.211989 9.17495 2.507259 5.742978 11.73071
#> 50  57.526802 9.17495 2.507259 5.742978 11.73071
#> 51  76.796331 9.17495 2.507259 5.742978 11.73071
#> 52  31.227352 9.17495 2.507259 5.742978 11.73071
#> 53   5.366188 9.17495 2.507259 5.742978 11.73071
#> 54  63.865112 9.17495 2.507259 5.742978 11.73071
#> 55  63.008080 9.17495 2.507259 5.742978 11.73071
#> 56  82.319290 9.17495 2.507259 5.742978 11.73071
#> 57  77.662850 9.17495 2.507259 5.742978 11.73071
#> 58  55.083675 9.17495 2.507259 5.742978 11.73071
#> 59   3.189323 9.17495 2.507259 5.742978 11.73071
#> 60  25.126159 9.17495 2.507259 5.742978 11.73071
#> 61  78.557222 9.17495 2.507259 5.742978 11.73071
#> 62  27.685278 9.17495 2.507259 5.742978 11.73071
#> 63   9.996686 9.17495 2.507259 5.742978 11.73071
#> 64  51.781429 9.17495 2.507259 5.742978 11.73071
#> 65  21.773154 9.17495 2.507259 5.742978 11.73071
#> 66  51.064176 9.17495 2.507259 5.742978 11.73071
#> 67  92.483152 9.17495 2.507259 5.742978 11.73071
#> 68  29.042409 9.17495 2.507259 5.742978 11.73071
#> 69  40.717051 9.17495 2.507259 5.742978 11.73071
#> 70  89.238087 9.17495 2.507259 5.742978 11.73071
#> 71  72.979633 9.17495 2.507259 5.742978 11.73071
#> 72  79.431137 9.17495 2.507259 5.742978 11.73071
#> 73   7.235543 9.17495 2.507259 5.742978 11.73071
#> 74  69.091993 9.17495 2.507259 5.742978 11.73071
#> 75  59.590785 9.17495 2.507259 5.742978 11.73071
#> 76  78.769829 9.17495 2.507259 5.742978 11.73071
#> 77  37.547305 9.17495 2.507259 5.742978 11.73071
#> 78  17.174328 9.17495 2.507259 5.742978 11.73071
#> 79  80.493271 9.17495 2.507259 5.742978 11.73071
#> 80  68.500986 9.17495 2.507259 5.742978 11.73071
#> 81  91.055087 9.17495 2.507259 5.742978 11.73071
#> 82  88.064602 9.17495 2.507259 5.742978 11.73071
#> 83  62.383069 9.17495 2.507259 5.742978 11.73071
#> 84   8.269692 9.17495 2.507259 5.742978 11.73071
#> 85  97.959449 9.17495 2.507259 5.742978 11.73071
#> 86  78.931894 9.17495 2.507259 5.742978 11.73071
#> 87  42.760674 9.17495 2.507259 5.742978 11.73071
#> 88  88.407677 9.17495 2.507259 5.742978 11.73071
#> 89   6.891265 9.17495 2.507259 5.742978 11.73071
#> 90  80.352612 9.17495 2.507259 5.742978 11.73071
#> 91  65.437734 9.17495 2.507259 5.742978 11.73071
#> 92  64.337373 9.17495 2.507259 5.742978 11.73071
#> 93  94.175260 9.17495 2.507259 5.742978 11.73071
#> 94  23.897683 9.17495 2.507259 5.742978 11.73071
#> 95  89.799917 9.17495 2.507259 5.742978 11.73071
#> 96  36.277399 9.17495 2.507259 5.742978 11.73071
#> 97  19.175607 9.17495 2.507259 5.742978 11.73071
#> 98  19.530958 9.17495 2.507259 5.742978 11.73071
#> 99  64.090664 9.17495 2.507259 5.742978 11.73071
#> 100 24.494405 9.17495 2.507259 5.742978 11.73071

# Evaluate at novel data
novel_data = data.frame(time = c(-5, 20, 300))  # Only predictors are needed
predict(demo_fit, newdata = novel_data, probs = c(0.025, 0.5, 0.975))
#>   time    predict     error       Q2.5        Q50     Q97.5
#> 1   -5   7.940359  10.16065  -13.38864   8.877179  26.24067
#> 2   20  11.511261  12.63866  -17.30368  13.911995  31.68086
#> 3  300 -76.585885 497.60254 -785.30489 159.365002 389.04721
# }