add_response_columns: Compute the corresponding observed response values for a set...

Description Usage Arguments Value Examples

View source: R/response.R

Description

The response for an observed data point at time t is defined as the mean of observed values on days t + s through t + e (inclusive) multiplied by e - s, where s and e are the number of days from forecast_date to the start and end, respectively, of the next full incidence_period. We choose to take the mean and multiply by the incidence period length rather than simply sum the observed values in order to avoid treating missing values as 0.

Usage

1
2
3
4
5
6
7
add_response_columns(
  signals,
  response_name,
  forecast_date,
  incidence_period,
  ahead
)

Arguments

signals

Wide data frame of signals. We expect the following columns:

  • geo_valueStrings of geographic locations.

  • time_valueDates of training data.

  • Covariate columnsColumns with names of the form value-{days}:{signal} or value+0:{signal} whose values correspond to signaldaysbeforetime_value'

response_name

Name of response signal. The value of the response variable on a single day should be located in column value+0:{response_name} of signals.

forecast_date

Date on which the forecast will be made

incidence_period

Time period over which the response should be summed.

ahead

integer or vector of integer ahead values

Value

Data frame of signals equal to signals with length(ahead) additional columns with names response+{a}:{response_name} corresponding to the response variable at ahead a.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
## Not run: 
add_response_columns(
  tibble(
    geo_value = "mi"
    time_value = seq.Date(as.Date("2020-07-01"), as.Date("2020-07-14"), "day"),
    `value+0:sig` = 1:14
  ),
  "sig",
  as.Date("2020-07-15"),
  "epiweek",
  1:2 
)

## End(Not run)

dshemetov/modeltools-mirror documentation built on Jan. 7, 2022, 12:23 a.m.