Simple COVID-19 Data Analysis
By: Akshith Ramadugu
Tags: Data, Data Science, Beginner, Covid 19, R

Predictions and Models

Going back to the data set supplied by Kaggle, models can be crafted to predict the increase/decrease of confirmed cases and fatalities. I employed four models to predict NY approved instances by the date.

##NY Data

ny <- k.train %>% dplyr::filter(Country_Region == “US” & Province_State==”New York”) %>%

dplyr::filter(Date >=”2020–03–05") ny.test <- k.test %>% dplyr::filter(Country_Region == “US” & Province_State==”New York”)

The first model is a Generalized Linear Model or GLM. This model links the underlying linear model to a response variable, which in this case would be Confirmed Cases.

##GLM

glm <- glm(ConfirmedCases~ Date, data=ny)

summary(glm)

pred.glm <- predict(glm,ny.test)

pred.glm <- as.data.frame(pred.glm)

The next model I used was a Support-vector machine Model or SVM, and this model does a regression analysis/assignment in a hyperplane or near-infinite space. In this hyperplane, the model would ideally root out outliers and make proper classifications regarding the variables.

##SVM

svm.model <- svm(ConfirmedCases ~ Date, data = ny)

summary(svm.model)

pred.svm <- predict(svm.model, newdata = ny.test)

pred.svm <- as.data.frame((pred.svm))

Following the use of an SVM, I created a Random Forest model using the same combination of variables. Random Forest works by creating decision trees for regression or classification tasks. Random decision forests correct for decision trees’’ habit of overfitting to data.

##Random Forest

rf.model <- randomForest(ConfirmedCases~ Date, data = ny)

summary(rf.model)

rf.predict <- predict(rf.model, ny.test)

rf.predict <- as.data.frame((rf.predict))

The final model that I used, and more so due to curiosity, was a Gradient Boosting Model or GBM. This model addresses classification and regression by producing a prediction model in the form of an ensemble of weak prediction models. The overall goal is to try and relate all the weaker associations.

After training each model, I used them to predict a 43 time period (04/02/2020–05/14/2020) of Confirmed COVID-19 cases using the Kaggle test data. I also used another data set from the COVID -19 tracking project to find the error for each model.

[1] "GLM: " >DMwR::regr.eval(pred.glm.error,nycConfirmedCases$ConfirmedCases)

mae mse rmse mape

3.442320e+05 4.696230e+09 6.852904e+04 1.833325e+00 > print(paste("SVM: "))

[1] "SVM: "

> DMwR::regr.eval(pred.svm.error,nycConfirmedCases$ConfirmedCases) mae mse rmse mape

1.929837e+05 1.810168e+09 4.254607e+04 9.352455e-01> >print(paste("RF: "))

[1] "RF: "

> DMwR::regr.eval(rf.predict.error,nycConfirmedCases$ConfirmedCases) mae mse rmse mape

8.941814e+04 3.756527e+08 1.938176e+04 4.436796e-01 > print(paste("GBM: "))

[1] "GBM: "

>DMwR::regr.eval(boost.predict.error,nycConfirmedCases$ConfirmedCases)

mae mse rmse mape

7.027998e+06 1.286084e+12 1.134056e+06 1.120166e+04

The Root Mean Square Error, or RMSE, was the best for the Random Forest model at 1.938176e+04. However, it is essential to note that in the grand scheme of things, that error is way too large and permanently stops this Random Forest model from being deployed for further predictions. It requires refinement either through data wrangling or improved model parameters.