enw_simulate_missing_reference | R Documentation |
A simple binomial simulator of missing data by reference date using simulated or observed data as an input. This function may be used to validate missing data models, as part of examples and case studies, or to explore the implications of missing data for your use case.
enw_simulate_missing_reference(obs, proportion = 0.2, by = NULL)
obs |
A |
proportion |
Numeric, the proportion of observations that are missing a reference date, indexed by reference date. Currently only a fixed proportion are supported and this defaults to 0.2. |
by |
A character vector describing the stratification of observations. This defaults to no grouping. This should be used when modelling multiple time series in order to identify them for downstream modelling |
A data.table
of the same format as the input but with a simulated
proportion of observations now having a missing reference date.
# Load and filter germany hospitalisations
nat_germany_hosp <- subset(
germany_covid19_hosp, location == "DE" & age_group == "00+"
)
nat_germany_hosp <- enw_filter_report_dates(
nat_germany_hosp,
latest_date = "2021-08-01"
)
# Make sure observations are complete
nat_germany_hosp <- enw_complete_dates(
nat_germany_hosp,
by = c("location", "age_group"), missing_reference = FALSE
)
# Simulate
enw_simulate_missing_reference(
nat_germany_hosp,
proportion = 0.35, by = c("location", "age_group")
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.