Prepare data for modelling with idbrm

Default method used when preparing data

prepare(data, ...)

# S3 method for default
prepare(data, model, ...)

Arguments

data

A dataframe to be used for modelling

...

Additional arguments passed to model specific prepare functions

model

Character string, model type to prepare to use. Supported options are "convolution".

Author

Sam Abbott

Sam Abbott

Examples

# define some example data
library(data.table)
dt <- data.table(
   region = "France", cases = seq(10, 500, by = 10),
   date = seq(as.Date("2020-10-01"), by = "days", length.out = 50)
   )
dt <- dt[, deaths := as.integer(shift(cases, 5) * 0.1)]
dt <- dt[is.na(deaths), deaths := 0]

dt <- prepare(
  dt, model = "convolution", location = "region",
  primary = "cases", secondary = "deaths",
  )
dt[]
#>     location       date time index init_obs cstart cmax primary secondary
#>  1:   France 2020-10-01    0     1        1      1    1      10         0
#>  2:   France 2020-10-02    1     2        1      1    2      20         0
#>  3:   France 2020-10-03    2     3        1      1    3      30         0
#>  4:   France 2020-10-04    3     4        1      1    4      40         0
#>  5:   France 2020-10-05    4     5        1      1    5      50         0
#>  6:   France 2020-10-06    5     6        1      1    6      60         1
#>  7:   France 2020-10-07    6     7        1      1    7      70         2
#>  8:   France 2020-10-08    7     8        1      1    8      80         3
#>  9:   France 2020-10-09    8     9        1      1    9      90         4
#> 10:   France 2020-10-10    9    10        1      1   10     100         5
#> 11:   France 2020-10-11   10    11        1      1   11     110         6
#> 12:   France 2020-10-12   11    12        1      1   12     120         7
#> 13:   France 2020-10-13   12    13        1      1   13     130         8
#> 14:   France 2020-10-14   13    14        1      1   14     140         9
#> 15:   France 2020-10-15   14    15        0      1   15     150        10
#> 16:   France 2020-10-16   15    16        0      1   16     160        11
#> 17:   France 2020-10-17   16    17        0      1   17     170        12
#> 18:   France 2020-10-18   17    18        0      1   18     180        13
#> 19:   France 2020-10-19   18    19        0      1   19     190        14
#> 20:   France 2020-10-20   19    20        0      1   20     200        15
#> 21:   France 2020-10-21   20    21        0      1   21     210        16
#> 22:   France 2020-10-22   21    22        0      1   22     220        17
#> 23:   France 2020-10-23   22    23        0      1   23     230        18
#> 24:   France 2020-10-24   23    24        0      1   24     240        19
#> 25:   France 2020-10-25   24    25        0      1   25     250        20
#> 26:   France 2020-10-26   25    26        0      1   26     260        21
#> 27:   France 2020-10-27   26    27        0      1   27     270        22
#> 28:   France 2020-10-28   27    28        0      1   28     280        23
#> 29:   France 2020-10-29   28    29        0      1   29     290        24
#> 30:   France 2020-10-30   29    30        0      1   30     300        25
#> 31:   France 2020-10-31   30    31        0      1   31     310        26
#> 32:   France 2020-11-01   31    32        0      2   31     320        27
#> 33:   France 2020-11-02   32    33        0      3   31     330        28
#> 34:   France 2020-11-03   33    34        0      4   31     340        29
#> 35:   France 2020-11-04   34    35        0      5   31     350        30
#> 36:   France 2020-11-05   35    36        0      6   31     360        31
#> 37:   France 2020-11-06   36    37        0      7   31     370        32
#> 38:   France 2020-11-07   37    38        0      8   31     380        33
#> 39:   France 2020-11-08   38    39        0      9   31     390        34
#> 40:   France 2020-11-09   39    40        0     10   31     400        35
#> 41:   France 2020-11-10   40    41        0     11   31     410        36
#> 42:   France 2020-11-11   41    42        0     12   31     420        37
#> 43:   France 2020-11-12   42    43        0     13   31     430        38
#> 44:   France 2020-11-13   43    44        0     14   31     440        39
#> 45:   France 2020-11-14   44    45        0     15   31     450        40
#> 46:   France 2020-11-15   45    46        0     16   31     460        41
#> 47:   France 2020-11-16   46    47        0     17   31     470        42
#> 48:   France 2020-11-17   47    48        0     18   31     480        43
#> 49:   France 2020-11-18   48    49        0     19   31     490        44
#> 50:   France 2020-11-19   49    50        0     20   31     500        45
#>     location       date time index init_obs cstart cmax primary secondary