Convert data into mcstate format; this is a thin wrapper around
mcstate::particle_filter_data() which adds a dummy step in front
of the first data point so that we can use the previous state and
the current states to convert cumulative measures into net daily
changes.
sircovid_data(data, start_date, dt)
| data | A |
|---|---|
| start_date | The start date, as a |
| dt | The time step (fraction of a day that each step represents) as used to create the model object |
A data.frame suitable for use with mcstate functions
such as mcstate::particle_filter() and mcstate::pmcmc()
# A data sert that has data from the first of February to the first of # March (one column of data called 'x') from <- as.Date("2020-02-01") to <- as.Date("2020-03-01") d <- data.frame(date = seq(from, to, by = 1), x = runif(to - from + 1), stringsAsFactors = FALSE) # Get this ready for sircovid/mcstate assuming the seeding starts on # the 15th of January and we take 4 steps per day. sircovid_data(d, start_date = "2020-01-15", 1 / 4)#> date_start date_end step_start step_end x #> 1 15 32 60 128 0.46118646 #> 2 32 33 128 132 0.31524175 #> 3 33 34 132 136 0.17467589 #> 4 34 35 136 140 0.53157354 #> 5 35 36 140 144 0.49363702 #> 6 36 37 144 148 0.77930863 #> 7 37 38 148 152 0.20417834 #> 8 38 39 152 156 0.71339728 #> 9 39 40 156 160 0.06521611 #> 10 40 41 160 164 0.35420680 #> 11 41 42 164 168 0.82519942 #> 12 42 43 168 172 0.27381825 #> 13 43 44 172 176 0.57004495 #> 14 44 45 176 180 0.33571908 #> 15 45 46 180 184 0.59626279 #> 16 46 47 184 188 0.19151803 #> 17 47 48 188 192 0.94776394 #> 18 48 49 192 196 0.54248041 #> 19 49 50 196 200 0.54460339 #> 20 50 51 200 204 0.27859715 #> 21 51 52 204 208 0.44670247 #> 22 52 53 208 212 0.37151118 #> 23 53 54 212 216 0.02806097 #> 24 54 55 216 220 0.46598719 #> 25 55 56 220 224 0.39003139 #> 26 56 57 224 228 0.02006522 #> 27 57 58 228 232 0.37697093 #> 28 58 59 232 236 0.55991284 #> 29 59 60 236 240 0.85708359 #> 30 60 61 240 244 0.38480971