/covid-19

Primary LanguageHTMLBSD 3-Clause "New" or "Revised" LicenseBSD-3-Clause

COVID-19 Analysis

Checkout the webpage with live plots. And if you're interested:

This is a very simple estimate of COVID-19 impacts, and I don't claim to know anything other than how to produce a nice figure and do simple math. So please don't misinterpret anything here.

Dependencies

using Dates
using PlotlyJS
using DataFrames
using CSV

A simple model for calculating cases based on a constant doubling time:

function cases(days::Day, current_cases, doubling_time::Day)
    dbl_period = days/doubling_time
    return current_cases * (2 ^ dbl_period)
end

A simple model for calculating instantaneous case load given a recovery time: note that the instantaneous case calculation assumes that the death time is the same as the recovery time

function instantanious_cases(dates, cumulative_cases, hosp_rate, death_rate, recovery_time)
    recovery_dates = dates .+ recovery_time
    recovery_lag = length(dates[dates .< recovery_dates[1]])
    recovered_cases = vcat(zeros(recovery_lag), cumulative_cases[1:end-recovery_lag])
    instant_cases = cumulative_cases - recovered_cases - recovered_cases .* death_rate
    instant_hosp = instant_cases .* hosp_rate
    return instant_cases, instant_hosp
end

Here is a function to generate plotly figures based on the simple virus model parameters.

function plot_covid(days, current_cases, doubling_time = Day(7), hosp_rate = 0.1, death_rate = 0.03, recovery_time = Day(10))
    td = today()
    dates = td:doubling_time:(td+days)
    cumulative_cases = [cases(d-td, current_cases, doubling_time) for d in dates]
    instant_cases, instant_hosp = instantanious_cases(dates, cumulative_cases, hosp_rate, death_rate, recovery_time)
    total_cases = scatter(x = dates, y = cumulative_cases, name = "Cumulative Infections")
    #total_hosp = scatter(x = dates, y = cumulative_cases.*hosp_rate, name = "Cumulative Hospitalizations")
    total_deaths = scatter(x = dates, y = cumulative_cases.*death_rate, name = "Cumulative Deaths")
    inst_cases = scatter(x = dates, y = instant_cases, name = "Instantaneous Infections")
    inst_hosp = scatter(x = dates, y= instant_hosp, name = "Instantaneous Hospitalizations")
    plot([total_cases, total_deaths, inst_cases, inst_hosp])
end

COVID-19 parameters

  • According to this article, the estimated doubling time of COVID-19 is ~5 days.
  • According to the WHO, the mortality rate of COVID-19 is ~3%.
  • The 10% hospitalization rate comes from this article, but the sources for that figure in the article are dubious at best.

JHU has put together some more detailed data, and HDX has put it in a useful format.

jh_data = DataFrame(CSV.read(download("https://data.humdata.org/hxlproxy/api/data-preview.csv?url=https%3A%2F%2Fraw.githubusercontent.com%2FCSSEGISandData%2FCOVID-19%2Fmaster%2Fcsse_covid_19_data%2Fcsse_covid_19_time_series%2Ftime_series_19-covid-Confirmed.csv")))

Colorado

data processing

co_data = jh_data[.!ismissing.(jh_data[!,Symbol("Province/State")]) .& (jh_data[!,Symbol("Province/State")].=="Colorado"),:]
co_data = melt(co_data,names(co_data)[1:4],variable_name = :Date, value_name =:cases)
co_data.Date = Date.(String.(co_data.Date),"m/d/y") + Year(2000)
recent_cases = co_data[co_data.Date .== maximum(co_data.Date),:cases][1]

Plot the colorado projection using the most recent case count:

plot_covid(Day(60), recent_cases, Day(5))
<iframe id="igraph" scrolling="no" style="border:none;" seamless="seamless" src="./CO.html" height="525" width="100%"></iframe>

US

data processing

us_data = jh_data[.!ismissing.(jh_data[!,Symbol("Country/Region")]) .& (jh_data[!,Symbol("Country/Region")].=="US"),:]
us_data = us_data[.!occursin.(",", us_data[!,Symbol("Province/State")]), :]
us_data = melt(us_data,names(us_data)[1:4],variable_name = :Date, value_name =:cases)
us_data.Date = Date.(String.(us_data.Date),"m/d/y") + Year(2000)
us_data = aggregate(us_data[!,[:Date,:cases]], :Date, sum)
recent_us_cases = us_data[us_data.Date .== maximum(us_data.Date),:cases_sum][1]

Plot the US projection based on the most recent case count:

plot_covid(Day(60), recent_us_cases, Day(5))
<iframe id="igraph" scrolling="no" style="border:none;" seamless="seamless" src="./US.html" height="525" width="100%"></iframe>

This page was generated using Literate.jl.