Applications of Parameterized Nonlinear Ordinary Differential Equations and Dynamic Systems : An Example of the Taiwan Stock Index

Considering the phenomenon of the mean reversion and the different speeds of stock prices in the bull market and in the bear market, we propose four dynamic models each of which is represented by a parameterized ordinary differential equation in this study. Based on existing studies, the models are in the form of either the logistic growth or the law of Newton’s cooling. We solve the models by dynamic integration and apply them to the daily closing prices of the Taiwan stock index, Taiwan Stock Exchange Capitalization Weighted Stock Index. The empirical study shows that some of the models fit the prices well and the forecasting ability of the best model is acceptable even though the martingale forecasts the prices slightly better. To increase the forecasting ability and to broaden the scope of applications of the dynamic models, we will model the coefficients of the dynamic models in the future. Applying the models to the market without the price limit is also our future work.


Introduction
Stock indices draw a lot of attention in the financial field and modelling stock prices is one of the major topics.Nevertheless, in most existing studies, stock price returns are modelled instead of stock prices themselves.It results from the theory of random walks stated and published in many books and theses.Fama's 1965 article [1] is one of the most commonly known ones.Among massive researches of modelling stock prices, Chen et al. [2] have investigated and modelled the mean reversion of stock prices.They characterized the phenomenon by three dynamic models derived from the concept of Newton's law of cooling.However, the type of the stock movement other than mean reversion should be included in a more reasonable model.Also, the speed of the convergence to the implied equilibrium should be described if we try to increase the accuracy of the model.
From past experiences, the uptrend and downtrend of the stock price, usually during a bull market and a bear market, respectively, move differently.The uptrend usually goes up fast at first due to good news and then slows down gradually as a result of selling pressure, but the downtrend generally drops steeply.The stock price movement and the logistic growth perform very much alike; nevertheless, stock prices fluctuate more dynamically in the real world.Therefore, modelling this phenomenon is the main goal in the study.
We examined a series of the daily closing prices of Taiwan Stock Exchange Capitalization Weighted Stock Index (TAIEX) and treated it as a dynamic system.The only assumption in this study is that the stock prices are related to time.In order to depict the movement with respect to time, we attempt to modify the logistic growth model and bring in the technique of dynamic integration to construct some models.Furthermore, the models describing the mean reversion in the existing study only consist one time related coefficient [2].We include two time-varying coefficients for constructing new models to increase the accuracy.Hence, we will introduce the nonlinear dynamic models in this study.From this point of view, modelling the stock prices may be more reliable.

International Journal of Differential Equations
In Section 2, we provide the literature review of the logistic growth model and dynamic integration.Section 3 is the methodology of how we build the nonlinear dynamic models.Section 4 consists of the empirical study of applying the dynamic models to TAIEX.In Section 5, we make some conclusions from the empirical study and some suggestions for future works.

Literature Review
The logistic growth model was named by the mathematician Verhulst.He solved the logistic equation and called the solution the logistic function [3][4][5] to express the population growth.The logistic model is continuous in time and can be stated by the differential equation: where  is time,  is the growth rate,  is the carrying capacity, and  is the population size.The logistic growth model was first used to describe the population growth in a restricted environment and then extensively applied to all kinds of fields such as Biology, Chemistry, Economics, Demography, and Statistics.
Concerning the topic of macroeconomics, Teräsvirta and Anderson [6] included logistic function to build a smooth transition autoregressive (STAR) model for describing business cycles.Based on their research, González-Rivera [7] applied STGARCH model on stock returns and exchange rates to explore the asymmetric response of conditional variances to positive and negative news.Other than applying logistic function, the nonlinear time series model such as GARCH is applied to explain the nonlinear phenomenon in the behaviors of the stock returns in the existing studies [8,9].Besides, there are neural network models applied to model the stock index [10][11][12].Guresen et al. [10] list a table of existing studies of artificial neural networks and financial time series models.The exponential law of the stock movement is described and analyzed by Gkranas et al. [13] and Zarikas et al. [14].However, applying logistic equation to stock prices directly is absent in existing studies.
As for applying dynamic system and differential equations to stock prices, Chiang-Lin et al. [15] applied "parabola approximation" and "dynamic integration" proposed in [16] to model the Taiwan stock index, TAIEX, and evaluate its derivative by considering the index as a dynamic system.Li et al. [17] also applied the same methods to model German DAX and tried to develop a risk detecting instrument of approaching financial catastrophe.Chen et al. [2] further combined Newton's law of cooling and dynamic integration to explain the phenomenon of mean reversion by modelling TAIEX.On the basis of existing researches, we try to transform the logistic model into some models by considering the stock price, the velocity of the stock price, and the stock return as the subject, respectively.We also solve the equations representing the models by dynamic integration.The details of the dynamic models are in the following section.

