Forecasting Deaths From COVID-19 in North Carolina up to the End of 2020

Photo by Ruthson Zimmerman on Unsplash


Matplotlib scatter plot of the actual death data up to 9/22 and a 41-day forecast leading up to the election today

Updating the model with new data

Here’s the entire Jupyter Notebook containing all code and previous model estimations
# Loading in most recent data updated as of today Nov. 3rd

NCcovidNew = pd.read_excel('NCcovidNew.xlsx', sheet_name='Sheet 1')
date = NCcovidNew['Date']
y = NCcovidNew['NC Deaths']
date.shape # 224 days of data
# Reshpaing the data


Refitting the model

reg = linear_model.LinearRegression() # Constructing SKlearn model
poly_f=PolynomialFeatures(degree=2,include_bias=False) # Instantiating quadratic termX_poly=poly_f.fit_transform(x) # Applying quadratic,y) # Fitting transformed data to model# Assigning variables to the model's parameter estimatesa=reg.intercept_[0]
print(“a (Intercept term) =”,a)
print(“b (Coefficient 1) =”,b)
print(“c (Coefficient 2) =”,c)

Putting it all together

plt.xlim(0, 290)
plt.plot(x, a + b*x+c*np.power(x,2), "r")plt.title('Predicted vs Actual COVID-19 Deaths in NC')
plt.xlabel('Days since first recorded death')
plt.axvline(x=224+58,color='b') # Blue vertical line corresponds with Dec. 31st
plt.axhline(y=a + b*(224+58) + c*(224+58)**2,color='b')
plt.axhline(y=a + b*(224) + c*(224)**2,color='g') # Corresponds with today's death total of 4,457


deathsByNewYears = a + b*(224+58) + c*(224+58)**2 # Forecasting 58 days into the future from todayprint("Predicted number of deaths on Dec. 31st:",int(deathsByNewYears))

Take this all with a grain of salt

Graph made in Google Sheets using data from The COVID Tracking Project

Here in North Carolina, the rate of positive tests have also picked back up in recent weeks

Graph made in Google Sheets using data from the NC DHHS
Source: CDC
Source: CDC

Final thoughts



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Ali Alsous

Ali Alsous

Economics student committed to leveraging the power of data science from a left/humanist international perspective; for the good of all and not the few.