1. Introduction
China’s capital market has made great achievements after three decades of development. However, in view of the global situation, China is facing a major change that has not been seen in a century. Therefore, the importance of capital market reform and development has continued to rise and has deepened since the 18th National Congress of the Communist Party of China. On this basis, the pursuit of the accuracy of capital market price forecasting helps stockholders to understand the comprehensive market situation of the stock market industry [
1]. Investors rely on changes in the index to determine the trend of stock price movements, so changes in capital market prices have always been of concern to stockholders and investors, and are a hot spot for scholarly research. Information on the direction and intensity of shocks, and volatility interactions in financial markets is important for investors, policy makers and financial market planners [
2].
Therefore, this paper uses the bat algorithm to optimize the three parameters in the Gaussian radial basis kernel function support vector regression model and compares the prediction performance with the support vector regression model of the other two types of kernel functions.
(1) In terms of data selection, this paper selects the daily data of 18 stock indices in China from 2016 to 2020, and uses the data of the last 20, 60, and 250 days in the full sample interval as the short-term forecast group, Mid-term forecast group and long-term forecast group.
(2) In the selection of predictive performance evaluation indicators, this paper integrates the existing evaluation indicators. Three indicators—RMSE, MAE and MAPE—were selected. The simulation experiment calculates the three index values of the gap between the optimized model predicted value and the true value and compares and analyzes it with the control model.
The rest of the paper is organized as follows:
Section 2 mainly introduces the literature review on stock price forecasting.
Section 3 improves the original bat algorithm and proposes a novel hybrid bat algorithm model (BA-SVR) that can predict stock prices. The steps and processes are also described in detail.
Section 4 discusses the choice of parameters and designs empirical simulation experiments.
Section 5 deals with performance evaluation and
Section 6 discusses the robustness test. Finally, the last section consists of the conclusion and future work.
2. Literature Review
In recent years, most of the existing studies have focused on different types of models and parameter optimizations that are beneficial to improve the accuracy of existing information for predicting future stock prices. Therefore, the literature related to this paper can include the following two aspects. One is to improve the accuracy of stock price prediction mainly through the analysis of models. The second is to study the optimization of parameters between different algorithms.
In terms of models, most of the literature in this category focuses on financial forecasting of time series data such as stock prices, and their methods of predicting stock prices are more traditional. This includes ARCH models, GARCH models, etc. For example, Du [
3] used ARCH models to study the response of Nikkei 225 closing prices to different types of data during the period from 5 January 1998 to 29 December 2017. Abounoori [
2] estimated a multivariate GARCH model for weekly stock index data to study the interaction of stock markets between Iran, the United States, Turkey, and the United Arab Emirates. While these methods have some advantages, such linear forecasting models have strict assumptions in the application of data distribution and are not suitable for forecasting financial data sets.
Therefore, some scholars have started to focus on nonlinear forecasting models in recent years. They try to forecast financial asset yields and prices by machine learning methods and construct models. The empirical study proves that machine learning methods are better than traditional time series analysis models in terms of forecasting accuracy. Gradojevic [
4] employs a nonparametric approach to forecast high-frequency exchange rates, which significantly improves the forecasting ability of both linear and nonlinear models. The nonlinear model outperforms the random walk and linear models based on some recursive out-of-sample forecasts. The artificial neural network model outperforms the random walk and any linear competing model for high frequency exchange rate forecasting. Given the growing interest in Chinese stock volatility, Liu [
5] extracts global stock information by combining forecasts from a time-varying parametric (TVP) volatility model to forecast Chinese stock volatility. Vlah Jerić [
6] reports the results of a study that collects data on stock market participants’ expectations of future levels of stock indices. Cheng and Shi [
7] also focus heavily on Chinese stock volatility, they conducted a comprehensive study on the prediction of Chinese stock market variance using 24 commonly used predictor variables, documenting the unstable relationship between scaled stock market prices and market variance. While Harel and Harpaz [
8] apply machine learning concepts to predict stock prices, demonstrating the trade-off between sensitivity and specificity of forecasts. Wu [
9] proposes a novel fuzzy time series forecasting model based on technical analysis, affine propagation clustering, and support vector regression models. The performance of the method is proved using the Taiwan Capitalization Weighted Stock Index, Standard and Poor’s 500 Index, and Dow Jones Industrial Average datasets.
However, the prediction process of machine learning and artificial intelligence often requires the initial parameters under specific models to be set in advance. For the more sensitive model parameters, the appropriateness of their settings can greatly affect the effectiveness of model fitting and forecasting. Intelligent optimization algorithms have been used to initialize the parameters of forecasting models to improve the accuracy of financial asset price forecasting. Among them, the bat algorithm has been increasingly used in management and operations research. It benefits from the bionic principle of the population algorithm and its better results in optimizing parameters. The bat algorithm can optimize the parameters as a way to achieve improved prediction performance. For example, Li et al. [
10] mixed support vector regression model with quantum computer mechanism, chaotic mapping function and bat algorithm. They proposed a novel prediction method that optimized the parameters and showed superiority in improving the prediction accuracy. Zhang et al. [
11] proposed a method that combined wavelet neural network (WNN) and adaptive mutation bat algorithm (AMBA). AMBA was used to optimize the network parameters of WNN. This method improves the accuracy of prediction and speeds up the training. Hong [
12] employs a support vector regression model with hybrid kernel functions. A chaotic efficient bat algorithm based on chaos, niche search and evolutionary mechanism is proposed for optimizing its parameters with satisfactory prediction accuracy. Moreover, Wu [
13] developed a least squares support vector machine model. The relevant parameters are optimized by the bat algorithm to improve the prediction performance.
Further, in stock index prediction, the bat algorithm will play a pivotal role in combination with other population intelligence algorithms or machine learning algorithms as well. In 2014, Chang et al. [
14] used the investment satisfaction ability index to screen potential candidates and used the evolutionary bat algorithm to construct stock portfolios. Hafezi [
15] designed a multi-agent framework for predicting stock prices with a bat neural network multi-agent system (BNNMAS), which tested a model for predicting stock prices in a global facing financial crisis for predicting DAX stock prices over a period of time. It is considered as a suitable tool for predicting stock prices, especially in the long-term period. While Golmaryami [
16] emphasized artificial neural networks (ANNs) with time series data and nonlinear parameters to predict the stock price the next day. The proposed ANNs were trained with the bat algorithm, which was first applied to stock price prediction in 2015. The approach was to first preprocess the data to predict the closing price of the stock using three types of ANNs. Subsequently, the performance of the three methods is evaluated by mean absolute percentage error (MADE). This literature provides an innovative idea and lays a theoretical foundation for the research in this paper. Mallikarjuna and Rao [
17] examine linear, nonlinear, artificial intelligence, frequency domain, and hybrid models to predict stock returns in developed, emerging, and frontier markets. Shahvaroughi [
18] uses artificial neural networks to predict stock price indices and uses social spider optimization (SSO) and Bat Algorithm (BA) to train it. Mean absolute error (MAE) is used as an error evaluation criterion. Some time series models of forecasting such as ARMA and ARIMA are used to predict stock prices.
3. Materials and Methods
3.1. The Original Bat Algorithm
The bat algorithm, as a method of swarm intelligence optimization algorithm, draws on the definition of bat algorithm by Yang [
19]. Here are the assumptions that the implementation of the bat algorithm satisfies. First, all bats rely on their own echolocation system to detect distances, and bats can accurately distinguish prey from obstacles and even distinguish what kind of prey it is. Second, each bat spontaneously adjusts the sonar rate and sonar loudness at any position to capture prey. Third, although the sonar loudness emitted by bats can be freely changed, for the sake of simplicity, it is assumed that there are maximum and minimum values of bat sonar.
Based on these three ideal state assumptions, we can describe the process of bat algorithm seeking global optimal solution as follows. Before the operation of the bat algorithm starts, for bat
i, we need to determine the position of the bat
,
, the bat’s flight speed
the maximum and minimum sound wave frequency
and minimum
, and the pulse rate
and set the initial value of impulse loudness
. The bat algorithm seeks the optimal position through iterations under certain conditions. In other words, it is the optimized parameter. Suppose the number of iterations
, where
is the maximum number of iterations, and
is the initial period. In each iteration of the bat algorithm, if the condition
is satisfied, it can update its flight speed
and position
by adjusting the sound wave emission frequency
. The update process is as follows:
where
refers to the global optimal position at the current moment, that is, the global optimal solution. It is equivalent to the position where bats can best catch their prey. Generally speaking, we set the initial value of
to 0.
Based on Equations (
1)–(
3),
i bats continuously iterate within a given maximum number of iterations to adjust the sound wave emission frequency
, flight speed
and location
. Next, we compare the pulse rate of
i bats with the random value rand. If the pulse rate is less than the random value, first select the bat with the largest sound wave frequency among all the bats whose pulse rate is less than the random value, and then find the optimal position according to
. Currently, if the random value is less than the impulse loudness
and the sound wave frequency is less than the local optimal sound wave frequency, then accept this solution, increase the pulse rate
and reduce the impulse loudness
, the adjustment processes are as follows:
where
is the loudness attenuation coefficient, and
is the rate enhancement coefficient. We sort the selected n bats according to the sound wave frequency, and get the bats in the optimal position, that is, find the local optimal solution. Finally, when the number of iterations reaches the preset maximum number of iterations, the algorithm terminates and the global optimal solution is obtained.
3.2. The Proposed Improved SVR Model
Support Vector Machine (SVM) models have been widely used and developed in academic circles since they were proposed. Depending on the data structure, SVM models can be divided into SVR models for regression and SVC models for classification. Compared with other learning methods, SVM is based on structural risk minimization, so it has strong generalization ability, and the local optimal point is the global optimal solution. The basic principles are shown below.
Given an n-dimensional data set , the regression function of the output space to the input space is , where is the weight and is the threshold.
The objective of the SVR is to find
such that the error between the true value and the predicted value is less than or equal to a given error
. The problem is then transformed into a conditional constrained optimization problem and expressed as:
In Equation (
6), the parameter
C is a penalty factor, which indicates the complexity of the model and the accuracy of sample fitting. The parameter
is the insensitive loss coefficient and are slack variables, which are meaningful only for outliers. Consideringthe introduction of Lagrangian operators
and
, the pairwise problem of Equation (
6) is
In Equation (
7), the kernel function
can make the function of the low-dimensional input space equal to the inner product of the high-dimensional space to achieve the dimensionality reduction effect. Generally speaking, it is divided into linear kernel functions, polynomial kernel functions and Gaussian kernel functions. For SVR can achieve high accuracy of nonlinear prediction by selecting the kernel function, this paper constructs SVR based on the Gaussian Radial Basis Function (RBF), and its formula is expressed as
where
is the width parameter of the Gaussian radial basis kernel function, which controls the range of radial action. Therefore, the regression model is
3.3. The Proposal of BA-SVR Hybrid Model
The main model constructed in this paper is a hybrid model of BA and SVR, and the main principle lies in the optimal estimation of the three parameters C, , and in the SVR model using the bat algorithm to achieve the initialization of the three parameters in the SVR model under the optimal prediction accuracy.
The steps of the hybrid BA-SVR prediction algorithm model are as follows.
Set the parameters of the BA-SVR model;
The parameters that need to be set include the maximum number of iterations of the bat algorithm , the size of the bat population (that is, the number of bats) N, the minimum loudness , the loudness attenuation coefficient , the rate enhancement coefficient for controlling the pulse rate, and the maximum frequency and minimum value , random movement step length (that is, the maximum value and minimum value of moving speed ), the number of parameters to be optimized, and the range of parameters to be optimized. Among them, if the linear kernel function is selected, the free parameters that SVR needs to optimize are the penalty factor C and the insensitive loss factor . If the RBF Gaussian radial basis kernel function is selected, the free parameters to be optimized for SVR also include the width parameter of the Gaussian radial kernel function.
Initialize the bat population;
This step includes pulse emission rate initialization, pulse loudness initialization, population initialization, flight speed initialization and pulse frequency initialization. Generally speaking, when initializing the bat population, it is often considered that the bat population is randomly distributed in a search space of a certain dimension, and the search dimension is the number of parameters that need to be optimized.
According to the setting of the model iteration of the bat algorithm, the bat is constantly looking for the optimal position in the search space, that is, constantly generating new solutions;
Calculate the fitness function;
As the basis for selecting the best position (optimum solution) in the BA-SVR model, the adaptability functions generally include MSE, RMSE, MAPE and other functions. This paper refers to the literature [
20], and uses the mean square error (MSE) as the fitness function of the model to verify the model,
Get the optimal solution;
According to the preset maximum number of iterations, when the number of iterations reaches the maximum number of iterations, the iteration is stopped, and the optimal solution is obtained. At this point the algorithm ends.
4. Parameters Selection and Empirical Design
4.1. Selection of Variables and Source of Data
In terms of variable selection, when forecasting stock index price and return, the opening prices, closing prices, lowest prices, highest prices, trading volume, and turnover are often considered. According to the extant literature, these six indicators of the stock index during four days or nine days before trading day are always used as input variables to predict future stock prices, for these indices would reflect adequate information of corresponding stock index [
21,
22,
23,
24]. Investors will get as much information about the stock index as possible and reflect all the information obtained by themselves in these six characteristics of the stock index. This information may not only include information related to the stock index but also include other information that may affect the closing price of the stock index, such as macroeconomic development and industrial policy. Therefore, the opening price, closing price, lowest price, highest price, trading volume and turnover during nine days before the trading day are used as multi-dimensional input variables in this paper, and the closing price on the 10th day is used as the predicted output variable for empirical prediction. The data used in this paper comes from the China Stock Market and Accounting Research (CSMAR) database.
In terms of empirical time selection, considering that the Chinese capital market was affected by the stock market crash in 2015, the time period of the total sample space is selected in this paper as 15 January 2016 (the 10th trading day in 2016) to 31 December 2020. That is, there are 21,762 pieces of data for each index of 1209 trading days. This paper uses the daily frequency data of the six characteristic variables of the 18 stock indexes in
Table 1. In addition, this paper refers to the literature [
24,
25,
26], the last 20 days, 60 days, and 250 days of the selected sample time are used as the test sets for short-term prediction, mid-term prediction, and long-term prediction, respectively. The other samples outside the forecast are the corresponding training sets.
4.2. Setting of the Initial Parameters of the BA-SVR Model
According to the implementation steps of the BA-SVR algorithm, the model parameters need to be set before the data iteration of the training set. Considering the total sample data dimension and data volume of the model in this paper, the initial parameters are set in this paper, including the maximum number of iterations maxgen , search dimensions (that is, the number of parameters that need to be optimized) , population size , loudness attenuation coefficient , rate enhancement coefficient , and minimum loudness , the minimum and maximum sound wave frequency , , the minimum and maximum bat flight speed , . In addition, in order to ensure the stability of the data, before the algorithm starts to run, both the training set and the test set data are normalized before the algorithm starts. After the initialization settings in this section, the following describes the specific process of the empirical research in detail.
4.3. The Compared Model Setting and the Steps of Forecasting Model
The innovation of the SVR forecasting model in this paper is that the bat algorithm parameters of the radial basis sum function are invoked to optimize the bat algorithm. In order to verify the accuracy of the SVR model after the bat algorithm optimization search when forecasting stock index prices, the polynomial kernel function SVR and the sigmoid kernel function SVR with default parameters are selected as the control group in this paper. The full sample interval used by these two types of comparison models are the same as those defined in the previous paper for the BA-SVR hybrid model, and the same last 20 days, 60 days and 250 days of data as the short-term, mid-term and long-term forecast groups of each index, respectively. The rest of the forecasting steps are the same as the BA-SVR described in the previous section. The difference is that the polynomial kernel function SVR model and the sigmoid kernel function SVR model use default initial parameters.
5. Empirical Research and Result Analysis
5.1. Tests for Panel Smoothness and Cointegration
Since 18 representative stock indices in the Chinese stock market are selected as the sample for this paper, a single time series smoothness test cannot be applied. For the research problem and the selected data, a panel unit root test is chosen to test the smoothness of the adopted data. Since the historical data of the six stock index characteristics used are all strongly balanced panels, and the sample selected for this paper is a long-sided version, i.e., the cross-sectional dimension is smaller than the time dimension. Therefore, the LLC test [
27] is used here. The results are shown in
Table 2, and the results indicate that four of the six stock index characteristics in this paper exhibit unbalanced and two exhibit balanced characteristics. We can also see this result more intuitively from the historical trend chart of these six characteristics (see
Appendix A). In order to match the qualitative requirements of the panel cointegration test, it is necessary to ensure the smoothness of all data presented, so the unit root test is performed again on the first-order differences of all variables, and the results are shown in
Table 3. It can be seen that all variables are smooth after first-order difference, and all six variables are first-order single integer.
To further investigate whether pseudo-regressions occur and to test for the existence of long-run cointegration relationships among all variables. This paper further performs cointegration tests on the six variables. Based on the results of the previous panel unit root test, all variables are first order single integer and cointegration tests are allowed. In this paper, the Westerlund test [
28] is mainly used to test the cointegration of all variables. If, the
p-value of the obtained results is less than 0.01, it indicates that there is a significant long-term cointegration relationship among the variables. The results of the four statistics in the Westerlund test [
28,
29] are shown in
Table 4 below. The results in
Table 4 show that all explanatory variables are significant at the 1% level of significance. There is a cointegration relationship among the six variables, and the possibility of pseudo-regression is excluded.
5.2. Evaluation Indicators for Predictive Effect
Prediction accuracy indicates how well a prediction model predicts the selected variables. Different accuracy measures are used to validate the fitness of a model for a particular data set. Typically, there are several accuracy measures such as mean error (ME), mean absolute error (MAE), mean absolute percentage error (MAPE), mean squared error (MSE) and mean square root error (RMSE). In order to investigate whether the prediction effect of the bat algorithm after improving the parameters of the SVR model is better than that of the same model without optimization, this paper integrates the existing regression prediction evaluation indexes. Three indicators of Root Mean Square Error (RMSE), Mean Absolute Error (MAE) and Mean Absolute Percentage Error (MAPE) are selected as the prediction accuracy indicators to compare and analyze the prediction accuracy of the BA-SVR hybrid prediction model with other control models. This criterion [
17,
30] has been used in previous studies.
where
,
and
denote the predicted value, actual value, and the mean value of the actual value, respectively. According to the above definition, the three-regression goodness-of-fit evaluation indicators are all measuring the deviation between the predicted value of the model and the true value. The smaller these indicators, the better the degree of fitting. Since the algorithm normalizes and denormalizes the data in the model, the main purpose of this paper is to verify that the prediction of the SVR model after the bat algorithm optimization is relatively better than that of the default parameter SVR without optimization. Therefore, the predicted values after normalization are used in the calculation of the prediction values.
5.3. Comparison and Analysis of Short-Term Forecast Results
As mentioned above, the last 20, 60 and 250 days of the selected total sample time for the 18 indexes are used as short, medium and long term forecast groups for empirical testing, respectively. Furthermore, in order to verify that the proposed bat algorithm can optimize the parameters of the support vector regression model to obtain higher prediction accuracy. In this paper, the polynomial kernel function SVR with default parameters and the sigmoid kernel function SVR are selected for comparative analysis with the three evaluation metrics selected in the previous sections.
Table 5 lists the three optimal initial parameters obtained after applying short-term training data andoptimizing them using the bat algorithm.
Table 6 and
Table 7 list the short-term forecast results and comprehensive comparison results obtained under the three models of the 18 stock indexes selected in the previous article.
As can be seen from
Table 5, the bat algorithm seeking optimal SVR parameters is able to minimize the MSE as the fitness function based on the selected training set data of different stock indices and obtain the optimal parameters under different financial data sets. However, it should be clear that the optimal parameters obtained from the BA-SVR hybrid model optimization are based on the optimal fitness function set in the model. Therefore, when comparing the prediction performance of different models with other prediction accuracy evaluation indexes, different results may be obtained due to the different fitness functions. From
Table 5, it can be concluded that the optimal parameter range of the penalty factor obtained by substituting the data of the 18 stock indices selected in this paper into the model ranges from 64.7818 to 97.6447. The absolute value of the optimal parameter range of the insensitive loss factor is between 0.0131 and 2.3154. The optimal range of the width parameter of the radial basis kernel function is between 1.1234 and 4.1270. Overall, the parameters of the 18 stock index short-term training group data are not significantly different after each optimization.
The short-term prediction results of the BA-SVR hybrid model (column 3), which is the main model used in this paper, and the short-term prediction results of the default free-parameter polynomial kernel function SVR model (column 4) and the default free-parameter sigmoid kernel function SVR model (column 5), which are selected as the control models in this paper, are shown in
Table 6 for the models trained on the test set of 18 stock index data, respectively RMSE, MAE and MAPE values. Based on the forecasting results of the 18 stock indices under the three models, it can be seen that, except for the SSE B-share, CSI 500 and SZSE B-index, the forecasting performance of the other 15 stock indices derived from the BA-SVR model forecasts and the three evaluation indicators are the best values in the three models. The two data sets of SSE B-shares and SZSE B-index are more suitable for forecasting by the sigmoid kernel function SVR model. For the CSI 500, the polynomial kernel function SVR model shows better forecasting performance. However, in the overall view of the 18 stock indices, the SVR model after the bat algorithm search outperforms the other two control models with unoptimized free parameters in terms of short-term forecasting performance. Comparing the forecasting performance of the two control models, we can also see that the polynomial kernel function outperforms the sigmoid kernel function for 16 of the 18 indices. The opposite is true for the SZSE B and SSE B indices, where the RMSE and MAE of the sigmoid kernel function SVR model are smaller than those of the BA-SVR model and the polynomial kernel function SVR model.
Table 7 depicts the average results of the forecasting results under the three models for the 18 stock indices. From this table, it can be concluded that all three forecasting performance evaluation metrics, RMSE, MAE and MAPE, reflect that the SVR model after the bat algorithm optimization search exhibits higher forecasting performance improvement in the short term when analyzed in comparison with the two control models.
5.4. Comparison and Analysis of Mid-Term Forecast Results
As described above, the data of the last 60 days of the 18 stock indices in the total sample time selected in this paper are used as the prediction set data in the medium-term forecasting, and the other sample data are used as the training group.
Table 8,
Table 9 and
Table 10 show the three SVR free parameters obtained from the mid-term bat algorithm search, the evaluation of the performance of the 18 stock indices for mid-term forecasting, and the combined evaluation table of the three models, respectively.
The optimal penalty factor ranges from 34.4416 to 97.3081 after the bat algorithm has been used to find the optimum for the medium-term training set data of 18 stock indices. The absolute value of the insensitive loss factor ranges from 0.1761 to 1.5592. The radial basis kernel function bandwidth parameter ranges from 1.4121 to 4.2374. The optimal free parameters obtained from the 18 stock index interim training group data and the bat algorithm after the optimization search of the interim data were brought into the SVR model, respectively. Compared with the two control models Polynomial kernel-SVR and Sigmoid kernel-SVR without the optimized free parameters, the results are shown in
Table 9.
In terms of RMSE, MAE and MAPE values, similar to the short-term results, the three evaluation indicators generally have the same evaluation when comparing different models, and there are fewer cases of inconsistent results for the three indicators. For the medium-term forecasts of the selected 18 stock indices, the BA-SVR forecasting performance remains optimal in the results of 11 stock indices, having the smallest RMSE, MAE and MAPE. The BA-SVR does not obtain the optimal performance in the other seven groups of stock indices. The Sigmoid kernel function SVR model has the best forecasting performance among the three models for the medium-term forecasts of the SSE B-shares, SSE 50 and SZSE B-index. As for CSI 500, SZSI, SZSE Composite Index and SZSE A Index, the Polynomial kernel function SVR model has slightly higher forecasting performance than the BA-SVR model, but the difference is not significant. The medium-term forecasting performance of BA-SVR is lower than the short-term forecasting performance of BA-SVR except for SZSE B. The medium-term values of RMSE, MAE and MAPE are higher than the short-term values. In contrast to the BA-SVR model, the Polynomial kernel function SVR and Sigmoid kernel function SVR models with default free parameters have improved in some samples, such as the SSE Composite Index and SSE A shares, in terms of medium-term forecasting performance.
Combining the 18 stock indices, the BA-SVR model is still able to show better forecasting performance in medium-term forecasting when compared and contrasted with the two SVR models without the bat algorithm’s optimality-seeking parameters.
Table 10 averages the three forecasting evaluation metrics for the 18 stock indices forecasting performance. The average of the medium-term forecast performance of RMSE, MAE and MAPE of the three models in
Table 10 also shows that the BA-SVR model still has an advantage when compared with the SVR model with unseeking parameters in a cross-sectional manner. The medium-term average of all three evaluation metrics of BA-SVR is the smallest, followed by the Polynomial kernel function SVR. The Sigmoid kernel function SVR value is the largest. However, when comparing with the short-term prediction performance of the same model, it can also be found that the BA-SVR model’s medium-term prediction is mostly inferior to its short-term prediction, while the Polynomial kernel function support vector regression and Sigmoid kernel function support vector regression without the free parameters optimized by the bat algorithm do not show this characteristic obviously.
5.5. Comparison and Analysis of Long-Term Forecast Results
In this paper, we analyze the long-term forecasting performance of the three models for 18 stock indices using the data of the last 250 trading days within the selected full sample period as the forecast set for the long-term forecasting performance empirical evidence and the other data within the sample period as the training set.
Table 11,
Table 12 and
Table 13 show the SVR parameters obtained from the long-term bat algorithm search, the evaluation metrics of the long-term forecasting performance of the three models, and the comparison of the mean values of the evaluation metrics, respectively. From
Table 11, the optimal penalty factors for the 18 stock indices obtained by the bat algorithm and the SVR model mixed with the free parameter search optimization range from 41.5925 to 98.7044. The absolute values of the insensitive loss factors range from 0.0941 to 1.4540. The optimal range of the bandwidth parameter of the Gaussian radial basis kernel function is between 0.7957 and 2.6268. Bringing the free parameters obtained from the long-term bat algorithm search in
Table 11 into the SVR model, we can obtain, in
Table 12, the long-term forecasting results for the 18 stock indices for 250 trading days and the long-term forecasting effects of the two control models.
According to the results in
Table 9, it can be seen that for the 18 stock indices, the long-term forecasting performance of the Sigmoid kernel function SVR model is the worst among the three models, implying that the RMSE, MAE and MAPE values are larger compared to the other two models in the same group. Experimental results for 13 of the 18 stock indices show that the BA-SVR model has higher forecasting performance than the polynomial kernel function SVR model. The values of RMSE, MAE and MAPE for the polynomial kernel function SVR model for the SSE Composite Index, SSE A shares and CSI 500 data are smaller than those of the BA-SVR model in the same group, indicating that the polynomial kernel function SVR model has better forecasting performance in these groups. The RMSE and MAE of the polynomial kernel function SVR model under the SSE B-share data are smaller than BA-SVR, but the MAPE is larger than BA-SVR. The RMSE of the polynomial kernel function SVR model under the SSE 380 data is smaller than BA-SVR, but the MAE and MAPE indicators are greater than the BA-SVR model.
While the BA-SVR model is not the best performing model in terms of forecasting in individual groups, the difference between the predicted RMSE, MAE and MAPE values of the BA-SVR model and the better polynomial kernel function SVR model is not significant in these groups. This difference is much smaller than the difference between these two models and the SVR model of the Sigmoid kernel function. In addition, the combined analysis of the 18 stock indices under the three forecasting models for forecasting performance evaluation model, and the results are shown in
Table 13. On average, the long-term forecasting results show that BA-SVR has a better forecasting performance improvement compared with the polynomial kernel function SVR model with default free parameters and the Sigmoid kernel function SVR model.
Further, the changes in the BA-SVR model’s prediction performance in the short, medium and long term are then compared together. According to
Table 6,
Table 9 and
Table 12, the forecasting performance of the BA-SVR model decreases to different degrees between different groups. Taking the SSE Composite Index as an example, the MAPE of the short-term BA-SVR model is 0.0329, the MAPE of the medium-term BA-SVR model is 0.0609, and the MAPE of the long-term BA-SVR model is 0.1756. The MAPE shows a gradual increase, which corresponds to the decrease in forecasting performance. This quality also matches with the average prediction performance of the BA-SVR model in the second column of
Table 7,
Table 10 and
Table 13. Unlike the polynomial kernel function SVR model and the Sigmoid kernel function SVR model, this trait does not appear significantly, and for both control models, in some groups, there is a higher long-term prediction performance than the short-term and medium-term. Here is a comprehensive comparison of the changes in the performance of the BA-SVR model in the short, medium and long term. According to
Table 6,
Table 9 and
Table 12, the predictive performance of BA-SVR models in different groups has decreased to varying degrees. Take the above stock index as an example, the MAPE of the short-term BA-SVR model is 0.0329, the MAPE of the medium-term BA-SVR model is 0.0609, and the MAPE of the long-term BA-SVR model is 0.1756. It can be clearly found that MAPE is showing a gradual upward trend, which corresponds to the decrease in prediction performance. Coincidentally, this characteristic also matches the average predicted performance of the BA-SVR model in the second column of
Table 7,
Table 10 and
Table 13. In contrast, the polynomial kernel function SVR model and the Sigmoid kernel function SVR model do not have this characteristic, and the long-term prediction performance of these two comparison models is higher than that of the short-term and medium-term in some groups.
For the empirical investigation of the forecasting ability of the bat algorithm optimized SVR model constructed in this paper in different periods, based on the 18 mainland China stock indices and the full sample interval selected in this paper, the following conclusions can be drawn. The BA-SVR model has better stock index closing price forecasting performance, and the results are still roughly robust compared with the polynomial kernel function SVR model without optimized free parameters and the Sigmoid kernel function SVR model without optimized free parameters. The results are still roughly robust compared to the polynomial kernel SVR model without optimized free parameters and the Sigmoid kernel SVR model without optimized free parameters. However, the SVR model with free parameters optimized by the bat algorithm has higher predictive power for short-term stock index closing prices compared to the medium-term and long-term, while the two control models do not significantly exhibit this property.
6. Robustness Test
This chapter aims to test the robustness of the BA-SVR model from different angles. Referring to the stationarity test and cointegration test of each time series variable in the previous chapter, there is a cointegration relationship between each variable. However, to ensure the accuracy of the data, we take the stationary data after the first-order difference of the stock index characteristics as the input and output variables of the new prediction model, and we re-estimate the optimized three SVR model parameters. After changing the input variables and output variables into stable first-order differential stock index characteristic data, we use bat algorithm to optimize the SVR model. The three parameters optimized by bat algorithm of 18 stock indexes in the short, medium and long term are shown in
Table 14.
Table 14 shows that the optimal parameter range of the penalty factor obtained is between 34.6240 and 98.6366. The absolute value of the optimal parameter range of the intensive loss factor is between 0.0870 and 2.9864. The optimal range of the width parameter of the radial basis kernel function is between 0.9862 and 7.7466.
In addition, based on the existing literature, we introduce ANN model and random forest model with good prediction performance as the control model, and use the stationary time series data for training and prediction from the short-term, mid-term and long-term perspectives. The short-term, mid-term and long-term prediction performance results of BA-SVR model, ANN model and RF model are listed in
Table 15,
Table 16 and
Table 17, respectively.
Following literature [
31,
32,
33], we also conduct Diebold-Mariano test on the prediction residuals of the three models to prove the effectiveness of BA-SVR model in stock index prediction. When two time series have the same time length and the data meet the stationarity condition, DM detection is often used to detect whether one model is better than the other in terms of statistics. The calculation formula of DM statistics is as follows:
where
d indicates the difference between the prediction residual sequences of two models.
indicates the mean value of time series
d.
indicates the standard error of time series data
d. We mark the results of DM test by * and °, which indicate the comparison of BA-SVR model with RF model and ANN model, respectively.
It can be seen from
Table 15 that the short-term prediction performance of BA-SVR model of 8 of the 18 stock indexes is significantly better than that of random forest model. The short-term prediction performance of BA-SVR model of 7 stock indexes is significantly better than ANN model. The short-term prediction performance of BA-SVR of only one stock index (SSE A shares) is significantly worse than that of ANN model. Therefore, in general, BA-SVR has certain advantages over the commonly used ANN model and RF model in the short-term prediction performance of stock index.
Note:
Table 15,
Table 16 and
Table 17 presents the out of sample performance of BA-SVR and the benchmark Artificial Neural Network model and Random Forest model with the testing sample. We list three evaluation indicators, including RMSE, MAE and MAPE. *, **, *** indicate the prediction performance of BA-SVR model and RF model by DM test under the significance of
,
and
, respectively. °, °°, °°° indicate the prediction performance of BA-SVR model and ANN model by DM test under the significance of
,
and
, respectively.
In terms of medium-term prediction performance, 17 of the 18 sample stock indexes selected in this paper show that the prediction performance of BA-SVR model is better than that of RF model. Among the 18 stock indexes, 13 results show that the prediction performance of BA-SVR model is better than ANN model. Results in
Table 15 and
Table 16 show that compared with short-term prediction, BA-SVR model performs better than ANN model and RF model in predicting mid-term stock index price.
Table 17 shows the long-term prediction effects of the three models on stock index prices. Among the 18 stock indexes, results of 11 stock indexes show that the long-term prediction effect of BA-SVR model is better than that of RF model, and the results of 2 stock indexes show that the long-term prediction effect of BA-SVR model is significantly worse than that of RF model. Only one stock index shows that the prediction performance of BA-SVR model is better than ANN model, and the results of 8 stock indexes show that the prediction performance of BA-SVR model is significantly worse than ANN model. Nevertheless, generally speaking, BA-SVR model still has good prediction effect in short-term, medium-term and long-term stock index prediction. At the same time, bat algorithm may be more widely used in parameter optimization of various prediction models in the future.
7. Conclusions
In this paper, the bat algorithm in the swarm optimization algorithm is applied to optimize the free parameters of the Gaussian radial basis kernel function support vector regression model, and then the BA-SVR hybrid model is constructed. In this paper, the constructed BA-SVR hybrid model is applied to the closing price forecasting of 18 stock indices in the capital market of mainland China, and compares it with the forecast results of the control model in the short, medium and long term, and the following conclusions are obtained.
(1) The proposed BA-SVR model has better forecasting performance in the short, medium and long term.
(2) After comparing with the polynomial kernel function support vector regression and the Sigmoid kernel function SVR model without optimization of free parameters, the prediction performance of the BA-SVR model is still robust in different periods.
(3) The BA-SVR model has the best forecasting performance in the short-term, followed by the mid-term, and the lowest forecasting ability in the long term, while the other two control models have no such significant characteristics.
Overall, the BA-SVR model has certain advantages in the application of forecasting stock indices in financial markets, and the optimization of the bat algorithm is further applied to stock index forecasting, which also provides a new perspective on the application of the bat algorithm in finance.
In future research, more attention will be given to the prediction and optimization of this hybrid model in other financial and management problems, or to the setting and selection of initial free parameters by metaheuristic algorithms in other machine learning models, and to the implementation of these methods in other optimization problems.