# IoT Implementation of Kalman Filter to Improve Accuracy of Air Quality Monitoring and Prediction
## 5 Discussion
### Predictive Ability Analysis
The parameter \(\lambda\) determines the rate at which \"older\" data enter into thecalculation of the EWMA statistic. A large value of \(\lambda\) (closer to 1) gives more weight to recent data and less weight to older data, while a small value of \(\lambda\) (closer to 0) gives more weight to older data. In this paper, the value of \(\lambda\) is 0.4, and the model input of each period is the same as the SMA. (4) ARIMA Prediction. The ARIMA model, also known as the differential autoregressive moving average model, transforms nonstationary time series into stationary time series, learning from historical data to patterns that change over time [54]. After learning, this rule is used to predict the future. The ARIMA model can be written as ARIMA(\(p,d,q\)) and is an extension of the ARMA(\(p,q\)) model. In ARIMA(\(p,d,q\)), parameters \(p,d\) and \(q\) are non-negative integers, \(p\) is the order (number of time lags) of the autoregressive model, \(d\) is the degree of differencing when the time series becomes stationary, and \(q\) is the order of the moving-average model. ARIMA(\(p,d,q\)) can be expressed as:  
\[\left(1-\sum_{i=1}^{p}\varpi_{i}L^{i}\right)(1-L)^{d}X_{t}=\left(1-\sum_{i=1}^ {q}\varpi_{i}L^{i}\right)\epsilon_{t} \tag{13}\]  
where \(L\) is a lag operator. Since the parameters of each difference in the model need to be determined before the ARIMA prediction, this paper selects the 70 h data of the monitoring site before 0:00 on 16 February 2019 as the training set for the ARIMA model. The specific training process is: (1) determine the minimum difference order \(d\) that transforms the original data into a stationary sequence \(S\); (2) calculate the autocorrelation and partial autocorrelation coefficients of sequence \(S\), to determine the values of \(p\) and \(q\); (3) estimate the parameters of each difference after completing the ARIMA model. (5) Comparison. In order to compare the prediction accuracy of KF, SMA, EWMA, and ARIMA more intuitively, the verification data set selected is the concentration of various air pollutants collected by the monitoring site on 16 February 2019, in PMS. Three evaluation indicators, MSE, RMSE, and MAE are also chosen to measure the performance of each model. As shown in the following table:  
As illustrated in Table 3, the MSE, RMSE, and MAE of the KF in predicting the concentration of each pollutant are the lowest, compared with the other three algorithms. In detail, the average RMSE is reduced by 68.3%. That is to say, the KF algorithm shows the smallest prediction error as a whole, and its prediction performance is the best. \begin{table}
\begin{tabular}{c c c c c} \hline \hline
**Type** & **Algorithm** & **MSE** & **RMSE** & **MAE** \\ \hline \multirow{4}{*}{SO\({}_{2}\)} & Kalman Filter & 0.0834 & 0.2888 & 0.2292 \\  & ARIMA & 0.4382 & 0.6620 & 0.4411 \\  & EWMA & 0.4202 & 0.6483 & 0.4696 \\  & SMA & 1.2255 & 1.1071 & 0.5978 \\ \hline \multirow{4}{*}{NO\({}_{2}\)} & Kalman Filter & 2.0523 & 1.4326 & 1.1996 \\  & ARIMA & 10.6014 & 3.2560 & 2.4728 \\  & EWMA & 12.8009 & 3.5778 & 2.9709 \\  & SMA & 19.7065 & 4.4392 & 3.5870 \\ \hline \multirow{4}{*}{CO} & Kalman Filter & 0.0005 & 0.0228 & 0.0186 \\  & ARIMA & 0.0022 & 0.0468 & 0.0223 \\  & EWMA & 0.0019 & 0.0432 & 0.0313 \\  & SMA & 0.0042 & 0.0649 & 0.0402 \\ \hline \multirow{4}{*}{O\({}_{3}\)} & Kalman Filter & 49.8062 & 7.0574 & 6.1945 \\  & ARIMA & 132.5246 & 11.5002 & 8.8032 \\  & EWMA & 175.5706 & 13.2503 & 11.0526 \\  & SMA & 262.682