Introduction

the spread of covid19 virus in egypt looks safe for now. regarding the annouanced confirmed cases in egypt seems low. But still it follows an exponential curve which seems dangerous. I just want to answer how fast will the virus spread in the Egypt?

I will follow a simple and maybe naive approch to this method to predict Covid19 growth: fit the pattern in China, then apply it to the Egypt data. Of course, Egypt and China are different countries with different public health systems, but I feel that this will at least give a first order estimate of how quickly the virus will spread.

Data prepration

## calling necessary library
library(data.table)
library(ggplot2)

Now we call the data from JHU JHU Center for Systems Science & Engineering, and ultiamtely.

main = fread('https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_covid19_confirmed_global.csv')
names(main) = tolower(names(main))
names(main)[1:2] = c('province','country')
main = melt(main, id.vars = c('province','country','lat','long'))
setnames(main, c('variable','value'), c('date','cases'))
main[, date := as.Date(date, format = '%m/%d/%y')]


china = main[country == 'China']
china = china[,.(cases = sum(cases)), by = .(country,date)]
china = china[, pchg := (cases-shift(cases,1))/shift(cases,1)]
china = china[, days := 1:nrow(china)]

china data fit

Let’s have a look at the Chinese data so far

ggplot(data = china) + geom_line(aes(x = date, y = cases),size =3, color ="red")

lets now fit this pattern with a sigmoid using non-linear least squares.

fit = nls(cases ~ SSlogis(days, Asym, xmid, scal), data = china)
china[, yhat := predict(fit,china)]
ggplot(data = china) + geom_line(aes(x = days, y = cases),size =3, color ="red") + geom_line(aes(x = days, y=yhat), color = 'blue',size= 3)

Projecting this pattern backwards, it’s possible to estimate when China reached 1322 cases, which is the current number in the Egypt.

dt = data.table(days = -20:5, cases = NA)
dt[,yhat := predict(fit,dt)] # day 0 for roughly 60 cases
print(dt[,.(days,yhat)])
##     days       yhat
##  1:  -20   16.32916
##  2:  -19   20.33070
##  3:  -18   25.31254
##  4:  -17   31.51465
##  5:  -16   39.23567
##  6:  -15   48.84720
##  7:  -14   60.81150
##  8:  -13   75.70353
##  9:  -12   94.23821
## 10:  -11  117.30424
## 11:  -10  146.00584
## 12:   -9  181.71435
## 13:   -8  226.13175
## 14:   -7  281.36873
## 15:   -6  350.04020
## 16:   -5  435.38184
## 17:   -4  541.39123
## 18:   -3  672.99788
## 19:   -2  836.26590
## 20:   -1 1038.63285
## 21:    0 1289.18672
## 22:    1 1598.98019
## 23:    2 1981.37633
## 24:    3 2452.41221
## 25:    4 3031.15447
## 26:    5 3740.00369
##     days       yhat

Project Egypt Case Count

Now let’s assume the Egypt is in “day 0” of the Chinese outbreak, and project fowards from there.

dt = data.table(days = -20:20, cases = NA)
dt[,yhat := predict(fit,dt)] # day -13 for roughly 60 cases

egypt = main[country == 'Egypt']
egypt = egypt[,.(cases = sum(cases)), by = .(country,date)]
egypt = egypt[, days:= NA]

future = data.table(country = 'Egypt', date = as.Date(character(0)), cases = NA, days = 0:40)
egypt = rbind(egypt, future)
egypt[, yhat := predict(fit, egypt)]
egypt[, date := as.Date(date, format = '%m/%d/%y')]
egypt[, project := ifelse(is.na(yhat), 0, 1)]
egypt[, dayid := cumsum(project)]

initdate = egypt[76, date]
egypt[is.na(date), date := initdate + dayid]
egypt[project == 1, cases := round(yhat,1)]
ggplot(data = egypt) + geom_line(aes(x = date, y = cases), size = 1.25) + geom_line(aes(x = date, y = yhat), color = 'red', size = 1.25) +
scale_x_date(date_breaks = "5 day") +
theme(axis.text.x=element_text(angle=60, hjust=1)) +
ggtitle('Egypt projected case count (projection in red)')

print(egypt[dayid>0 & dayid <71, .(date, cases)])
##           date cases
##  1: 2020-04-07  1289
##  2: 2020-04-08  1599
##  3: 2020-04-09  1981
##  4: 2020-04-10  2452
##  5: 2020-04-11  3031
##  6: 2020-04-12  3740
##  7: 2020-04-13  4604
##  8: 2020-04-14  5655
##  9: 2020-04-15  6923
## 10: 2020-04-16  8444
## 11: 2020-04-17 10253
## 12: 2020-04-18 12384
## 13: 2020-04-19 14865
## 14: 2020-04-20 17716
## 15: 2020-04-21 20942
## 16: 2020-04-22 24528
## 17: 2020-04-23 28440
## 18: 2020-04-24 32618
## 19: 2020-04-25 36981
## 20: 2020-04-26 41432
## 21: 2020-04-27 45865
## 22: 2020-04-28 50178
## 23: 2020-04-29 54276
## 24: 2020-04-30 58087
## 25: 2020-05-01 61558
## 26: 2020-05-02 64661
## 27: 2020-05-03 67390
## 28: 2020-05-04 69753
## 29: 2020-05-05 71775
## 30: 2020-05-06 73486
## 31: 2020-05-07 74921
## 32: 2020-05-08 76114
## 33: 2020-05-09 77100
## 34: 2020-05-10 77911
## 35: 2020-05-11 78574
## 36: 2020-05-12 79115
## 37: 2020-05-13 79555
## 38: 2020-05-14 79912
## 39: 2020-05-15 80201
## 40: 2020-05-16 80435
## 41: 2020-05-17 80624
##           date cases

Results

According to these numbers, Egypt can expect to exceed 10000 cases in the third week of April. This is about two weeks from now. This gives egyptian government with 1-3 more weeks to prepare. Tasking into consideration the measurnments that the government imposed already and the health care emergecy situation, it is hard to reach this worst case senario is hard to believe that this would occur unless something happens extraordiary. people need to practise social distance and officials need to work on this problem with all its resources.

Contact

For any question or feedback, you can contact me.

Go back to Mohamed Elashri.