Methodology
In order to characterize the movement of the stock prices, we only assume that the stock price is a function of time  and consider it as a dynamic system.Since we suspect that the rise and fall of the stock prices may be described by the logistic growth model, we combine the concept of the logistic growth model and the dynamic integration to build dynamic models.The models are represented by differential equations which are detailed below along with their solutions.
Model A (dynamic logistic model) where () is the stock price at time .We can rewrite (2) as and hence model A is in the form of the logistic growth model.
Because the stock prices change dynamically in reality, we assume that the coefficients  1 () and  1 () are constant during a very short time.Then we consider the parameterized differential equation: with given values of two points at time  0 and  1 .Let  = |(( 0 ) +  1 / 1 )/( 0 )| and the solution is if  () <  ( 0 ) , ( () +  1 / 1 ) ⋅  () > 0; (7) Model A describes the relationship between the stock price, (), and its velocity, ()/.From the economic point of view, there exists an implied equilibrium in the market.All other things being equal, if the stock price is below the equilibrium, it will rise towards the equilibrium price; if the stock price is above the equilibrium, it will decline.The phenomenon is also called the mean reversion.This model characterizes the mean reversion of the stock prices if  1 is negative,  1 is positive and when the expected future stock price is higher than the current stock price.Under the circumstances, the implied equilibrium is at | 1 / 1 | and the stock price moves as how the logistic growth model describes.The convergence of the simulated theoretical stock prices by ( 5), ( 6) is plotted in Figures 7 and 8. Otherwise, the movement of the stock prices follows a quadratic differential equation with no constant growth rate [15].In this situation, the stock prices will not converge to the implied equilibrium.
In addition to model A, we further consider both the velocity, ()/, and the acceleration,  2 ()/ 2 , of the stock price to construct a model.In this instance, the model may represent the movement more properly.Hence, we propose model B in the following.

Model B (dynamic transformed logistic model)
where () is the stock price at time .
Assuming the coefficients  2 () and  2 () are constant during a very short time, we consider the parameterized differential equation with given values of two points at times  0 and  1 : and it can be solved as follows.Let Model B describes the relationship between the velocity, ()/, and the acceleration,  2 ()/ 2 , of the stock price.The relationship is in the form of the logistic growth model.When  2 is negative and  2 is positive, the velocity moves in the way that the logistic growth model depicts.That is, the velocity reverses to an implied equilibrium velocity so that the stock price goes up or down with an approximately constant speed.In the case of other combinations of the coefficients ( 2 and  2 ), the velocity diverges and hence the stock prices fluctuate more dynamically.
Other than the velocity, the relative growth rate of the stock price, (()/)/(), which is also known as the return is a meaningful measure in the field of finance.Therefore, we change the velocity and the acceleration in model B into the relative growth rate and its derivative to build model C. Model C provides another kind of differential equation characterizing the stock price movement.

Model C (dynamic relative growth rate transformed logistic model)
where () is the stock price at time  and () = (()/)/ () is the relative growth rate of the stock price at time .
Assuming the coefficients  3 () and  3 () are constant during a very short time, we consider the parameterized International Journal of Differential Equations differential equation with given values of two points at times  0 and  1 : and it can be solved as follows.Let  = |(( 0 ) +  3 / 3 )/( 0 )| and the solution is ) ⋅  () < 0,  () <  ( 0 ) ,  () <  ( 0 ) .Model C describes the relationship between the relative growth rate of the stock price, (), and its derivative.Since the relative growth rate is the return of the stock price, when  3 is negative and  3 is positive, the return moves in the way that the logistic growth model depicts.That is, the return reverses to a constant implied equilibrium.In the case of other combinations of the coefficients ( 3 and  3 ), the return diverges and the fluctuations of the stock prices are more dynamical but different from what model B describes.
The dynamic models above are built on the work of Chen et al. [2].But all of them consist of two coefficients instead of one as in their study.Hence we generalize one of their models into a two-coefficient dynamic model and compare it with the three models above.This extended model is stated in the following.

