Skip to contents

When there is a lag in the reception of data nowcast can be used to correct for this lag, and predict the true underlying values.

Usage

nowcast(
  data_aggregated,
  offset,
  n_week_adjusting,
  n_week_training,
  date_0,
  nowcast_correction_fn = nowcast_correction_fn_negbin_mm,
  nowcast_correction_sim_fn = nowcast_correction_sim_neg_bin
)

Arguments

data_aggregated

Aggregated dataset from the function nowcast_aggregate

offset

offset

n_week_adjusting

Total number of weeks to correct.

n_week_training

Number of weeks to train on

date_0

Date of aggregation.

nowcast_correction_fn

Correction function. The deafault is nowcast_correction_fn_expanded. Must return the same as this function.

nowcast_correction_sim_fn

Simmulatoin function. Must return a datatable with the following collumns "n_death", "sim_value", "cut_doe", "ncor" and simmulations for equally many weeks as n_week_adjust.

Value

Dataset including the corrected values for n_death

Details

For more details see the help vignette: vignette("nowcast", package="attrib")

Examples


data_aggregated <- attrib::data_fake_nowcasting_county_aggregated
n_week_training <- 50
n_week_adjusting <- 1
date_0 <- data_aggregated[order(cut_doe)][nrow(data_aggregated)]$cut_doe + 1
offset = "log(pop)"
nowcast_object <- attrib::nowcast(
  data_aggregated,
  offset,
  n_week_adjusting,
  n_week_training,
  date_0
)

data_aggregated <- attrib::data_fake_nowcasting_county_aggregated
data_aggregated <- data_aggregated[location_code == "county_nor03"]
n_week_training <- 50
n_week_adjusting <- 1
date_0 <- data_aggregated[order(cut_doe)][nrow(data_aggregated)]$cut_doe + 1
offset = "log(pop)"
nowcast_object <- nowcast(
  data_aggregated,
  offset,
  n_week_adjusting,
  n_week_training,
  date_0,
  nowcast_correction_fn = nowcast_correction_fn_quasipoisson,
  nowcast_correction_sim_fn = nowcast_correction_sim_quasipoisson
)