diff --git a/R/epinowcast.R b/R/epinowcast.R index e7ed8048b..359189fc8 100644 --- a/R/epinowcast.R +++ b/R/epinowcast.R @@ -111,8 +111,10 @@ epinowcast <- function(data, data = data ), expectation = epinowcast::enw_expectation( - formula = ~ rw(day, .group), + r = ~ rw(day, .group), generation_time = 1, + observation = ~1, + latent_reporting_delay = 1, data = data ), missing = epinowcast::enw_missing( diff --git a/R/model-modules.R b/R/model-modules.R index 681cf50ee..710be6c3b 100644 --- a/R/model-modules.R +++ b/R/model-modules.R @@ -219,48 +219,76 @@ enw_report <- function(non_parametric = ~0, structural = ~0, data) { #' Expectation model module #' -#' @param formula A formula (as implemented in [enw_formula()]) describing +#' @param r A formula (as implemented in [enw_formula()]) describing #' the generative process used for expected incidence. This can use features #' defined by reference date as defined in `metareference` as produced by #' [enw_preprocess_data()]. By default this is set to use a daily group -#' specific random walk. Note that the daily group specific random walk is -#' currently the only option supported by [epinowcast()]. +#' specific random walk. #' #' @param generation_time A numeric vector that sums to 1 and defaults to 1. #' Describes the weighting to apply to previous generations (i.e as part of a #' renewal equation). When set to 1 (the default) this corresponds to modelling #' the daily growth rate. #' +#' @param observation A formula (as implemented in [enw_formula()]) describing +#' the modifiers used to adjust expected observations. This can use features +#' defined by reference date as defined in `metareference` as produced by +#' [enw_preprocess_data()]. By default no modifiers are used but a common choice +#' might be to adjust for the day of the week. Note as the baseline is no +#' modification an intercept is always used and it is set to 0. +#' +#' @param latent_reporting_delay A numeric vector that defaults to 1. +#' Describes the weighting to apply to past and current latent expected +#' observations (from most recent to least). This can be used both to convolve +#' based on some assumed reporting delay and to rescale obserations (by +#' multiplying a probability mass function by some fraction) to account +#' ascertainment etc. +#' +#' @param ... Additional parameters passed to [enw_add_metaobs_features()]. The +#' same arguments as passed to `enw_preprocess_data()` should be used here. #' @inherit enw_report return #' @inheritParams enw_obs #' @family modelmodules #' @export #' @examples #' enw_expectation(data = enw_example("preprocessed")) -enw_expectation <- function(formula = ~ rw(day, by = .group), - generation_time = 1, data) { - if (as_string_formula(formula) %in% "~0") { - stop("An expectation model formula must be specified") +enw_expectation <- function(r = ~ rw(day, by = .group), generation_time = 1, + observation = ~1, latent_reporting_delay = 1, + data, ...) { + if (as_string_formula(r) %in% "~0") { + stop("An expectation model formula for r must be specified") + } + if (as_string_formula(observation) %in% "~0") { + observation <- ~1 } - if (sum(generation_time) != 1) { stop("The generation time must sum to 1") } - features <- data$metareference[[1]] - features <- features[ + # Set up growth rate features + r_features <- data$metareference[[1]] + if (length(latent_reporting_delay) > 1) { + r_features <- enw_extend_date( + r_features, + days = length(latent_reporting_delay) - 1, direction = "start" + ) + enw_add_metaobs_features(r_features, ...) + } + r_features <- r_features[ date >= (min(date) + length(generation_time)) ] + # Growth rate indicator variables r_list <- list( r_seed = length(generation_time), gt_n = length(generation_time), lrgt = log(rev(generation_time)), - t = nrow(features), + t = nrow(r_features), obs = 0 ) r_list$g <- cumsum(rep(r_list$t, data$groups[[1]])) - r_list$t + r_list$ft <- r_list$t + r_list$r_seed # Initial prior for seeding observations latest_matrix <- latest_obs_as_matrix(data$latest[[1]]) @@ -268,33 +296,60 @@ enw_expectation <- function(formula = ~ rw(day, by = .group), seed_obs <- purrr::map(seed_obs, ~ rep(log(.), r_list$gt_n)) seed_obs <- round(unlist(seed_obs), 1) - form <- enw_formula(formula, features, sparse = FALSE) - data <- enw_formula_as_data_list( - form, + # Growth rate model formula + r_form <- enw_formula(r, r_features, sparse = FALSE) + r_data <- enw_formula_as_data_list( + r_form, prefix = "expr", drop_intercept = TRUE ) + # Observation indicator variables + obs_list <- list( + lrd_n = length(latent_reporting_delay), + lrlrd = log(rev(latent_reporting_delay)) + ) + obs_list$obs <- ifelse( + sum(latent_reporting_delay) == 1 && obs_list$lrd_n == 1 && + as_string_formula(observation) %in% "~1", + 0, 1 + ) + # Observation formula + obs_form <- enw_formula(observation, data$metareference[[1]], sparse = FALSE) + obs_data <- enw_formula_as_data_list( + obs_form, + prefix = "expo", drop_intercept = TRUE + ) + out <- list() - out$formula$expectation <- form$formula + out$formula$r <- r_form$formula + out$formula$observation <- obs_form$formula + out$data_raw$r <- r_features + out$data_raw$observation <- data$metareference[[1]] + names(r_list) <- paste0("expr_", names(r_list)) - out$data <- c(r_list, data) + names(obs_list) <- paste0("expo_", names(obs_list)) + out$data <- c(r_list, r_data, obs_list, obs_data) + out$priors <- data.table::data.table( variable = c( "expr_r_int", "expr_beta_sd", - rep("expr_leobs_int", length(seed_obs)) + rep("expr_leobs_int", length(seed_obs)), + "expo_beta_sd" ), - dimension = c(1, 1, seq_along(seed_obs)), + dimension = c(1, 1, seq_along(seed_obs), 1), description = c( "Intercept of the log growth rate", - "Standard deviation of scaled pooled expectation effects", + "Standard deviation of scaled pooled log growth rate effects", rep("Intercept for initial log observations (ordered by group and then - time)", length(seed_obs)) + time)", length(seed_obs)), + "Standard deviation of scaled pooled log growth rate effects" ), distribution = c( - "Normal", "Zero truncated normal", rep("Normal", length(seed_obs)) + "Normal", "Zero truncated normal", rep("Normal", length(seed_obs)), + "Zero truncated normal" ), - mean = c(0, 0, seed_obs), - sd = c(0.2, 0.1, rep(1, length(seed_obs))) + mean = c(0, 0, seed_obs, 0), + sd = c(0.2, 1, rep(1, length(seed_obs)), 1) ) out$inits <- function(data, priors) { priors <- enw_priors_as_data_list(priors) @@ -312,17 +367,28 @@ enw_expectation <- function(formula = ~ rw(day, by = .group), )), expr_r_int = rnorm( 1, priors$expr_r_int[1], priors$expr_r_int[2] * 0.1 - ) + ), + expo_beta = numeric(0), + expo_beta_sd = numeric(0) ) if (data$expr_fncol > 0) { init$expr_beta <- rnorm(data$expr_fncol, 0, 0.01) } - if (data$ expr_rncol > 0) { + if (data$expr_rncol > 0) { init$expr_beta_sd <- abs(rnorm( data$expr_rncol, priors$expr_beta_sd_p[1], priors$expr_beta_sd_p[2] / 10 )) } + if (data$expo_fncol > 0) { + init$expo_beta <- rnorm(data$expo_fncol, 0, 0.01) + } + if (data$expo_rncol > 0) { + init$expo_beta_sd <- abs(rnorm( + data$expo_rncol, priors$expo_beta_sd_p[1], + priors$expo_beta_sd_p[2] / 10 + )) + } return(init) } return(fn) diff --git a/R/preprocess.R b/R/preprocess.R index 62e401f70..57456f50c 100644 --- a/R/preprocess.R +++ b/R/preprocess.R @@ -165,20 +165,31 @@ enw_add_metaobs_features <- function(metaobs, #' @title FUNCTION_TITLE #' @description FUNCTION_DESCRIPTION #' @param metaobs PARAM_DESCRIPTION -#' @param max_delay PARAM_DESCRIPTION, Default: 20 +#' @param days +#' @param direction Should new dates be added at the begining or end of +#' the data. Default is "end" with "start" also available #' @return OUTPUT_DESCRIPTION #' @family preprocess #' @export #' @importFrom data.table copy data.table rbindlist setkeyv #' @importFrom purrr map -enw_extend_date <- function(metaobs, max_delay = 20) { +enw_extend_date <- function(metaobs, days = 20, direction = "end") { + direction <- match.arg(direction, choices = c("start", "end")) + + new_days <- 1:days + if (direction %in% "start") { + new_days <- -new_days + filt_fn <- min + } else { + filt_fn <- max + } exts <- data.table::copy(metaobs) - exts <- exts[, .SD[date == max(date)], by = .group] + exts <- exts[, .SD[date == filt_fn(date)], by = .group] exts <- split(exts, by = ".group") exts <- purrr::map( exts, ~ data.table::data.table( - extend_date = .$date + 1:(max_delay - 1), + extend_date = .$date + new_days, . ) ) @@ -920,7 +931,10 @@ enw_preprocess_data <- function(obs, by = c(), max_delay = 20, # extract and extend report date meta data to include unobserved reports metareport <- enw_metadata(reference_available, target_date = "report_date") - metareport <- enw_extend_date(metareport, max_delay = max_delay) + metareport <- enw_extend_date( + metareport, + days = max_delay - 1, direction = "end" + ) metareport <- enw_add_metaobs_features(metareport, ...) # extract and add features for reference date diff --git a/inst/examples/germany_latent_renewal.R b/inst/examples/germany_latent_renewal.R new file mode 100644 index 000000000..30c9d2a5b --- /dev/null +++ b/inst/examples/germany_latent_renewal.R @@ -0,0 +1,156 @@ +# Load packages +library(epinowcast) +library(data.table) +library(ggplot2) + +# Use 2 cores +options(mc.cores = 2) + +# Load and filter germany hospitalisations +nat_germany_hosp <- germany_covid19_hosp[location == "DE"][age_group %in% "00+"] +nat_germany_hosp <- enw_filter_report_dates( + nat_germany_hosp, + latest_date = "2021-10-01" +) + +# Make sure observations are complete +nat_germany_hosp <- enw_complete_dates( + nat_germany_hosp, + by = c("location", "age_group") +) +# Make a retrospective dataset +retro_nat_germany <- enw_filter_report_dates( + nat_germany_hosp, + remove_days = 40 +) +retro_nat_germany <- enw_filter_reference_dates( + retro_nat_germany, + include_days = 40 +) + +# Get latest observations for the same time period +latest_obs <- enw_latest_data(nat_germany_hosp) +latest_obs <- enw_filter_reference_dates( + latest_obs, + remove_days = 40, include_days = 20 +) + +# Preprocess observations (note this maximum delay is likely too short) +pobs <- enw_preprocess_data(retro_nat_germany, max_delay = 20) + +# Compile nowcasting model using multi-threading +model <- enw_model(threads = TRUE, stanc_options = list("O1")) + +# Reference date model: Fixed log-normal distribution +reference_module <- enw_reference(~1, data = pobs) + +# Report date model: Day of week reporting effect +report_module <- enw_report(~ (1 | day_of_week), data = pobs) + +# Expectation model: +# - Weekly random walk on the growth rate +# - Generation time with probability mass spread over 4 days +# - latent reporting delay representing the incubation period and assumed +# ascertainment +# - Day of week reporting effect +expectation_module <- enw_expectation( + r = ~ rw(week), + generation_time = c(0.1, 0.4, 0.4, 0.1), + observation = ~ (1 | day_of_week), + latent_reporting_delay = 0.4 * c(0.05, 0.3, 0.6, 0.05), + data = pobs +) + +# Fit nowcast model with these modules and produce a nowcast +nowcast <- epinowcast(pobs, + expectation = expectation_module, + reference = reference_module, + report = report_module, + fit = enw_fit_opts( + save_warmup = FALSE, pp = TRUE, + chains = 2, threads_per_chain = 2, + iter_warmup = 1000, iter_sampling = 1000, + adapt_delta = 0.95, max_treedepth = 12 + ), + model = model +) + +# Plot nowcast of observed values +plot(nowcast, latest_obs) + +# Plot Reproduction number estimates +rt <- enw_posterior(nowcast$fit[[1]], variables = "r") +cols <- c("mean", "median", "q5", "q20", "q80", "q95") +rt[, (cols) := lapply(.SD, exp), .SDcols = cols] +rt <- cbind( + expectation_module$data_raw$r[, .(date)], rt +) + +ggplot(rt) + + aes(x = date) + + geom_line(aes(y = median), size = 1, alpha = 0.6) + + geom_line(aes(y = mean), linetype = 2) + + geom_ribbon(aes(ymin = q5, ymax = q95), alpha = 0.2, size = 0.2) + + geom_ribbon(aes(ymin = q20, ymax = q80, col = NULL), alpha = 0.2) + + geom_hline(yintercept = 1, linetype = 2) + + theme_bw() + + labs( + x = "Reference date", + y = "Effective reproduction number" + ) + +# Plot expected latent cases +latent_exp_cases <- enw_posterior( + nowcast$fit[[1]], + variables = "exp_latent_lobs" +) +latent_exp_cases[, (cols) := lapply(.SD, exp), .SDcols = cols] +latent_exp_cases <- cbind( + enw_extend_date( + expectation_module$data_raw$r[, .(date, .group = 1)], + days = nowcast$data[[1]]$expo_lrd_n, + direction = "start" + ), + latent_exp_cases +) + +ggplot(latent_exp_cases) + + aes(x = date) + + geom_line(aes(y = median), size = 1, alpha = 0.6) + + geom_line(aes(y = mean), linetype = 2) + + geom_ribbon(aes(ymin = q5, ymax = q95), alpha = 0.2, size = 0.2) + + geom_ribbon(aes(ymin = q20, ymax = q80, col = NULL), alpha = 0.2) + + theme_bw() + + labs( + x = "Reference date", + y = "Expected latent cases" + ) + +# Plot expected reported cases +exp_cases <- enw_posterior( + nowcast$fit[[1]], + variables = "exp_lobs" +) +exp_cases[, (cols) := lapply(.SD, exp), .SDcols = cols] +exp_cases <- cbind( + expectation_module$data_raw$observation, + exp_cases +) + +exp_cases <- enw_latest_data(nat_germany_hosp)[, date := reference_date][ + exp_cases, + on = "date" +] + +ggplot(exp_cases) + + aes(x = date) + + geom_point(aes(y = confirm)) + + geom_line(aes(y = median), size = 1, alpha = 0.6) + + geom_line(aes(y = mean), linetype = 2) + + geom_ribbon(aes(ymin = q5, ymax = q95), alpha = 0.2, size = 0.2) + + geom_ribbon(aes(ymin = q20, ymax = q80, col = NULL), alpha = 0.2) + + theme_bw() + + labs( + x = "Reference date", + y = "Expected reported cases" + ) diff --git a/inst/examples/germany_simple.R b/inst/examples/germany_simple.R index b10398b96..bc3dc00b0 100644 --- a/inst/examples/germany_simple.R +++ b/inst/examples/germany_simple.R @@ -38,13 +38,13 @@ latest_obs <- enw_filter_reference_dates( # Preprocess observations (note this maximum delay is likely too short) pobs <- enw_preprocess_data(retro_nat_germany, max_delay = 20) -# Fit the default nowcast model and produce a nowcast -# Note that we have reduced samples for this example to reduce runtimes +# Fit a simple nowcasting model with fixed growth rate and a +# log-normal reporting distribution. nowcast <- epinowcast(pobs, - expectation = enw_expectation(~ rw(week) + (1 | day_of_week), data = pobs), + expectation = enw_expectation(~1, data = pobs), fit = enw_fit_opts( save_warmup = FALSE, pp = TRUE, - chains = 2, iter_warmup = 500, iter_sampling = 500 + chains = 2, iter_warmup = 500, iter_sampling = 500, ), - obs = enw_obs(family = "poisson", data = pobs) + obs = enw_obs(family = "poisson", data = pobs), ) diff --git a/inst/stan/epinowcast.stan b/inst/stan/epinowcast.stan index 9ef1e4c97..4bc538163 100644 --- a/inst/stan/epinowcast.stan +++ b/inst/stan/epinowcast.stan @@ -2,6 +2,7 @@ functions { #include functions/zero_truncated_normal.stan #include functions/regression.stan #include functions/log_expected_obs_from_r.stan +#include functions/log_expected_obs_from_latent_obs.stan #include functions/discretised_logit_hazard.stan #include functions/hazard.stan #include functions/expected_obs.stan @@ -37,9 +38,11 @@ data { array[t, g] int latest_obs; // latest obs for each snapshot group // Expectation model + // Growth rate submodule int expr_r_seed; // How many seeding initial intercepts to use? int expr_gt_n; // Length of the generation time int expr_t; // Time span for r + int expr_ft; // Sum of expr_t + expr_r_seed // PMF describing the generation time (reversed and logged) vector[expr_gt_n] expr_lrgt; // Observation model to use for the latent process. Currently 0 = none @@ -53,7 +56,19 @@ data { // Mean of initial log cases array[2, g * expr_r_seed] real expr_leobs_int_p; array[2, 1] real expr_r_int_p; - array[2, 1] real expr_beta_sd_p; + array[2, 1] real expr_beta_sd_p; + // Observation sub-module + int expo_lrd_n; // Length of the generation time + // Parrtial PMF describing the reporting delay (reversed and logged) + vector[expo_lrd_n] expo_lrlrd; + // Observation model to use for the latent process. Currently 0 = none + int expo_obs; + int expo_fnindex; + int expo_fncol; + int expo_rncol; + matrix[expo_fnindex, expo_fncol + 1] expo_fdesign; + matrix[expo_fncol, expo_rncol + 1] expo_rdesign; + array[2, 1] real expo_beta_sd_p; // Reference day model int model_refp; @@ -119,11 +134,15 @@ transformed data{ parameters { // Expectation model - // Initial log observations by group + // Growth rate submodule + // Initial log observations by group matrix[expr_r_seed, g] expr_leobs_int; real expr_r_int; vector[expr_fncol] expr_beta; vector[expr_rncol] expr_beta_sd; + // Observation sub-module + vector[expo_fncol] expo_beta; + vector[expo_rncol] expo_beta_sd; // Reference model array[model_refp ? 1 : 0] real refp_mean_int; @@ -149,6 +168,8 @@ parameters { transformed parameters{ // Expectation model vector[expr_t] r; // Log growth rate of observations + array[g] vector[expr_ft] exp_latent_lobs; // Expected final observations + vector[expo_obs ? expo_fnindex : 0] expo_modifier; // Reporting modifier array[g] vector[t] exp_lobs; // Expected final observations // Reference model vector[refp_fnrow] refp_mean; @@ -164,12 +185,27 @@ transformed parameters{ // Expectation model profile("transformed_expected_final_observations") { + // Get log growth rates and map to expected latent observations r = combine_effects( expr_r_int, expr_beta, expr_fdesign, expr_beta_sd, expr_rdesign, 1 ); - exp_lobs = log_expected_obs_from_r( - expr_leobs_int, r, expr_g, expr_t, expr_r_seed, expr_gt_n, expr_lrgt, t, g + exp_latent_lobs = log_expected_obs_from_r( + expr_leobs_int, r, expr_g, expr_t, expr_r_seed, expr_gt_n, expr_lrgt, + expr_ft, g ); + // Get reporting modifiers and map latent expected observations to expected + // observations + if (expo_obs) { + expo_modifier = combine_effects( + 0, expo_beta, expo_fdesign, expo_beta_sd, expo_rdesign, 1 + ); + exp_lobs = log_expected_obs_from_latent_obs( + exp_latent_lobs, expo_lrd_n, expo_lrlrd, t, g, expo_modifier + ); + }else{ + exp_lobs = exp_latent_lobs; + } + } // Reference model @@ -224,6 +260,7 @@ transformed parameters{ model { profile("model_priors") { // Expectation model + // Growth rate sub-module // Initial intercept of log observations to_vector(expr_leobs_int) ~ normal(expr_leobs_int_p[1], expr_leobs_int_p[2]); // Intercept of growth rate @@ -232,7 +269,16 @@ model { effect_priors_lp( expr_beta, expr_beta_sd, expr_beta_sd_p, expr_fncol, expr_rncol ); - + // Observation model sub-module + // Reporting modifiers + effect_priors_lp( + expo_beta, expo_beta_sd, expo_beta_sd_p, expo_fncol, expo_rncol + ); + // Reporting overdispersion (1/sqrt) + if (model_obs) { + sqrt_phi[1] ~ normal(sqrt_phi_p[1], sqrt_phi_p[2]) T[0,]; + } + // Reference model if (model_refp) { refp_mean_int ~ normal(refp_mean_int_p[1], refp_mean_int_p[2]); @@ -260,11 +306,6 @@ model { miss_beta, miss_beta_sd, miss_beta_sd_p, miss_fncol, miss_rncol ); } - - // Observation model - if (model_obs) { // reporting overdispersion (1/sqrt) - sqrt_phi[1] ~ normal(sqrt_phi_p[1], sqrt_phi_p[2]) T[0,]; - } } // Log-Likelihood either by snapshot or group depending on settings/model if (likelihood) { diff --git a/inst/stan/functions/log_expected_obs_from_latent_obs.stan b/inst/stan/functions/log_expected_obs_from_latent_obs.stan new file mode 100644 index 000000000..6ea4e8562 --- /dev/null +++ b/inst/stan/functions/log_expected_obs_from_latent_obs.stan @@ -0,0 +1,20 @@ + array[] vector log_expected_obs_from_latent_obs( + array[] vector exp_latent_lobs, int rd_n, vector lrrd, int t, + int g, vector modifier + ) { + array[g] vector[t] exp_lobs; + for (k in 1:g) { + if (rd_n == 1) { + exp_lobs[k] = exp_latent_lobs[k] + rep_vector(lrrd[1], t); + }else{ + for (i in 1:t){ + exp_lobs[k][i] = + log_sum_exp( + segment(exp_latent_lobs[k], i, rd_n) + lrrd + ); + } + } + exp_lobs[k] = exp_lobs[k] + segment(modifier, (k-1) * t + 1, t); + } + return(exp_lobs); + } diff --git a/man/enw_expectation.Rd b/man/enw_expectation.Rd index ae7126b98..ee5add8e0 100644 --- a/man/enw_expectation.Rd +++ b/man/enw_expectation.Rd @@ -4,22 +4,45 @@ \alias{enw_expectation} \title{Expectation model module} \usage{ -enw_expectation(formula = ~rw(day, by = .group), generation_time = 1, data) +enw_expectation( + r = ~rw(day, by = .group), + generation_time = 1, + observation = ~1, + latent_reporting_delay = 1, + data, + ... +) } \arguments{ -\item{formula}{A formula (as implemented in \code{\link[=enw_formula]{enw_formula()}}) describing +\item{r}{A formula (as implemented in \code{\link[=enw_formula]{enw_formula()}}) describing the generative process used for expected incidence. This can use features defined by reference date as defined in \code{metareference} as produced by \code{\link[=enw_preprocess_data]{enw_preprocess_data()}}. By default this is set to use a daily group -specific random walk. Note that the daily group specific random walk is -currently the only option supported by \code{\link[=epinowcast]{epinowcast()}}.} +specific random walk.} \item{generation_time}{A numeric vector that sums to 1 and defaults to 1. Describes the weighting to apply to previous generations (i.e as part of a renewal equation). When set to 1 (the default) this corresponds to modelling the daily growth rate.} +\item{observation}{A formula (as implemented in \code{\link[=enw_formula]{enw_formula()}}) describing +the modifiers used to adjust expected observations. This can use features +defined by reference date as defined in \code{metareference} as produced by +\code{\link[=enw_preprocess_data]{enw_preprocess_data()}}. By default no modifiers are used but a common choice +might be to adjust for the day of the week. Note as the baseline is no +modification an intercept is always used and it is set to 0.} + +\item{latent_reporting_delay}{A numeric vector that defaults to 1. +Describes the weighting to apply to past and current latent expected +observations (from most recent to least). This can be used both to convolve +based on some assumed reporting delay and to rescale obserations (by +multiplying a probability mass function by some fraction) to account +ascertainment etc.} + \item{data}{Output from \code{\link[=enw_preprocess_data]{enw_preprocess_data()}}.} + +\item{...}{Additional parameters passed to \code{\link[=enw_add_metaobs_features]{enw_add_metaobs_features()}}. The +same arguments as passed to \code{enw_preprocess_data()} should be used here.} } \value{ A list containing the supplied formulas, data passed into a list diff --git a/man/enw_extend_date.Rd b/man/enw_extend_date.Rd index a9b158267..170604991 100644 --- a/man/enw_extend_date.Rd +++ b/man/enw_extend_date.Rd @@ -4,12 +4,13 @@ \alias{enw_extend_date} \title{FUNCTION_TITLE} \usage{ -enw_extend_date(metaobs, max_delay = 20) +enw_extend_date(metaobs, days = 20, direction = "end") } \arguments{ \item{metaobs}{PARAM_DESCRIPTION} -\item{max_delay}{PARAM_DESCRIPTION, Default: 20} +\item{direction}{Should new dates be added at the begining or end of +the data. Default is "end" with "start" also available} } \value{ OUTPUT_DESCRIPTION diff --git a/man/epinowcast.Rd b/man/epinowcast.Rd index e00a7b99e..e1625555f 100644 --- a/man/epinowcast.Rd +++ b/man/epinowcast.Rd @@ -9,8 +9,8 @@ epinowcast( reference = epinowcast::enw_reference(parametric = ~1, distribution = "lognormal", non_parametric = ~0, data = data), report = epinowcast::enw_report(non_parametric = ~0, structural = ~0, data = data), - expectation = epinowcast::enw_expectation(formula = ~rw(day, .group), order = 1, data - = data), + expectation = epinowcast::enw_expectation(formula = ~rw(day, .group), generation_time + = 1, observation = ~1, latent_reporting_delay = 1, data = data), missing = epinowcast::enw_missing(formula = ~0, data = data), obs = epinowcast::enw_obs(family = "negbin", data = data), fit = epinowcast::enw_fit_opts(fit = epinowcast::enw_sample, nowcast = TRUE, pp = @@ -31,7 +31,7 @@ specification as defined using \code{\link[=enw_report]{enw_report()}}.} \item{expectation}{The expectation model specification as defined using \code{\link[=enw_expectation]{enw_expectation()}}. By default this is set to be highly flexible and thus -weakly informed. Other options are not yet supported.} +weakly informed.} \item{missing}{The missing reference date model specification as defined using \code{\link[=enw_missing]{enw_missing()}}. By default this is set to not be used.}