Model D (dynamic general Newton model)
where () is the stock price at time .We assume the coefficients in (15) are constant during a very short time interval  ∈ [ 0 ,  1 ] and consider the parameterized differential equation: between two given data points at times  0 and  1 .The solution can be found in the article of Chen et al. [2].
As applying these dynamic models, we discretize and convert them into difference equations since the time interval between the two given points at times  0 and  1 is relatively short compared to the interval of the complete data.The discretization and the parameterization make the differential equations solvable.In the empirical study, we fit and forecast the data by the solutions.We also adopt the dynamic forecasting method discussed in [2] to obtain more accurate theoretical values.

Empirical Study
We collected and studied a series of Taiwan Stock Exchange Capitalization Weighted Stock Index (TAIEX) closing prices from June 1, 2015, to August 31, 2016.There are 310 trading days during this period.Since the dynamic forecasting method is applied, the length of forecasts needs not to be long [2] so that we make 30 forecasts for each model.But the forecasting periods of the four models are different because first-order difference is revolved in calculations of model A, D and second-order difference is revolved in calculations of model B, C.
We apply forward difference method to numerical analysis since the results do not differ much from applying backward difference method [16].For fitting with the dynamic models, the future information is included in calculations.To avoid the inclusion of future information for model forecasting, the theoretical values are obtained assuming that the situation is unchanged during a longer period from three trading days before the date to be forecasted.That is, the model coefficients are assumed to be constant in the interval  ∈ [ 0 ,  3 ] and the theoretical values at time  3 are obtained by solving (4), ( 10), (13), and ( 16 In numerical analysis, the theoretical values of model D sometimes blow up when the coefficient  4 are very large because of its position in the power of exponential part of the solution.The theoretical values make sense if they are restricted in a range where market values exist.Hence, when  4 is higher than 2 (resulting in the theoretical value out of range of possible market values on the condition) the theoretical value will be replaced with the theoretical value of the previous trading day.Moreover, a 10% daily price fluctuation limit in Taiwan stock market is set up since June 1, 2015.Accordingly, the theoretical values of the four models are restricted to the limit if they are above or below it.
The TAIEX series is also analyzed by examining its sample ACF (autocorrelation function) and PACF (partial autocorrelation function) and testing by Ljung-Box Test [19] shown in Figure 9 and Table 4.The autocorrelation of the series is not statistically significant.Under the circumstances, we suppose the stock closing prices during the period is a random walk and consequently the martingale is set as the benchmark model.Once the theoretical values of the four dynamic models are obtained, we compare them with the fits and forecasts of the martingale.
We will first present the fits of the four dynamic models and next their forecasts in the section.The fitting results are in Figures 1-4.
The graphs show that the fits of model A fluctuate much more than the other models and model D has the fewest deviations of the fits from the market values.The MAPEs and RMSPEs of the models are listed in Table 2.The order of the model performance by the values coincides with the graphs.Furthermore, the fits of the martingale are only closer to the market values than those of model A.
We then examine the model coefficients.The graphs and some statistics of the coefficients are in Table 5 and Figures 10-13.Basically the alphas and the betas move in the small range around their median except for some large jumps or drops.The unusual jumps and drops seem to appear on the same dates and should be studied more thoroughly.
As noted in the previous section, the phenomenon of mean reversion shows if  1 < 0 and  1 > 0 for model A,  2 < 0 and  2 > 0 for model B,  3 < 0 and  3 > 0 for model C, and  4 < 0 for model D. On the condition, if the subject value is higher than the implied equilibrium, it will reverse to the equilibrium with a sharp decreasing speed; if the subject value is lower than the implied equilibrium, it will first reverse to the equilibrium with a steep rise and then gradually slow down.The phenomenon is for different subjects related to stock index: the stock index closing price for model A, D; the velocity of stock price for model B; the relative growth rate (return) of stock price for model C. Therefore, the mean reversion described in models A and D is either the bull market or the bear market for the stock prices.In models B and C, the bull market (upward trend) or the bear market (downward trend) is used to describe the velocity and the related growth rate of the stock prices, respectively.The proportion of mean reversion shown during the studied period of the data is 0.72 (199/278) for model A, D and 0.23 (64/277) for model B, C. Other than the mean reversion phenomenon, the dynamic models also characterize different types of market trends as well by different performances of the model coefficients.
Next we forecast by the four dynamic models and compare the results with the martingale in Figures 5 and 6.The details of each model are shown in Figures 14-19.The forecasts of model A fluctuate the most and have the most deviations from the market values.Models B, C, and D all forecast the trend of the stock prices well and model D seems to have the most accurate forecasts.We list the errors of the four dynamic models and the martingale in Table 3.The forecasting ability of the martingale is the best among all models; however, model D has similar results.
The sources of error include the disparity between the differential equations and the difference equations, the disagreement between the movement of the subject and the model form, and the dynamics of the model coefficients.If the model form does not represent the movement of the subject very accurately, the model will produce larger error and thus  the forecasting ability of the model will be lower.Model A and model D both characterize the relationship between the subject and its first-order derivative.Nevertheless, model D forecasts much better than model A as a result of the concordance between model D and the data.Besides, error comes from the dynamics of the model coefficients.We assume the model coefficients are constant in a four-day interval prior to the forecast during the forecasting process.In real world, the coefficients are more dynamical and consequently error shows.

Conclusions
We propose four dynamic models to characterize the movement of the subject, the TAIEX closing prices.Some types of the movement are considered in the models: the mean reversion, different speeds of the uptrend and the downtrend, and so forth.There are two forms of the models: the logistic growth and the law of Newton's cooling.We apply the    four dynamic models to fit and forecast the TAIEX closing prices and compare them with the martingale.The fits of models B, C, and D are closer to the market values than those of the martingale which suggests that they characterize the movement of the subject quite properly.However, the martingale outperforms the dynamic models for forecasting the coefficients by some different methods such as time series analysis and polynomial extrapolation is our future work.
Furthermore, there are some limits to the dynamic model applications.For example, the theoretical values are limited in a range of 10% price limit because of the regulation constraint.Therefore, applying the dynamic models to the subject in the market without the price limit may not be suitable.However, the empirical study shows that the model in the form of the law of Newton's cooling (model D) is better than the models in the form of the logistic growth (models A, B, and C).This suggests that the former type of the model may be more proper for the market with price limit while the later type of the model may be more proper for the market without price limit.Confirming the conjecture and modifying the models to generalize their applications are also our future work.
), respectively.Therefore, the fitting periods of model A, D begin from June 2, 2015, and end at July 19, 2016, while the fitting periods of model B, C begin from June 2, 2015, and end at July 18, 2016.Forecasts of model A, D are both from July 20, 2016, to August 30, 2016; forecasts of model B, C are both from July 19, 2016, to August 29, 2016.

Figure 1 :
Figure 1: Time plot of raw data and model A fits.

Figure 2 :Figure 3 :
Figure 2: Time plot of raw data and model B fits.

Figure 4 :Figure 5 :
Figure 4: Time plot of raw data and model D fits.

Figure 6 :Figure 7 :
Figure 6: Time plot of raw data and the forecasts of model D and the martingale.

Figure 10 :Figure 11 :
Figure 10: Time plots of model A coefficients- 1 and  1

Figure 17 :Figure 18 :Figure 19 :
Figure 17: Time plots of raw data and the forecasts of model D.

Table 1 :
Classification of model forecasting ability by MAPE.

Table 2 :
MAPEs and RMSPEs, fits of the four dynamic models and the martingale.classification of Table1although RMSPE is more affected by extreme values.In brief, the smaller the values of MAPE and RMSPE are, the better the forecasting ability of a model is.Besides, MAPE and RMSPE are also calculated to measure the fitting accuracy of the models in this study.

Table 3 :
MAPEs and RMSPEs, forecasts of the four dynamic models and the martingale.

Table 5 :
Centering tendency of the dynamic model coefficients.