Skip to contents

Example

library(diseasenowcasting)

# Create a fake disease process
set.seed(265824)
sims <- simulate_process_for_testing()

# Run a nowcast with very few iterations
predictions <- nowcast(sims, "onset_date", "report_date", cores = 4)
#> ℹ Computing a nowcast for 2024-09-11 per "days"
#> ℹ Assuming data is count-data where counts are in column `n`. To change this set `data_type = "linelist"`

#Get the predicted values
preds <- predictions |> 
  posterior::as_draws() |> 
  posterior::subset_draws("N_predict") |> 
  posterior::summarise_draws()

preds
#> # A tibble: 10 × 10
#>    variable         mean median    sd   mad    q5   q95   rhat ess_bulk ess_tail
#>    <chr>           <dbl>  <dbl> <dbl> <dbl> <dbl> <dbl>  <dbl>    <dbl>    <dbl>
#>  1 N_predict[1,1]  7485    7485  0     0     7485  7485 NA          NA       NA 
#>  2 N_predict[2,1]  7178    7178  0     0     7178  7178 NA          NA       NA 
#>  3 N_predict[3,1] 16581   16581  0     0    16581 16581 NA          NA       NA 
#>  4 N_predict[4,1] 28006.  28005  3.05  2.97 28003 28012  1.00     4082.    3605.
#>  5 N_predict[5,1] 16233.  16232  4.49  4.45 16228 16242  1.00     4062.    4093.
#>  6 N_predict[6,1] 14445.  14444  5.43  4.45 14438 14456  0.999    3876.    3760.
#>  7 N_predict[7,1]  6076.   6075  6.20  5.93  6067  6087  1.00     3798.    3599.
#>  8 N_predict[8,1]  2219.   2217  7.06  5.93  2209  2232  1.00     3821.    4016.
#>  9 N_predict[9,1]  3486.   3485  7.76  7.41  3476  3500  1.00     4150.    4082.
#> 10 N_predict[10,… 56870.  56869  8.48  7.41 56858 56886  1.00     4161.    3921.