covid19BH | R Documentation |
The purpose of this page is to show the user how to format the Y input argument
in the pandemic_model
function, when epidemiological data was obtained
outside of the load_covid
function.
The Covid-19 data for the city of Belo Horizonte, MG - Brazil will be used to illustrate
how to correctly format the epidemiological data required in the pandemic_model
function,
using the function format_data
.
See the Examples section.
For complete information on the required data format,
check the Y
input argument description in ?pandemic_model
.
covid19BH
This data frame has 103 observations and 6 variables. It contains the number of Covid-19 confirmed cases and deaths for the city of Belo Horizonte, from the date of the first notified case in 2020-03-16 to 2020-06-26.
date - dates in the YYYY-MM-DD format
new_confirmed - number of new cases
new_deaths - number of new deaths
last_available_confirmed - cumulative number of cases
last_available_deaths - cumulative number of deaths
estimated_population_2019 - size of Belo Horizonte's population
https://brasil.io/dataset/covid19
CovidLP Team, 2020. CovidLP: Short and Long-term Prediction for COVID-19. Departamento de Estatistica. UFMG, Brazil. URL: http://est.ufmg.br/covidlp/home/en/
load_covid
, format_data
, pandemic_model
, posterior_predict.pandemicEstimated
,
pandemic_stats
and plot.pandemicPredicted
.
## formating the data frame for pandemic_model function #loading data data <- covid19BH data names(data) #re-order data in ascending order class(data$date) data$date = as.Date(data$date) class(data$date) data <- data[order(data$date), ] head(data) # building the Y list required start <- data$date[1] end <- data$date[nrow(data)] cases <- data$last_available_confirmed new_cases <- data$new_confirmed deaths <- data$last_available_deaths new_deaths <- data$new_deaths pop <- data$estimated_population_2019[1] Y <- format_data(s_date = start, e_date = end, cases = cases, n_cases = new_cases, deaths = deaths, n_deaths = new_deaths, name = "Belo Horizonte/MG", pop = pop) Y plot(Y) ## fitted model: ##pandemic_model function may take a few minutes... ## Not run: outputBH = pandemic_model(Y, control = list(max_treedepth = 50, adapt_delta = 0.999)) outputBH summary(outputBH) ##convergence diagnostics traceplot(outputBH) density(outputBH) stan_ac(outputBH$fit, pars = c("a","b","c","f")) ## making predictions predictions = posterior_predict(outputBH) ## calculating prediction intervals and statistics stats = pandemic_stats(predictions) ## plotting results plot(predictions) ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.