1. Introduction
The stability of small-scale agricultural products’ prices is of great significance to the healthy development of the grain market and the national economy. An in-depth understanding of the trends of changes in the prices of small-scale agricultural products plays a guiding role in stabilizing the prices of agricultural products. However, the production of small-scale agricultural products is subject to factors such as planting area and abnormal weather, and their prices often have the characteristics of sharp fluctuations in a short period of time. Take the most representative small-scale agricultural product as an example: the price of Chinese garlic has been extremely unstable in recent years. Affected by a combination of supply and demand, policies, natural disasters, fertilizer prices, oil prices, GDP, public opinion, speculation, and other factors [
1], garlic prices in China have experienced many abnormal and precipitous fluctuations. This phenomenon has disrupted normal market expectations [
2], affected the interests of industry stakeholders, and even led to market disorder and social unrest [
3]. Therefore, with the background of frequent and violent price fluctuations of small-scale agricultural products, it is of great significance to deeply understand the fluctuation trends of small-scale agricultural product prices and explore scientific methods to predict the market prices of them. This could help relevant practitioners make correct judgments and scientific decisions to avoid market risks and promote the healthy development of the small-scale agricultural product industry. This paper takes garlic, the most representative small-scale agricultural product of China, as an example, to explore a price-prediction method for small-scale agricultural products.
The prices of small-scale agricultural products such as garlic are characterized by high volatility, strong nonlinearity, and nonstationarity, and also exhibit some seasonal and cyclical fluctuations [
4]. These pose a great challenge to the garlic price prediction task. The prices are influenced by a variety of factors. However, some influencing factors are difficult to measure quantitatively. It is difficult to put all factors in when building a forecasting model. Since these factors are concentrated in the historical price series, it is beneficial to fully explore the volatility characteristics of historical prices to improve the accuracy of the forecasting model. The key to improving prediction performance is to fully exploit the complex regular information in the price series.
Some classical econometric model studies in the past have helped to achieve short-term forecasts of agricultural prices, such as ARIMA, GARCH, and other linear models [
5,
6,
7,
8]. However, such models ignore the non-stationary and non-linear characteristics of agricultural price series in modeling and have difficulty capturing the long-term dependence in the series. Moreover, it has been pointed out in the literature that when garlic prices suddenly and dramatically fluctuate, there is still a large gap between the predicted results of the econometric model and the actual values [
9].
Machine-learning methods with flexible operational design and powerful self-learning capabilities have been introduced to overcome the shortcomings of econometric models in price forecasting tasks. Such models were found to be effective in learning nonlinear features in time series and improving forecasting performance. They have been shown to be robust in various nonlinear modeling tasks, such as classification and feature extraction [
10,
11,
12]. Among the machine-learning models, artificial neural networks (ANNs) are powerful for predicting nonlinear data [
13]. However, due to its shallow structure, the ANN cannot store network states and can hardly deal with the long-term dependence of time series.
Based on this, deep-learning methods have been developed and applied in the field of agricultural product price prediction [
14]. Mainstream deep-learning models include the CNN, RNN, and other models [
15]. For the time series prediction problem, the recurrent neural network (RNN) is a common and effective method. Still, it often suffers from gradient disappearance or gradient explosion when dealing with long series. Long short-term memory (LSTM) and gated recurrent unit (GRU), which are the variants of the RNN, are starting to emerge. LSTM, proposed by Hochreiter S. [
16], and GRU, proposed by Cho [
17], address the structural defects of the RNN and can effectively deal with the long short-term dependence and non-linear characteristics of sequences.
In addition, a great deal of research has proved that the linear and nonlinear patterns of price series cannot be captured simultaneously by a single model alone, and agricultural products prices are no exception [
18,
19,
20]. Therefore, combined model methods have been introduced to the agricultural products price prediction task, which combine the advantages of different prediction models by integrating them to capture the linear and nonlinear patterns. Combined models can provide enhanced interpretability while improving the accuracy of price predictions of agricultural products.
Inspired by the above studies, for more accurate prediction of garlic prices, we combined the advantages of deep-learning models and econometric models and propose combined prediction models. The daily garlic-price series is the research object. Since garlic-price series, like those of other financial products, are detected to have heteroskedasticity, we first developed GARCH-family models based on the conditional heteroskedasticity of garlic prices. The GARCH-family models are first used to capture the information of different volatility features, such as volatility aggregation and the leverage effect of garlic-price series. Then, the above volatility feature information is integrated into the bottom layer of the LSTM model, and the self-learning ability of the LSTM model is used to deal with the complex correlations between price information and volatility feature information in the input series to improve the prediction of garlic-price series.
The main contributions of this paper are as follows: (1) This paper proposes a garlic-price-prediction method based on combined model that overcomes the limitations of single-model prediction by incorporating statistical features into deep-learning models. (2) We compared the performances of multiple combined models obtained by merging different GARCH-family models with LSTM, and we present the optimal combined model for garlic price prediction. (3) We compared the LSTM–GARCH combined models with multiple benchmark models and found that LSTM–GARCH combined models are more suitable for the current garlic dataset. It improves on the accuracy of existing garlic price prediction models and provides a new means of garlic price prediction.
The sections of this paper are organized as follows. In
Section 2, an overview of related work is introduced. In
Section 3, the dataset and details of the prediction models proposed in this paper are described. In
Section 4, the experimental procedure and analysis of results of this work are illustrated. Finally in
Section 5, the conclusion of the paper is presented.
4. Experimental Procedure and Analysis of Results
In this section, we present large-scale experiments using the proposed LSTM–GARCH-family combined models and three time-series data-prediction benchmark models on a real dataset. In
Section 4.1, we first give the experimental setup to introduce the specific implementation of our experiments. In
Section 4.2, we compare and analyze the performances and advantages of LSTM–GARCH and three benchmark models for time series data forecasting in a garlic price forecasting task. In
Section 4.3, we present the application of the proposed optimal combined model to the garlic price prediction task.
4.1. Experimental Setup
In the experimental setup, we first introduce the dataset used in our experiments, then give the performance evaluation metrics, and finally describe our experimental design.
4.1.1. Dataset
To improve the generalization ability of the model, the garlic prices from 1 January 2004 to 20 September 2019 were selected as the training data for the model, and the garlic prices from 21 September 2019 to 14 May 2021 were selected as the testing data of the model. In order to reflect the degree of volatility of the garlic-price series and enhance the stability of the series, the first-order difference form of the logarithm of garlic price was constructed, which is
=log(
)-log(
) (return). We show the time series plot of garlic price return in
Figure 4. Subsequently, the ADF unit root test was performed on the series. From
Table 3, it is shown that the first-order difference series is smooth. The ARCH Lagrange Multiplier (ARCH-LM) test showed that garlic-price series have a high-order ARCH effect. Therefore, GARCH-family models can be established.
4.1.2. Evaluation Metrics
The following three evaluation metrics were used to measure the predictive ability of the model: mean absolute error (MAE), root mean-square error (RMSE), and mean absolute percentage error (MAPE). Lower values of the evaluation metrics indicate better performance of the prediction model. The three evaluation metrics were calculated as follows.
where
denotes the predicted value of garlic price,
denotes the actual price of garlic, and
N denotes the total number of predicted samples.
4.1.3. The Structures and Hyperparameters of LSTM–GARCH-Family Combined Models
To illustrate the effectiveness and necessity of the combined models, we first used the GARCH-family models (GARCH, EGARCH, PGARCH) and the LSTM alone for garlic price prediction separately. Second, to find the optimal combined model for garlic price prediction, we combined the LSTM model with the GARCH-family models, and the structures of the combined model are shown in
Section 3.3.3. Finally, we compared the performances of the above prediction models to obtain the optimal garlic price prediction model. It summarizes the input layer variables of the single models and the combined models in
Table 4. The GARCH terms, EGARCH terms, and PGARCH terms denote the corresponding parameters extracted from the GARCH-family models which were used as inputs to the combined models. In addition, the explanatory variable in
Table 4 is the daily price series of garlic, and the symbol “
√” denotes input variables in the models.
The choice of parameters is crucial to the prediction performance of the LSTM–GARCH-family combined models. The parameters of the LSTM–GARCH models consisted of two main components. The hyperparameters were used in the LSTM, and the statistical parameters were used to fit the economic model GARCH. To obtain the optimal prediction performances of the models, we iteratively adjusted the parameters of the model. The following was the parameter tuning process for the two types of models used in our experiments.
Hyperparameter settings in LSTM
For deep-learning models, prediction performance is highly dependent on the choice of hyperparameters. Since the hyperparameter space is large and cannot be fully traversed, we used empirical tuning to get the hyperparameters with good performances for the selected dataset. The essential hyperparameters, such as learning rate, batch size, sliding window size, and the number of LSTM neurons, significantly influenced the model’s performance when building the model. For the hyperparameters selected for LSTM, we used MSE as the loss function. In addition, Adam was used as an optimizer, which combines the advantages of AdaGrad and RMSProp, including fast convergence and small memory requirements [
48].
For the learning rate setting, due to the learning rate being set to 0.001, the model converged faster and the accuracy was higher. We set the learning rate to 0.001. The computational time of the model was about 219.4s.
For the values of batches and windows hyperparameters, we set the initial batches to
and windows to
. Next, we performed combined optimization of batches and windows.
Figure 5 shows the results of the corresponding hyperparameter configurations; the final values of batches and windows were set to 40 and 50. In addition, we use
Figure 6a to show the performance of LSTM with varying window values when the initial batch value is 40. We use
Figure 6b to show the performance of LSTM with varying batch values when the initial window’s value is 50.
To select the number of neurons, we first chose from and then fine-tuned them in the appropriate interval to achieve the ideal state. Finally, 20 neurons were selected for the first LSTM layer and ten neurons for the second LSTM layer.
The LSTM prediction model consisted of three basic modules: the input layer, the hidden layer, and the output layer. The key hyperparameters were set as shown in the hyperparameter settings section. In the LSTM model, the numbers of neurons in the two LSTM layers were 20 or 10, and the numbers of hidden nodes in the two fully connected layers were 5 and 1, respectively. A small batch of data with 40 points was selected for iterative training in this experiment. To avoid overfitting the data, dropout regularization was used, and the probability was set to 0.1 [
49]. The garlic price of the last 50 days was selected to predict the garlic price of the next day. Meanwhile, Adam was chosen and a learning rate of 0.001 was set to control the learning speed of the network. After 100 epochs, the model loss stopped decreasing and reached a state of convergence.
GARCH-family single model prediction. In the part of parameter-setting discussion, we introduced how to choose the parameters of the GARCH-family models. Based on AIC, SC, and HQ criteria, we chose the GARCH (1, 1, 0), EGARCH (1, 1, 1), and PGARCH (1, 1, 1) models under the GED distribution. We could predict the garlic price through the established models. Meanwhile, the characteristic term coefficients of the GARCH-family models were derived.
Single-combination model prediction. GARCH-family models were combined with an LSTM model to obtain LSTM–GARCH (LSTM-G), LSTM-EGARCH (LSTM-E), and LSTM-PGARCH (LSTM-P). The hyperparameters were the same as in the LSTM model, except that the number of LSTM-layer neurons changed slightly with the input dimensions. We tested the accuracy of different numbers of hidden nodes through many experiments to obtain the prediction results with the highest accuracy. According to the rules for selecting LSTM layer neurons already introduced in the discussion of parameter settings, we set the numbers of neurons in the two LSTM layers of the single combined models to 25 and 10, and the numbers of nodes in the fully connected layers to 5 and 1. Similarly, single-combination models reach eda state of convergence after 100 epochs.
Dual-model prediction. The two GARCH-family models were combined with the LSTM model to obtain the dual-combination models LSTM-GE, LSTM-GP, and LSTM-EP. We adjusted hyperparameters such as the number of neurons in the LSTM layer of the model to construct a well-performing garlic prediction model. The final numbers of neurons in the LSTM layers were chosen to be 30 and 10, respectively; and the numbers of nodes in the fully connected layers were 5 and 1, respectively.
Triple-combination model prediction. The three GARCH-family models were combined with the LSTM model to obtain the triple combination model LSTM-GEP. The final numbers of neurons in the LSTM layers were chosen to be 30 and 15, respectively; and the numbers of nodes in the fully connected layer were 5 and 1, respectively.
4.1.4. Benchmark Models
To further demonstrate the effectiveness and superiority of our proposed model, we selected three prediction models and compared them with our proposed model. First, we selected CNN and GRU models and combined them with GARCH-family models to obtain GRU–GARCH-family models and CNN–GARCH-family models as benchmark models. In addition, we also selected the attention–LSTM model, which has an excellent performance in current time series data prediction, to compare with our proposed optimal LSTM–GARCH family model.
GRU has a similar structure to the LSTM and can be regarded as a simple variant of LSTM. Both LSTM and GRU preserve important features through various gate structures and thus ensure they will not be lost even after a long period. GRU improves the complex cell structure of LSTM by merging the input and forgetting gates and merging the cell states and hidden states of LSTM. In the GRU model, the reset gate is used to determine how much past information to forget, and the update gate is used to decide how much input and previous output to pass to the next cell, so the GRU cell can decide how much information to copy from the past to reduce the risk of gradient disappearance. It has often been applied to price prediction in recent years [
50]. The performances of LSTM and GRU are slightly different on different data sets. To further verify the superiority of our proposed model, we combined the GRU with the GARCH-family models to obtain the GRU–GARCH-family combined models. The GRU and GRU–GARCH-family models were selected as the benchmark models. We built a stacked GRU model similar to the LSTM model, i.e., with two GRU layers and two fully connected layers. With the hyperparameters adjusted to the optimal case, the optimal LSTM–GARCH-family combined models we obtained in the above experiments were compared with the GRU and GRU–GARCH-family combined models (GRU-G, GRU-GP, and GRU-GEP).
A convolutional neural network (CNN) is suitable for spatial feature extraction and is widely used in the field of image recognition. It mainly includes an input layer, a convolutional layer, a pooling layer, a fully connected layer, and an output layer. We tried to use the CNN model for garlic price prediction work. In this work, the CNN model took garlic price and GARCH-family-related parameters as input data and extracted the correlation between each index and garlic price through convolution operation; then compressed the amount of data and parameters through pooling to avoid overfitting and reduce the complexity of the model; then transformed the data form through flattening layer; and finally fine-tunesd and output the prediction results using a fully connected layer. We combined the CNN with the GARCH-family models to get CNN–GARCH-family combined models to test the ability of the CNN to extract garlic-price series features. We compared the optimal LSTM–GARCH-family models with the combined CNN–GARCH-family models (CNN-G, CNN-GP, and CNN-GEP). We set the CNN to have two convolutional layers, a max pooling layer, a dropout layer, and a fully connected layer ui a grid search method. For the first two convolutional layers, the filter size was 1 and the numbers of filters were selected as 32 and 16, respectively. The filter size for the max pooling layer was 2. In addition, dropout regularization was set to 0.1 to prevent overfitting.
Attention improves the model’s ability to select temporal correlations. The attention mechanism is a resource allocation mechanism that mimics human attention, and it can change the level of attention to input information by assigning reasonable weights to different features. Attention–LSTM models are often used in the field of price prediction. Many extant pieces of literature point out that LSTM incorporating the attention mechanism has an advantage over LSTM models in time-series data prediction. Therefore, we selected an attention–LSTM as a benchmark model. For a fair comparison, the attention–LSTM model had two LSTM layers, and the hyperparameters of the LSTM layers were the same as those of the solo LSTM. In addition, we added the attention layer after the two LSTM layers.
4.2. Analysis of Results
In the analysis of results, we first analyze the performance of our proposed LSTM–GARCH-family combined models and then compare the optimal combined model with the benchmark models. In this paper, we use the three evaluation metrics, MAE, RMSE, and MAPE, to evaluate the performances of the garlic price prediction models; smaller values indicate better prediction performance.
4.2.1. Results of LSTM–GARCH-Family Models
The results of the LSTM–GARCH family combined models are shown in
Table 6. From the experimental results, it can be seen that the prediction performance of the LSTM model is significantly better than those of the GARCH-family models alone. The values of MAE, RMSE, and MAPE for the LSTM model were 12.87%, 16.73%, and 5.21%, which are significantly lower than those of the GARCH, EGARCH, and PGARCH models. Compared with the GARCH-family models, the LSTM model can learn the temporal patterns and nonlinear characteristics of time series data more effectively due to its long memory.
Figure 7a shows the prediction results of the LSTM model in the test set.
In the combined models, the prediction performance was significantly improved over the LSTM model. Due to the addition of a GARCH-family model, the single combined models captured the information of economic characteristics in the garlic-price series. The experimental results show that LSTM-G had the best prediction performance among the single combined models. By adding GARCH coefficients to the input layer of LSTM, the LSTM-G model captured the information of economic characteristics, such as volatility aggregation and volatility persistence of garlic-price series. Thus, the model prediction performance was significantly improved; and its values of MAE, RMSE, and MAPE were reduced to 11.88%, 16.00%, and 4.87%. Similarly, LSTM-E and LSTM-P, by the addition EGARCH coefficients and PGARCH coefficients to the input layer of LSTM, respectively, enable the models to capture the leverage effect of garlic-price series and enhance the flexibility of asymmetric fluctuations of the time series. GARCH coefficients had the highest contribution to the improvement of model performance among the single combined models.
Figure 7b shows the prediction results of the LSTM-G combination model in the test set.
Compared to the single models and single-combination models, it was found that the dual-combination models have better prediction performances. The LSTM-GP combined model had the best prediction performance. The combination of GARCH coefficients and PGARCH coefficients had the highest contribution to the improvement of model performance in the dual-combination models. The LSTM-GP model had the smallest MAE, RMSE and MAPE values of 11.44%, 15.66%, and 4.56%, respectively.
Figure 7c shows the prediction results of the LSTM-GP model in the test set.
The prediction performance of the LSTM-GEP combined model merged with three GARCH-family models did not further improve on the dual-combination models. Further additions did not provvide better prediction performance.
Figure 7d shows the prediction results of the LSTM-GEP combination model in the test set.
From the overall prediction results, it can be seen that the deep-learning model outperformed the econometric models and the combined models generally performed better than the single models. The combined models use the GARCH-family models to capture the fluctuation characteristic information of the garlic-price series, which effectively expands the price series information, thereby enabling the LSTM model to learn more effective information. Therefore, the prediction performances of combined models were effectively improved.
Figure 8 shows the percentage reductions of MAE, RMSE, and MAPE of the better performing combined models compared with the LSTM model, and it was found that the LSTM-GP combined model had the most significant reduction of evaluation metrics, indicating that the LSTM-GP combined model has the best prediction performance.
4.2.2. Results of Comparison with the Benchmark Models
The results of the prediction performance comparison between the proposed optimal combined model LSTM-GP and the three sets of benchmark models are shown in
Figure 9a–c. It can be seen from the figures that the prediction performance of LSTM-GP was better than that of the GRU–GARCH combined models, the CNN–GARCH-family combined models, and the LSTM model with an attention mechanism. Below we analyze the reasons in detail.
First, we compare and analyze the performances of the models obtained by combining LSTM, GRU, and CNN with GARCH-family models. From
Figure 9a,b, we found that all three types of deep-learning models combined with GARCH-family models improved the prediction performances more than single deep-learning models. The results of the three types of combined models, LSTM–GARCH, GRU-GARCH, and CNN-GARCH, proved that combining deep-learning models with GARCH-family models can improve the prediction performance. The reason is that the GARCH-family models expand the historical price information by calculating the price volatility at each time node and mining the price volatility features at each time node, which enables the deep-learning models to capture feature information other than price and effectively improve the prediction performances of the models. Among them, the addition of GARCH and PGARCH models contributed the most to improving performance.
Second, we compare and analyze the extraction abilities of three deep-learning models, LSTM, GRU, and CNN, for garlic price sequence features. From
Figure 9a,b, it can be seen that among the various types of single and combined models, the LSTM-GP model produced the lowest MAE, RMSE, and MAPE metrics, which proves that LSTM has the best extraction ability for garlic-price series features. We briefly analyzed the reasons in terms of the three types of model structures. Although the CNN can capture the spatial structure of data, it does not have a long-term memory function and lacks consideration of the correlation of time-series data. Hence, its prediction performance is inferior to those of LSTM and GRU. Compared with the LSTM model, although the GRU improves computational efficiency by simplifying the gate structure, GRU has a slightly inferior performance to LSTM. The LSTM-GP model has the best performance and outperformed the GRU-GP and CNN-GP models.
Finally, to verify the effectiveness of the LSTM-GP model, we compared it with the attention–LSTM model, which shows a better current temporal prediction effect.
Figure 9c shows that the LSTM model with the attention mechanism has better prediction performance than the LSTM model alone. The reason is that by adding the attention mechanism, the LSTM model can take into account the importance of different hidden states and focus more attention on the relatively essential states. Therefore, the model can better capture the sequence’s long-term dependencies. Compared to the LSTM model with the attention mechanism, the LSTM-GP model, by simultaneously capturing characteristic information such as volatility aggregation and temporal correlation of garlic-price series, captures more effective information at each time node. For this reason, our proposed combined LSTM-GP model produced lower values for the three evaluation metrics and better performance in garlic price prediction.
4.3. Price Prediction Analysis
According to the above research on garlic-price-prediction methods, the combined LSTM-GP model has the highest prediction accuracy. To further verify the effectiveness of the model, we predicted garlic prices for a total of 31 days from 15 May 2021 to 14 June 2021, by using LSTM-GP, and analyzed the prediction performance. A comparison of the predicted results with the actual prices is shown in
Figure 10; and MAE, RMSE, and MAPE of the models are shown in
Figure 11. MAE, RMSE, and MAPE were 0.1143, 0.1400, and 4.40%, which are 16.93%, 17.93%, and 17.47% lower than those of the LSTM model. From
Figure 10, we can see that the predicted values of the combined LSTM-GP model are closer to the actual prices than those of LSTM. This also confirms that the price series features extracted by the GARCH-family models help to improve the prediction performance of the model. Through empirical analysis, it can be concluded that the model is effectively and stably applicable to the short-term prediction of garlic prices and has a certain degree of interpretability to support the prediction of garlic prices.
5. Conclusions
Aiming at the characteristics of high volatility, strong nonlinearity, and nonsmoothness of garlic daily price series, this paper proposed a method combining a deep-learning model and econometric model to construct a garlic price prediction model based on a GARCH-family model and an LSTM model. The volatility characteristics of garlic-price series were extracted by the GARCH-family models, and then the parameters obtained from the GARCH-family models containing volatility characteristics information and price series were added to the LSTM model input layers. The volatility characteristics of the garlic-price series were fully learned by using the self-learning ability and long-time memory of the LSTM model. It has the respective advantages of the two types of models, thereby improving the model’s prediction performance. Large-scale experiments based on real data led to the following conclusions.
(1) Among the single models, the LSTM model performs significantly better than the GARCH-family models. By using its long memory property to effectively learn the temporal patterns of time series, LSTM can deal with the complex nonlinear relationships in garlic-price series and overcome the shortcoming of low accuracy in traditional prediction models.
(2) The prediction performances of the combined models were generally better than those of the single model. The combined models of the LSTM and GARCH family introduce the statistical features of garlic price data into the deep-learning model and reasonably exploit the linear and nonlinear information in the price data. The combined models outperformed the single models in the evaluation indexes of mean absolute error, root mean-square error, and mean absolute percentage error.
(3) The LSTM-GP combined model, which incorporates GARCH, PGARCH, and LSTM models, had the best performance of all models. The empirical analysis concluded that the model is effectively applicable to the short-term prediction of garlic prices and has a certain degree of interpretability, which can provide support for garlic price prediction.
In light of the results obtained, we have proposed a combined model that is applicable to garlic price prediction called LSTM–GARCH. The model proposed in this paper, which was studied from a time series perspective, solves the problems of low prediction accuracy of the traditional single model and poor model interpretability of existing price prediction models. It can effectively achieve the short-term prediction of garlic prices. The accurate prediction of garlic prices can help people related to the garlic industry chain to make correct judgments and scientific decisions, which is conducive to avoiding market risks and can play a guiding role in stabilizing the market for this small agricultural commodity.
Currently, the combined model we have constructed has not been put into use. Alfonso et al. [
51] proposed a broad set of intelligent agents that achieve cryptocurrency prediction and can be used for actual trading. Inspired by this, we are considering further completing the garlic price prediction system in the garlic industry chain big data platform we developed. Second, it is worth considering that garlic, as an important small agricultural product, is subject to multiple uncertainties, such as supply and demand, speculative behavior, and public opinion. This poses a specific challenge to garlic price prediction. In the future, we may adopt multi-view learning to integrate garlic-price-influencing factors based on garlic prices and explore the construction of a multi-feature combined model to improve garlic price prediction accuracy further.