Machine learning forecasting of CR and PRC balance of trade

International trade is an important factor of economic growth. While foreign trade has existed throughout the history, its political, economic and social importance has grown significantly in the last centuries. The objective of the contribution is to use machine learning forecasting for predicting the balance of trade of the Czech Republic (CR) and the People ́s Republic of China (PRC) through analysing and machine learning forecasting of the CR import from the PRC and the CR export to the PRC. The data set includes monthly trade balance intervals from January 2000 to June 2019. The contribution investigates and subsequently smooths two time series: the CR import from the PRC; the CR export to the PRC. The balance of trade of both countries in the entire monitored period is negative from the perspective of the CR. A total of 10,000 neural networks are generated. 5 neural structures with the best characteristics are retained. Neural networks are able to capture both the trend of the entire time series and its seasonal fluctuations, but it is necessary to work with time series lag. The CR import from the PRC is growing and it is expected to grow in the future. The CR export to the PRC is growing and it is expected to grow in the future, but its increase in absolute values will be slower than the increase of the CR import from the PRC.


Introduction
According to Jánošová [1], international trade is an important factor of economic growth. The definition of international trade in the study of Fürst and Pleschová [2] is that the term "international trade" refers to exchange of goods, services and capital across international borders. The authors believe that carrying out this type of trade is much more complicated process than at the national level. Bernard [3] states that in most countries, international trade constitutes a significant share of gross domestic product. While foreign trade has existed throughout the history, its political, economic and social importance has grown significantly , 010 (2020) Web of Conferences https://doi.org/10.1051/shsconf /2020730100 0 SHS 73 IES2019 4 4 data. When using regression models with time series data, it is necessary to distinguish between two types of forecast, that is, ex ante and ex post. Ex-ante forecasts are those that are only made using data available in advance, and ex-post forecasts are those using later predictor data [27]. Yu, Wang and Lai [28] in their study report that the difficulty of forecasting the volume of foreign trade is often due to the limitations of many conventional forecasting models. To improve forecasting performance, it is necessary to propose an approach that would hybridize artificial intelligence models and econometric models. According to Cai, Chen and Fang [29], CNY exchange rates can be considered financial time series characterized by high non-linearity, uncertainty and behaviour changing over time. Liu et al. [30] made exchange rates forecasts using ANNs RBF (radial basis function). Their results have shown that the efficiency of ANNs RBF in forecasting CNY exchange rates if acceptable. Chang and Vochozka [31] deal with ANNs, decision trees, and hybrid model of ANNs. They compare the models of stock prices forecasting models created by means of these three methods. Their study also found that compared to other two methods, ANNs is a more stable forecasting method. Weijin and Yuhui [32] present a model used for forecasting import and export within a single sector. The authors have found that non-linear forecasts can deal not only with the combination of data and improving the accuracy but can also reflect non-linear characteristics of the forecasting system. De Souza, Freitas and De Almeida [33] introduced a new predictor of neural time series weight, which uses virtual generalized ANN weighting with a random approach to forecasts of future incomes from shares. The predictor was evaluated based on predicting future weekly returns on 46 shares from Brazilian stock market. The results have shown that the predictors of weighted ANN with a random-access weight generate forecasts of future revenues with the same error level and characteristics of autoregressive ANNs basic predictors 5,000 times faster. Dongdong and Wenhong [34] note that financial time series are non-linear, nonstationary, and stochastic, which can be seen as difficult. In their work, the authors used a specific method based on wavelet analysis and artificial intelligence for forecasting the A300 index in China and NASDAQ index in the USA. Their model shows superiority in performance forecasting. The results show that these methods are suitable only for short-term forecasting. The prediction difference between A300 and NASDAQ indicates that the Chinese stock market is less efficient than the US market. The aim of Tkacz [35] is to improve the accuracy of financial forecasting of Canadian production growth using the most significant models of artificial neural networks (ANNs). In his study, the author has found that ANNs show statistically smaller forecasting errors in terms of year-on-year growth of real GDP compared to linear and univariate models. However, such forecasting improvements are less significant in forecasting quarterly growth of real GDP.
Copper prices in international trade markets are volatile. Accurate forecasting of copper price can result in commodity trading and fixed profits in the copper industry. For predicting copper prices, Wang et al. [36] 4 4 linear regression is carried out. Subsequently, ANNs are used for regression analysis. From linear regression, the curve obtained by means of spline function appears to be the most suitable one. All ANNs have proven applicable in practice. Vijayalakshmi and Girish [38] provide an overview of literature dealing with short-term forecasting of spot electricity prices in deregulated competitive energy markets using ANNs. Accurate prices forecasts enable the participants in energy markets to maximize their profit and meet their commitments in the area of energy using the right combination of energy purchase agreements, bilateral trade, and purchase/sale of electricity through energy exchanges in a reasonable, efficient, and effective manner. ANNs models have proven to be the tool for short-term forecasts of spot electricity prices.
The foreign exchange market is one of the most invested markets in the world, with an average daily volume of trade of USD 1.8 trillion. Due to extreme volatility and uncertainty associated with foreign currency fluctuations, exchange rate forecasting is one of the most demanding and difficult tasks both for researchers and experts from practice. Traditionally, exchange rate is forecast for some technical indicators which just followed past price trends without considering a number of other factors. However, if the foreign exchange market is influenced by an accidental event, these indictors will provide misleading forecasts. This means that traditional forecasting techniques, such as linear trend analysis, would not work for forecasting future foreign currency fluctuations. To overcome this lack of traditional forecasting techniques, Emam and Min [39] propose ANN, which have proven useful for forecasting volatile financial time series, such as exchange rates. After applying ANN to actual data, the authors have found that the proposed ANN is very effective for forecasting daily fluctuations of exchange rates.

