Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save arinbasu/7450be4e22b162be03ea9cd077cb05df to your computer and use it in GitHub Desktop.
Save arinbasu/7450be4e22b162be03ea9cd077cb05df to your computer and use it in GitHub Desktop.
title author tags
Coronavirus situation and projections in New Zealand
Arindam Basu
coronavirus, covid19, prediction

Coronavirus predictions in NZ and others

New zEaland is one of the few countries that seem to have got a control over coronavirus outbreak. Here we present the incidence of Coronavirus in New Zealand and some predictions as to how and when we can expect to get to a point of 0 incident cases in NZ.

## first load the libraries
library(tidyverse)
library(lubridate)
library(incidence)
library(projections)
library(epitrix)
library(distcrete)

## then obtain the data from JHU CSSE archives on cases

fulldata <- read_csv("https://github.com/CSSEGISandData/COVID-19/raw/master/csse_covid_19_data/csse_covid_19_time_series/time_series_covid19_confirmed_global.csv")

fulldata %>% head(3) # gives us the headers and some data
## now select NZ and process NZ data and convert it to an incidence object

## create a New Zealand data object first

nz_data <- fulldata %>%
   rename(province = `Province/State`,
          country = `Country/Region`) %>%
   filter(country == "New Zealand") %>%
   select(-Lat, -Long) %>%
   gather(dates, count, -province, -country) %>%
   mutate(date1 = mdy(dates),
          inc_cases = c(0, diff(count, lag = 1)),
          days_since = as.numeric(date1 - min(date1))) %>%
   select(date1, inc_cases, days_since)

nz_data %>% head()
nz_inc <- fulldata %>%
   rename(province = `Province/State`,
          country = `Country/Region`) %>%
   filter(country == "New Zealand") %>%
   select(-Lat, -Long) %>%
   gather(dates, count, -province, -country) %>%
   mutate(date1 = mdy(dates),
          inc_cases = c(0, diff(count, lag = 1))) %>%
   select(date1, inc_cases) %>%
   uncount(inc_cases) %>%
   pull(date1) %>%
   incidence()
   
# nz_inc # will provide detailed information about the incidence object
# plot incidence
plot(nz_inc, border = "white") +
   ggsave("incidence_plot.jpg")

The first plot

incidence plot

This shows that the number of cases increased steadily till the first week of April and then progressively dropped. This suggests that we had reached a peak in the number of cases in New Zealand and then there has been a progressive drop in the number of new cases we continued to find despite significantly increasing the number of tests. Intuitively, this would mean that we would find more new cases even with somewhat relaxed testing criteria that the Ministry of Health used for testing (instead of tight testing criteria for overseas travel or contact with someone with history of overseas travel and physical symptoms, now the new criteria included anyone with suspicious symptoms and signs). We have fitted an optimised model to find a peak date and patterns of fitted lines on the existing data. The find_peak() function from the incidence package returns that the peak was reached around 4th April, 2020.

Next, we fitted an optimised Weibull regression model for the data using the incidence package and ran the regression model against time with no other coviariates.

peak_day <- find_peak(nz_inc) # find the day of the peak

reg_results <- fit_optim_split(nz_inc) # fit an optimised regression model

fit_info <- reg_results$fit # returns the results of the fit 

# fit_info # will provide details of the model

Results of the regression model

In the model, we regressed log-incidence over time, splitting the dates into two halves: one before 4th April, 2020, and the ones after 4th April, 2020. Each of these graphs were exponential graphs, and had different growth rates. We obtained the following statistics from the regression model:

Parameter Estimate 95% confidence interval
Daily Growth Rate before 4th April 0.16 0.13, 0.10
Daily growth rate after 4th April - 0.15 - 0.22, -0.08
Doubling time of infection before 4/4/2020 4.31 days 3.64, 5.28
Doubling (down) time of infection after 4/4/2020 4.35 3.02, 7.75

This gives us several interesting insights into the process of the growth and shrinkage of this epidemic. Prior to 4th April, the number of cases grew rapidly at the rate of doubling every nearly five days; likewise, after the peak period was reached, when the epidemic started on a downhill climb, it did so equally rapidly as evidenced over the next few days, new cases halving roughly every five days. We can graphically examine these trends.

Daily incidence

As can be seen in this graph, the trend of the cases grew rapidly till 2nd April, then there was a plateau, and then the number of cases steadily decreased starting 3rd April. In the absence of any intervention, the number of cases would have gone upward. New Zealand started "lock down" or level 4 of the intervention to "eliminate" the infection in and around 25th March, 2020. This meant that the effects to reduce the new number of cases even with increased surveillance and relaxed criteria took about 10 days to take effect. Note that this roughly or on average the time it takes an infection to manifest from first infection. This suggests that despite limitation in the number of tests being conducted, the tests were on track to identify and estimate the true number of cases.

What could we expect and what can we expect?

Let's first plot what would have happened if the infection were to continue as it was during the first 28 days of the infection (from around the end of February till the time when the "elimination strategy" was announced in New Zealand), and see the possible numbers of new cases we might see 40 days, so that roughly around the second week of April.

Projected numbered cases

As can be seen in the figure, in the absence of any interventions, the numbers from around the third week of March would continue to rise monotonically. But that did not happen. Instead, following the lock down or elimination strategy, the numbers started coming down. So now let's plot the projected numbers at this stage if the current trend continues.

Projected numbers post lockdown

While the numbers continue to decline, to get to a 0 incidence rate, it will be weeks before that can happen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment