Polynomial regression and the COVID-19 epidemic
Polynomial regression and the COVID-19 epidemic
Random training-validation split
Random training-validation split
The first method randomly selects 80% of the data as a training set and uses the remaining 20% as validation. The following commands will choose the training and validation data for you; you can change the percentage of data set aside for validation.
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.
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
Time-sequenced validation set
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.
The following command will find a polynomial of best fit by minimizing training MSE. You can change the degree of the polynomial.
degree=5;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.
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.
yLimit=100000;plotErrors[dataFuture,yLimit]
The Singh-Bawa model
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]