Facing the ARIMA Model against Neural Networks
Tags: Artificial Intelligence, Machine Learning, Time Series Forecasting, Arima, Artificial Neural Network

Regarding this first plot, we can see that at the end and at the beginning of each year the concentration of PM2.5 particles is higher than in other periods of the year, but it is still fuzzy data and we can barely have a better understanding of what is really happening. Because of this, some transformations are needed to be able to get a deeper insight into our data. There are many tools available, and here we are only going to use two, but there are many others that can provide better or different insights.

Grouping by different frames of time

The first method is as simple as to compute the mean of the data measurements by week or month.

Weekly average.

Monthly average,

As we can see from the plots, the information that we get from the data using this method is not very clear.

Moving average

This time we are still going to use the mean but in a different way, by using the Moving Average, that computes the average of N given time steps. It will smooth the data allowing the viewer to infer some visible patterns or trends.

Weekly Moving average

In this last plot, we can clearly spot some regular patterns. However, these methods are very sensitive to outliers and as we can see in the first plot our data has many of them.

Please note the difference between these two transformations because they look similar but they are not the same. In the average, we just compute the average per week and in the Moving Average (MA) we compute the average of N lagged observations. Although, the second one is more useful because it will help us to smooth the data removing the noise.

First Conclusion

There is nothing clear we can get from the data even though it seems to have many outliers. and one can think of these outliers as faulty measures by the devices related to any kind of misfunction. However, doing some research we will find that these levels have been already reached and documented in the capital of China.

Getting closer to the last weeks

The data that we have evaluated so far looks quite messy, and as the objective of this small project is to apply different forecasting techniques, we are going to focus the efforts in the last four weeks of the entire dataset. By doing so the visualizations are going the be easier and we will see clearly how the predictions fit in our data.

The caption of the last four weeks

In the distribution of the data, we can see that most of the data is grouped in the first values, looking like the exponential distribution.

In this data dataset, there are 716 measures of the particle’s concentration, around one month of data. With a mean of 78 particles per hour. This means is considered as unhealthy and people should not be exposed during long periods of time to these levels.

Stationarity

Before applying any statistical model it’s important to check if our data is considered as stationary

Stationarity basically means that the properties such as the mean and variance don’t change over time.

(https://www.itl.nist.gov/div898/handbook/pmc/section4/pmc442.htm)

There are various ways to check if data is stationary, and one good way is the Test Dickey-Fuller, which states that if the p-value is lower than a given threshold it won’t be considered as stationary.

Test Dickey-Fuller

As we proved with Dickey-Fuller Test, fortunately, our data is stationary which means that it doesn’t have any kind of trend and therefore it doesn’t need any transformations and we can directly to apply ARIMA.

Sometimes the time series are non-stationary. For these cases, it is possible to apply transformations to the data that will make them stationary.