Description Usage Arguments Value Examples
Create training and test data matrices and training response for a set of given aheads. Works for both single ahead values and a vector of ahead values. For multiple ahead values, the function has the ability to return separate data matrices and responses for each ahead, or a single data matrix and response matrix for all aheads at once.
1 2 3 4 5 6 | create_train_and_predict_matrices(
lagged_df,
ahead,
training_window_size,
aheads_separate = TRUE
)
|
lagged_df |
Data frame of lagged data. It should have the following columns:
A data frame in this format can be made using |
ahead |
Number of incidence period units (i.e., epiweeks, days, etc.)
ahead to forecast. Can be a single positive integer or a vector of
positive integers. Note that for each |
training_window_size |
Size of the local training window in days to use. For example, if
|
aheads_separate |
If |
For a single ahead value, named list with entries:
train_x
: Matrix of training data whose columns correspond to the
value-{days}:{signal}
columns in lagged_df
. The training data consists of the
latest date with an non-null response, plus all data from the training_window_size
days prior to it.
train_y
: Vector of response data from the response+{ahead}:{response}
column of
lagged_df
corresponding to the rows of train_x
.
train_geo_values
: Vector of geo values corresponding to the rows
of train_x
.
train_time_values
: Vector of time values corresponding to the rows
of train_x
.
train_end_date
: Latest time_value
used in the training period.
predict_x
: Matrix of prediction data in the same format as train_x
. The
prediction data contains the most recent training_window_size
days.
predict_geo_values
: Vector of geo_values
corresponding to the rows of predict_x
.
predict_time_value
: Time value corresponding to predict_x
.
For multiple ahead values and aheads_separate = TRUE
, a list having
the same length as ahead
, with each element being a named list as above.
For multiple ahead values and ahead_separate = FALSE
, a named list as
above, except train_y
is a matrix of responses rather than a vector.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | ## Not run:
create_train_and_predict_matrices(
tibble(
geo_value = rep(c("az", "wv"), 5),
time_value = rep(
as.Date(c("2021-01-25", "2021-01-26", "2021-01-27", "2021-01-28", "2021-01-29")),
each = 2),
`value-2:signal_1` = seq(-3, 6),
`value-1:signal_1` = seq(-1, 8),
`value+0:signal_1` = seq(1, 10),
`response+2:signal_1` = c(seq(5, 10), rep(NA, 4))
),
ahead = 2,
training_window_size = 1)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.