Prepare index matrix for Rt
Arguments
- window
integer indicating the length of the window over which Rt is to be estimated. Window length is assumed to be the same for all locations. Default value is 7 i.e. Rt is estimated over a weekly window. Currently only non-overlapping windows are supported.
- nloc
integer. Number of locations.
- T
integer. Number of time steps
Details
This is a utility function that prepares the index matrix for Rt estimation in Stan. Say we have two locations and a time series of cases over 14 days. For each location, we want to estimate Rt over a 7 day window so that in all, the model has 4 parameters for Rt (two for each location). The matrix looks like:
1 | 3 |
1 | 3 |
1 | 3 |
1 | 3 |
1 | 3 |
1 | 3 |
1 | 3 |
1 | 3 |
2 | 4 |
2 | 4 |
2 | 4 |
2 | 4 |
2 | 4 |
2 | 4 |
2 | 4 |
The columns index the locations and the rows index the time points.
Examples
make_rindex(7, 2, 14)
#> [,1] [,2]
#> [1,] 1 2
#> [2,] 1 2
#> [3,] 1 2
#> [4,] 1 2
#> [5,] 1 2
#> [6,] 1 2
#> [7,] 1 2
#> [8,] 3 4
#> [9,] 3 4
#> [10,] 3 4
#> [11,] 3 4
#> [12,] 3 4
#> [13,] 3 4
#> [14,] 3 4
make_rindex(4, 2, 14)
#> Warning: data length [32] is not a sub-multiple or multiple of the number of rows [14]
#> [,1] [,2]
#> [1,] 1 2
#> [2,] 1 2
#> [3,] 1 2
#> [4,] 1 2
#> [5,] 3 4
#> [6,] 3 4
#> [7,] 3 4
#> [8,] 3 4
#> [9,] 5 6
#> [10,] 5 6
#> [11,] 5 6
#> [12,] 5 6
#> [13,] 7 8
#> [14,] 7 8