Using the kalman filter with Arima for the COVID-19 pandemic dataset of Pakistan

The current pandemic of the Novel Corona virus (COVID-19) has resulted in multifold challenges related to health, economy, and society, etc. for the entire world. Many mathematical epidemiological models have been tried for the available data of the COVID-19 pandemic with the core objective to observe the trend and trajectories of infected cases, recoveries, and deaths, etc. However, these models have their own assumptions and parameters and vary with regional demography. This article suggests the use of a more pragmatic approach of the Kalman filter with the Autoregressive Integrated Moving Average (ARIMA) models in order to obtain more precise forecasts for the figures of prevalence, active cases, recoveries, and deaths related to the COVID-19 outbreak in Pakistan.


Specifications
Infectious diseases Specific subject area Time-series and econometric modeling Type of data Table  Graph How data were acquired The data were acquired from the official website maintained by the Government of Pakistan ( http://covid.gov.pk/ ). Instruments: Programming language R and its packages, "TSPred" "forecast", and "SutteForecastR" were used for the analyses.

Data format
The data are in raw format and have been analyzed. An Excel file with data has been uploaded.

Parameters for data collection
The dataset consists of daily reported total (cumulative) confirmed & active cases of COVID-19, recoveries, and deaths. The parameters were used for the Kalman-filtered ARIMA models.

Description of data collection
The daily prevalence data of cumulative confirmed COVID-19 cases, active cases, recoveries, and deaths in Pakistan from February 26, 2020, to April 30, 2020, were collected from the official website of the Government of Pakistan ( http://covid.gov.pk/ ), and MS-Excel 2019 was used to build a time-series database for further analysis.

Data source location
Ministry of National Health Services Islamabad Pakistan

Data accessibility
Raw data can be retrieved from http://covid.gov.pk/stats/pakistan

Value of the Data
These data are useful because they provide a forecast for not only the number of confirmed cases reflecting the outbreak of the COVID-2019 pandemic but the number of active cases, recoveries, and deaths as well, thus representing a valid and objective tool for monitoring infection prevalence and control. The institutions involved in the command and control of the pandemic and the general public can both benefit from these data when using outcomes of the fitted models. With the help of fitted models and the use of available data, some reliable forecasts of infected cases, active cases, recoveries, and deaths can be made for the future. Better measures about epidemic management can be taken after applications of the fitted Kalman-filtered ARIMA models. The health practices, facilities, need and intensity of lockdown, and efficient quarantining period can be assessed.

Data description
The daily prevalence data (number of cumulative confirmed cases) of COVID-19, number of total active cases, recoveries, and deaths from Pakistan for 65 days from February 26 to April 30, 2020 were collected from the official website of the Government of Pakistan ( http: //covid.gov.pk/ ) [1] . The obtained raw data were tabled in MS-Excel 2019 to build a time-series database for further use. The Kalman filters with the ARIMA models were applied to the dataset, in relation to the COVID-19 pandemic. Fig. 1 shows that the overall prevalence and active cases of COVID-19 have an increasing trend (in the form of exponential curves) depicting an epidemic in Pakistan. Fitting of normal distribution to the residuals and autocovariance function (ACF) were also displayed in Fig. 1 . The daily situation of total (cumulative) recoveries and deaths with a five-day-ahead forecast has been displayed in Fig. 2 & 3 , respectively. The recovery-& death-rates (out of closed cases) are presented in Fig. 4 . Table 1 compares different fitted models showing the results of fitting data (April 26-30, 2020) of total confirmed cases. Table 2 reports the figures about forecast of prevalence, active cases, recoveries, and deaths with relative 95% confidence intervals.

Experimental design, materials, and methods
The primary purpose of using time-series models, such as autoregressive moving average (ARMA) models, is to forecast. These models are applicable to stationary (stable) time-series, and the Augmented Dickey-Fuller (ADF) unit-root test [2] is commonly used to check whether the time-series is stationary or not. In practice, log transformation and differences are the pre-   ferred approaches to stabilize the time-series [3] . Seasonal and non-seasonal differences are used to stabilize the term trend and periodicity [4] . If a time-series becomes stationary after differencing, then an ARMA model used for that transformed series is referred to as an ARIMA model where "I (integrated)" reflects the order of differencing. Usually, the Box-Jenkins methodology [3] is used to fit an appropriate ARIMA model. There is another class of models called the state space models (SSMs). An SSM involves dynamics for an unobserved stochastic process called the state and a distribution for the actual observations called function of the state. Every ARIMA model is actually an SSM. The Kalman filter (KF) is an algorithm that works in the context of an SSM to compute the sequence of filtering distribution (the distribution of the current state) and compute the likelihood of the data. Thus, the use of the KF with ARIMA could provide better predictions and forecasts through optimal estimates. However, the presence of outliers may affect the optimality while using the KF [5 , 6] .
A package "TSPred" of the R language [7] was used for the KF algorithm with the most appropriate ARIMA model for the data about COVID-19. After applying the ADF test, the data-series of cumulative confirmed cases was made stationary with the first difference and the most suitable order of ARIMA, following the Box-Jenkins methodology [3] , was ARIMA (1,1,1). Similar routines were followed for the other data series.
The proposed method of forecasting was compared with one of the classical methods (i.e., the Holt-Winters method [8] ) and one of the latest available models i.e., the SutteARIMA [9 , 10] . For the evaluation of the forecasting methods, many popular measures for the accuracy of forecasting were considered. However, we report here the absolute percentage error (APE) and mean APE (MAPE).
where Y t and F t are observed and forecast values, respectively at time t . Four previous studies were considered as reference for the methodology of the analysis [6 , 10-12] .
To determine the prevalence (cumulative confirmed cases) of COVID-19 and active cases in Pakistan, the KF algorithm was used for the best-fitted ARIMA models, following the available methodology [6] . Following Benvenuto et al. [8] , logarithmic transformation was performed to evaluate the influence of seasonality on the forecast.
As recoveries from the infection of COVID-19 and deaths due to COVID-19 depend on the prevalence of the disease, it is not appropriate to fit some direct models to the data of recoveries and deaths. Therefore, it is proposed to model the ratios ( R t / C t and D t / C t ) where C t = cumulative confirmed cases; R t = cumulative recoveries; and D t = cumulative deaths at time t . The forecasts of these ratios can easily be converted into the respective figures of total recoveries and deaths after considering the results of the model for confirmed cases.
The forecasting accuracy was compared for three methods used-the Holt-Winters method, SutteARIMA, and KF-ARIMA-for all the data-series. We report here the results for the cumulative confirmed cases of COVID-19 for five days (April 26-30, 2020). The actual reported values, forecast values and APE and MAPE are displayed in Table 1  The forecast figures were computed for the next five days (i.e., May 1 to May 5, 2020) of the used dataset. These figures with relative 95% confidence intervals are reported in Table 2 . Although the spread of the virus seems to be increasing slightly, the number of recoveries are also increasing with a relative small number of deaths.
Finally, it may be noted that forecasting is always a tricky subject and there can be a number of candidate models that can be fitted to the available data. However, any fitted model may not be fully accurate due to the complex, evolving, and varying environmental, social, and economic conditions of different countries. Thus, predictions and forecasts are uncertain by nature. The above presented models and forecasts do not consider the regional demography, and the actual figures may change due to many administrative measures like intensity of lockdown, policy of quarantining and health facilities etc. Thus, readers should be careful while interpreting these forecasts.

Declaration of Competing Interest
The author declares no known competing financial interests or personal relationships that could have appeared to influence the work reported in this paper.