COVID-19 Model Projections for India
Update: This project has been superseded by the DST India Covid Model
Download the JS script covid19-model-india.js
and include it locally.
<script src="js/covid19-model-india.js"></script>
Before the Covid19ModelIndia
class can be instantiated, we need to fetch some
JSON data as follows:
let urls = [];
urls.push("https://api.covid19india.org/states_daily.json");
urls.push("https://api.covid19india.org/raw_data1.json");
urls.push("https://api.covid19india.org/raw_data2.json");
urls.push("https://api.covid19india.org/raw_data3.json");
urls.push("https://api.covid19india.org/raw_data4.json");
urls.push("https://api.covid19india.org/raw_data5.json");
urls.push("https://api.covid19india.org/raw_data6.json");
let promises = [];
urls.forEach(function(url) {
promises.push(fetch(url).then(data => data.json()));
});
Promise.all(promises).then(function(data) {
init(data);
});
Due to the asynchronous nature of the fetch calls, the model should be created only after ensuring that all data has been fetched completely. For this reason, the model is instantiated inside the init function which is called only after all the data has been fetched as shown above.
In order to create an instance of the model, we need to supply:
t0
: baseline date, usually taken as three to seven days before the current datestateSeries
: an array containing daily state-wise statistics as obtained fromstates_daily.json
caseSeries
: an array containing time-series of reported cases as obtained from concatenation of allraw_data<n>.json
function init(data)
{
let t0 = new Date();
t0.setDate(t0.getDate() - 3);
let statesSeries = data[0].states_daily;
let caseSeries1 = data[1].raw_data;
let caseSeries2 = data[2].raw_data;
let caseSeries3 = data[3].raw_data;
let caseSeries = caseSeries1.concat(caseSeries2, caseSeries3);
let model = new Covid19ModelIndia(t0, statesSeries, caseSeries);
// all functions using model data are nested inside this
display(model, app);
}
Projected statistics for a specific district can be obtained from the model using
const districtIndex = model.indexDistrictNameKey("Bengaluru Urban.Karnataka");
const stat = model.districtStatLimit("reported", districtIndex, new Date("10 April 2020"));
The above districtStatLimit
function returns an object containing three
values { min : ..., mid : ..., max : ...}
.
Similar functions are available for country and state level
// state level
const stateIndex = model.indexStateName("Karnataka");
var stat = model.stateStatLimit("reported", stateIndex, new Date("10 April 2020"));
// country level
var stat = model.countryStatLimit("reported", new Date("10 April 2020"));
The model has two sets of parameters predefined for use:
model.lowParams
: these parameters result low to moderate infection projectionsmodel.highParams
: these parameters result in high infection projections These parameters can be passed to generate the default low and high statistics. In addition, the model provides a time-series extrapolation method to generate projections. The functions for obtaining these low, high and extrapolation case projections are:
const districtIndex = model.indexDistrictNameKey("Bengaluru Urban.Karnataka");
const lowStat = model.districtStat("reported", districtIndex, model.lowParams, new Date("10 April 2020"));
const highStat = model.districtStat("reported", districtIndex, model.highParams, new Date("10 April 2020"));
const extrapolStat = model.districtStat("reported", districtIndex, model.lowParams, new Date("10 April 2020"), true);
Similar functions are available for state and country level.
The model is tuned to predict patient statistics every week, on the week from
a baseline starting date. The array of dates corresponding to each week
can be obtained using model.dates
. model.dates[0]
represents the baseline
date (t=0
), model.dates[1]
represents a week after t=0
and so on.
For example, to obtain the projected number of critically ill patients for the second week in a district, the following query needs to be made:
var districtIndex = model.indexDistrictNameKey("Bengaluru Urban.Karnataka");
var numCritical = model.districtStat("critical", districtIndex, model.lowParams, model.dates[2]);
Projected cumulative counts upto a given date can be provided by the model for the following categories:
"reported"
: Number of infections reported"carriers"
: Number of carriers (symtomatic patients + asymptomatic)"critical"
: Number of critically ill patients"deceased"
: Number of deceased"ventilators"
: Number of ventilators required"pumps"
: Number of infusion pumps required
In addition to the calculating the index of the item or category by name, the index can be calculated from an ID as well. See the JSON objects defined in the scripts for information about the IDs.
Band plots for projections can be generated using Gnuplot via a sequence of
shell scripts. The relevant scripts are given in the data/band-plot
folder.
Projection output data from stats-band.js
can be piped to a csv file by
launching the script JS script using node as follows:
- Enter the
data/band-plot
folder. npm install node-fetch
./selected-plots.sh
for generating plots for a selected few states and districts./plot.sh <arg1> <arg2> ...
for generating plots for a specific region
./plot.sh "country" "reported"
for India plots./plot.sh "state" "Karnataka" "reported"
for states./plot.sh "district" "Bengaluru Urban" "Karnataka" "reported"
for districts