Initialization


Polynomial regression and the COVID-19 epidemic

Random validation set

We will select a random validation set and build a polynomial model for COVID data.
In[]:=
validationPercentage=0.20;​​data=readData[validationPercentage];​​dataPlot=plotData[data]
​
The following command will find a polynomial of best fit by minimizing training MSE. You can change the degree of the polynomial.
In[]:=
degree=1;​​fitPolynomialPlot[data,degree]
​
​​
​​
​​
​You can also also Mathematica to automatically compute the best fit polynomial for a variety of degrees. You can change the range of the y-values for the plot at the end.
yRange=100000;​​plotErrors[data,yRange]

​
​Time-sequenced validation set

Here you can select the day your training data starts and ends, and how many days in the future you would like the model to make predictions for.
In[]:=
startDay=1;​​endDay=500;​​futureDays=10;​​dataFuture=readTimeSeries[startDay,endDay,futureDays];​​dataPlot=plotData[dataFuture]
​
​
​
​
​
​
​
​
​
The following command will find a polynomial of best fit by minimizing training MSE. You can change the degree of the polynomial.
In[]:=
​​degree=2;​​fitPolynomialPlot[dataFuture,degree]
​
​​
​​
​​
​You can also also Mathematica to automatically compute the best fit polynomial for a variety of degrees. You can change the range of the y-values for the plot at the end.
yRange=100000;​​plotErrors[dataFuture,yRange]

The Singh-Bawa model

In this section we will evaluate a model proposed in the Singh-Bawa article. The authors started on day 80 and used 140 days for training. Let's ask for 100 additional days of data to validate the quality of their predictions.
In[]:=
startDay=80;​​endDay=220;​​futureDays=100;​​dataFuture=readTimeSeries[startDay,endDay,futureDays];​​dataPlot=plotData[dataFuture]
Next, is one of the polynomials they proposed as a model for the data and plot it. There is a slight twist when plotting it, we need to translate it to start at x=80. At first glance, do you have any concerns?
In[]:=
​​q[x_]=20261+2482x−9.9x^2-.23x^3+0.00299x^4-0.000009x^5;​​modelPlot=Plot[q[x-80],{x,80,320}]​​
Finally, let us combine the plot of the data and the plot of our model:
In[]:=
Show[modelPlot,dataPlot]