library(LEMMA)
library(data.table)
library(ggplot2)

In this Case Studies we show how to use LEMMA to model COVID-19 hospitalizations in Alameda County. In previous versions of LEMMA, fitting Alameda County required substantial user intervention. In the current version, minimal user intervention is required.

1. Set up an Excel input file Open the template Excel file (the original is system.file("extdata", "template.xlsx", package = "LEMMA") but the installation instructions on GitHub suggest copying it to example.xlsx in your local directory). In Excel, Save As as “Alameda.xlsx”.

dt <- fread("hospitals_by_county_June30.csv")
dt <- dt[county == "Alameda"]
1. Write the data
write.table(dt[, c(2:4, 7:8)], sep = ",", row.names = F)
#> "todays_date","hospitalized_covid_confirmed_patients","hospitalized_suspected_covid_patients","icu_covid_confirmed_patients","icu_suspected_covid_patients"
#> "3/29/20",36,91,20,16
#> "3/30/20",59,89,27,18
#> "3/31/20",56,94,27,17
#> "4/1/20",52,76,27,15
#> ...

Copy and paste the observed data to the Data tab in Alameda.xlsx.

1. Choose your prior distributions in the Parameters with Distributions sheet. The existing priors are fine for Alameda but they could be adjusted for a different county. For example, in a significantly older population, the hospitalization rate could be higher.

2. Choose your interventions in the Interventions sheet. Note that if automatic.interventions (on Internal sheet) is true (the default), interventions with mean 1 and sd 0.3 are added whenever there are no interventions for 14 days.

We may want to give the model additional ability to adapt to possible changes in transmission. To account for the possibility that increased mobility, decreased social distancing, etc increased transmission, add a intervention with mean 1 and standard deviation 0.5 on June 1. A mean of 1 indicates that our prior is no change, but the large standard deviation allows for possibility of significant change. The standard deviation of 4 days on the intervention date allows for flexibility on the date of change. Add the following row:
Intervention Date mean = “6/1/2020” standard deviation = 4
Re Multiplier mean = 1, standard deviation = 0.5 Days to Reach New Re mean = 7, standard deviation = 2

Future changes in public health interventions (for example, relaxing/replacing current Shelter In Place ordinances) can be modelled as a future intervention which multiplies Re by a factor greater than 1. As an example, suppose we want to consider the effect of a third intervention which multiplies Re by 1.4 on July 15. Add the following row:
Intervention Date mean = “7/15/2020” standard deviation = 0
Re Multiplier mean = 1.4, standard deviation = 0
Days to Reach New Re mean = 7, standard deviation = 0

1. Run CredibilityIntervalFromExcel
result <- LEMMA::CredibilityIntervalFromExcel("Alameda.xlsx")

1. In this case there are several warnings. These can be eliminated by changing max_treedepth to 15 and adapt_delta to 0.99 on the Internals sheet, which increases run time. In this example, the results are not significantly different from those using the defaults, but this is not guaranteed in general. See the FAQ for more details on such warnings.