Data and methods
The current world trade is significantly affected by the trade policy of the United States of America (the USA), which gradually imposed sanctions on the Russian Federation, Turkey, and other states. They started trade war with the PRC, the European Union, and other countries, thus creating a new framework of the trade relationships between countries directly involved in the international politics game, but also the countries which are not directly affected, threatened or influenced by the US trade policy. It can thus be stated that the new relations will definitely be hard to forecast (also due to the way the USA changes them. Stability on international markets is also derived from the prediction of the future development of the key macroeconomic indicators. The question therefore is, whether at present, to a certain extent turbulent time, it is possible to forecast the key macroeconomic indicators using standard statistical methods. As the research suggests, artificial neural networks are supposed to be successful in solving such tasks. Some authors already proved that the artificial multilayer perceptron neural networks are able to find the correlation even between very non-linear variables. At the same time, they are also able to find certain trend in year-on-year, month-on-month and week-on-week development of time series. They can therefore identify seasonal fluctuations quite accurately. The aim of the contribution is to investigate and subsequently smooth two time series: 1. The CR import from the PRC. 2. The CR export to the PRC. On the basis of the results obtained, it will be possible to predict the future development of the balance of trade of two trade partners. The data set shows the course of the time series at monthly intervals starting from January 2000 to June 2019. The course of both time series is shown in Figure 1. Source: [40], edited by authors The figure does not show seasonal fluctuations in the time series development within the individual years of the monitored period. However, there is a clear increase in import to almost 20-time higher volume since 2000. There was also an increase in the CR export to the PRC during the monitored period (more than 50 times higher), but the difference between import and export is almost five times in favour of the CR import from China. Nevertheless, it can be assumed that the time series development is not random but subject to seasonal fluctuations, although they are not obvious at first sight. As evident from the figure, the balance of trade of both countries in the entire monitored period is negative from the perspective of the CR. The shape of the curve is very similar to the inverse curve of the import. The export development is less noticeable on the curve of the balance of trade. Table  1 shows the basic statistical characteristics of the data set.  Regression will be carried out using multilayer perceptron networks. Smoothing of the time series will be performed separately for import and export time series. The balance of trade will be the difference between the two variables over time. The procedure chosen corresponds to the situation where the two time series seasonal fluctuations are different.
Smoothing the time series separately and subsequent calculation of the forecast development of balance of trade using the most successful neural networks help achieve more accurate results.
Multilayer perceptron networks (MLP) will be generated. The time series lag will be 5 months. This means that the target (forecast) variable will be calculated using the data from the 5 previous months. This way a possible time series fluctuation caused by the latest data (in this case, this refers to the time series of the USA import from the PRC). A smaller lag can thus result in extreme fluctuations of smoothed time series, which would be a significant decrease in the case of import and increase in the case of export. Larger time series lag can mean averaging of the values. However, each time series lag brings higher demands on the complexity of the artificial neural structure, more specifically the neurons in the input layer (in the case of this calculation, it will be 15 neurons I the input layer of the artificial neural structure).
The independent continuous variable will time. Seasonal fluctuations will be represented by categorical variable in the form of the month and the year in which the value was measured. We will thus work with possible monthly seasonal fluctuations of the time series. However, it should also be possible to capture the overall trend of the time series. They will be entered as continuous variables in the "Integer" regime. The dependent variable will be the CR import from the PRC or the export from the CR to the PRC.
The time series will be divided into three sets -Training, Testing, and Validation. The first group will contain 70% of the input data. The training data set will be used for generating neural structures. The remaining two sets will contain 15% of the input data each. Both sets will be used for verifying the reliability of the neural structure or the model found. A total of 10,000 neural networks will be generated, out of which 5 with the best characteristics † will be retained. The hidden layer will contain at least 2 and at most 9 neurons. The following distribution functions in the hidden layer and the output layer will be considered: Linear, Logistic, Atanh, Exponential, Sinus.
Other settings will be default (according to the ANN tool -automated neural networks). Finally, the prediction of both time series until December 2020 will be carried out. At the same time, the balance of trade will be calculated through the export and import difference. However, this implies that from the retained networks, the neural network able to forecast the concrete time series development most accurately. Table 2 shows the overview of the neural networks retained in smoothing the import time series at the time series lag of 5 months. † Least squares method will be used. Generating of networks will be finished if there is no improvement, that is, if there is no reduction in the sum of the squares. We will thus retain the neural networks whose sum of the residuals squares to the actual CR import from the PRC or the CR export to the PRC is as low as possible (zero in ideal case).  Due to the time series lag, the input layer contains 15 neurons. The table shows that the neural networks with 4-10 neurons in the hidden layer were retained. For the activation of the hidden layer, the function of hyperbolic tangent and logistic function are used. For the activation of the output layer, exponential, identity, and hyperbolic tangent functions are used. The correlation coefficient of all neural networks data sets achieves very high values, always from more than 0.93 to more than 0.97, which indicates high degree of direct dependence. The retained neural networks thus shall be able to forecast the future development of the CR import from the PRC very accurately. The error was set by means of the sum of the least squares. The error is approximately the same as the error calculated in the first experiment. The error is rather large but acceptable with regard to the high values of the variable (in all data sets and networks). Figure 2 shows the comparison of the actual course of the time series and the smoothed time series.  subsequently a significant decrease in the CR import (this was between September 2015 and December 2015. The value is not stabilized until January 2016). In order to determine whether the networks are applicable, we will deal with their application for forecasting. The development of the CR import from the PRC for the period of July 2019-December 2020 will be forecast. Concrete data is shown in Table 3. The results shown in the table represent a possible development of the time series. I tis evident that the network 3. MLP 15-31 will not be considered for the application, since it achieves very low values during the monitored period, and the network 5. MLP 15-10-1, which achieves extremely high values. The detailed course of predictions can be seen in Figure 3.  Comparing the actual development of the CR import from the PRC and the forecast development of the variable over time forecast using artificial neural networks retained in Experiment 2, it can be concluded (namely with regard to the table of statistics in Annex 2) that the network 1. MLP 15-5-1 can be seen as the best artificial neural network with a potential of forecasting further development of the CR import from the PRC. The network is also able to capture the seasonal fluctuations and the overall trend of the time series.

Export
Also in the case of smoothing the export time series, 10,000 artificial neural networks were generated, out of which 5 with the best characteristics were retained (see Table 4). In the case of export, the input layer also contains 15 neurons. It results from the table that the neural networks with 4-10 neurons in the hidden layer were retained. For the activation of the hidden layer, the neural networks use the functions of hyperbolic tangent and sinus. The output layer of neurons is activated by means of the exponential, sinus, and identity functions. The performance of the artificial neural networks measured by correlation coefficient achieves the values of more than 0.97 in the training data set, more than 0.98 in the testing data set (above 0.99 in the case of the 2. MLP 15-10-1) and more than 0.98 in the validation data set. This indicates direct dependence in almost all cases. Based on this parameter, it can be stated that the networks (if not suffering from overfitting) are able to forecast the further development of the CR export in the PRC very accurately (since they were smoothing the time series in the past very accurately). For the calculation of the error, the least squares method was used. In the case of export, the error calculated achieves quite high values; however, since we work with the parameter given in USD and with regard to the individual values, the error is acceptable. Figure 4 shows comparison of the actual course of the time series and smoothed time series.  It results from Figure 4 that all smoothed time series are able to follow the actual development of the CR export to the PRC relatively well. However, the actual time series is so disordered that the models are not able to capture all local extremes, especially in the last quarter of the monitored period, which shows extreme fluctuations. Nevertheless, the parameters of the neural structures acquired provide a precondition of quality monitored time series forecasting (although they are not able to fully capture the local extremes of the time series, they react to the fluctuations of the neural network). Also in the case of export, we will deal with forecasting the further development of the variable monitored, predicting the development of the CR export to the PRC for the period of July 2019-December 2020. Concrete data is shown in Table 5. The data in the table indicate that none of the neural networks suffer from overfitting. Predictions made using the retained neural networks shall thus be applicable. To choose the most suitable structure for forecasting the CR export to the PRC, the graphical illustration of the course of predictions will be used (for more details, see the graph in Figure 5). Comparing the actual development of the CR export to the PRC with the forecast development of the variable over time forecast for the period of July 2019-December 2020 using artificial neural networks retained in smoothing the export time series, it can be concluded (especially with regard to the table of statistics in Annex 2) that the network 1. MLP 15-4-1 shows the best predictions.

Results discussion
Within the research, smoothing of time series of the CR import from the PRC and the CR export to the PRC was carried out. Time series lag was set for 5 months in both cases. This eliminated potential extraordinary fluctuations caused by fluctuations of the time series in the individual months. First, it was observed how multilayer perceptron neural networks are able to smooth time series. For both time series, 10,000 artificial neural networks were generated, out of which five best structures were retained. In forecasting the future development of import, two neural structures had to be excluded since they apparently suffered from overfitting. In graphical comparison, another network suffering from overfitting had to be excluded. The two remaining networks were compared in terms of their basic statistical parameters and with regard to the current development of the time series. Subsequently, a network for calculating the balance of trade of both monitored countries was chosen. Also, artificial neural networks smoothing the time series of the CR export to the PRC were analysed. For this, all retained networks appeared to be applicable, but one of the captures the future development more accurately than others. It was thus used for calculating the CR and PRC balance of trade. It shall also be stated that the error identified is acceptable. The difference of predictions calculated using the most successful neural structures was used for calculating the balance of trade from the perspective of the Czech Republic (for more details, see Table 6).   Table 6 demonstrates the potential development of the monitored variables and mainly the target variable -balance of trade. It assumes the growth in the CR import from the PRC, slight growth in the CR export to the PRC and the growth in negative balance of trade of the CR and the PRC. This situation is even better illustrated in Figure 6.   4 4 increase. From the perspective of the Czech Republic, the balance of trade of both countries will be even more negative than now.

Conclusion
The objective of the contribution was to predict the development of the Czech Republic (the CR) and the People´s Republic of China (the PRC) balance of trade in analysing and machine learning forecasting of the CR import from the PRC and the CR export to the PRC. Both monitored time series were smoothed. In both cases, the most successful neural network was chosen. From the difference of the CR export to the PRC and the CR import to the PRC, the balance of trade of both countries was calculated.