Научная статья на тему 'Hidden Markov models and neural networks in formation of investment portfolio'

Hidden Markov models and neural networks in formation of investment portfolio Текст научной статьи по специальности «Экономика и бизнес»

CC BY
278
35
i Надоели баннеры? Вы всегда можете отключить рекламу.
Ключевые слова
HIDDEN MARKOV MODELS / PERCEPTRON / INVESTMENT PORTFOLIO / GROSS DOMESTIC PRODUCT / BAUM-WELCH ALGORITHM / СКРЫТЫЕ МАРКОВСКИЕ МОДЕЛИ / ПЕРЦЕПТРОН / ИНВЕСТИЦИОННЫЙ ПОРТФЕЛЬ / ВАЛОВЫЙ ВНУТРЕННИЙ ПРОДУКТ / АЛГОРИТМ БАУМА ВЕЛША

Аннотация научной статьи по экономике и бизнесу, автор научной работы — Novikov Petr Andreevich, Valiev Radik Rifatovich

Математические модели, применяемые инвесторами для прогноза будущего состояния финансового рынка, теряют свою эффективность при ухудшении макроэкономической ситуации. В связи с этим актуальна разработка модели, обеспечивающей минимизацию убытков при формировании инвестиционного портфеля в условиях экономических колебаний. Большинство моделей, описывающих экономические колебания, рассматривают годовые изменения, что приводит к понижению своевременности реагирования на фактические колебания экономики. Модель, позволяющая прогнозировать будущее состояние экономики исходя из более актуальных данных, может помочь выбрать оптимальную стратегию формирования инвестиционного портфеля. В настоящей работе предлагается математическая модель, позволяющая определить возможное направление изменения экономической ситуации поквартально, что позволяет более своевременно принимать решения по поводу стратегии формирования инвестиционного портфеля. Модель построена на основе скрытых марковских моделей и многослойного персептрона.

i Надоели баннеры? Вы всегда можете отключить рекламу.
iНе можете найти то, что вам нужно? Попробуйте сервис подбора литературы.
i Надоели баннеры? Вы всегда можете отключить рекламу.

Common mathematical models are used by investors for prediction of the future state of the financial market lose if the macroeconomic situation gets worse. In this regard, it is desired to build models that minimize losses in the formation of an investment portfolio under the conditions of economic fluctuations. Many models describing economic fluctuations consider annual changes, which allows to reduce the response time to the actual economical fluctuations. A model that predicts the future state of the economy based on more recent data enables the choice of the optimal strategy for investment portfolio formation. In this paper, we have proposed an economical model that allows to determine possible direction of changes in the economic situation on a quarterly basis, which is helpful in making timely decisions on the strategy for investment portfolio formation. Our model is based on hidden Markov models and the multilayer perceptron.

Текст научной работы на тему «Hidden Markov models and neural networks in formation of investment portfolio»

2018, Т. 160, кн. 2 С. 357-363

УЧЕНЫЕ ЗАПИСКИ КАЗАНСКОГО УНИВЕРСИТЕТА. СЕРИЯ ФИЗИКО-МАТЕМАТИЧЕСКИЕ НАУКИ

ISSN 2541-7746 (Print) ISSN 2500-2198 (Online)

UDK 004.85

HIDDEN MARKOV MODELS AND NEURAL NETWORKS IN FORMATION OF INVESTMENT PORTFOLIO

P.A. Novikov, R.R. Valiev

Kazan Federal University, Kazan, 420008 Russia Abstract

Common mathematical models are used by investors for prediction of the future state of the financial market lose if the macroeconomic situation gets worse. In this regard, it is desired to build models that minimize losses in the formation of an investment portfolio under the conditions of economic fluctuations. Many models describing economic fluctuations consider annual changes, which allows to reduce the response time to the actual economical fluctuations. A model that predicts the future state of the economy based on more recent data enables the choice of the optimal strategy for investment portfolio formation. In this paper, we have proposed an economical model that allows to determine possible direction of changes in the economic situation on a quarterly basis, which is helpful in making timely decisions on the strategy for investment portfolio formation. Our model is based on hidden Markov models and the multilayer perceptron.

Keywords: hidden Markov models, perceptron, investment portfolio, gross domestic product, Baum-Welch algorithm

Introduction

A large value of the internal rate of return in the financial market leads to an increase in the number of its participants. The volume of trade in corporate bonds in the United States rose by 4.8% in the first half of 2017, compared with the same period of 2016. The growth of popularity of the financial market can also be observed by comparison of monthly indicators: the number of registered customers in the stock market trading system of the Moscow Stock Exchange increased by 5.15% in June 2017, as compared with the previous month.

The increase of the number of participants in the financial market boosts the demand for the methods that allow investment portfolio formation with the greatest profit. However, as A.O. Shklyaev notes [1], macroeconomic factors have a great influence on the short-term methods that help in the formation of an optimal investment portfolio. J. Wakas et al. [2] come to the conclusion that one of the key factors affecting the volatility of the volume of foreign portfolio investments is the gross domestic product (GDP) growth rate. A model that allows prediction of changes in the economic situation can increase the efficiency of the strategy for investment portfolio formation.

The objective of this work is to find an approach to determine a strategy for investment portfolio formation taking into account the predictions of changes in the economic situation.

The review of the studies dedicated to modeling of economic fluctuations shows that the applicable methods go far beyond the regression analysis.

C. Len and S. Van [3] apply hidden Markov models (HMMs) to reflect the development of economic cycles using China as an example. The authors use the expectation

maximization (EM) algorithm to select HMM parameters with the help of annual GDP indicators. As a result they obtain a model with the prediction accuracy of 75%.

C. Anglelache and G.V. Anglelache [4] propose single- and multi-factor regression models for studying the signs that affect the change of the economic situation. The authors prove a close dependence of the Austrian GDP indicator on the performance of trading companies.

M.I. Geras'kin and P.V. Porubova [5] use time series regression models. The authors develop models that describe the GDP growth rate in the Russian Federation, as well as the value of the fixed capital, volume of investments, employment growth rate, etc. The physical value of the GDP in 2016 confirmed the authors' prediction on the reduction of this indicator: the actual increase rate was -0.2%, and, according to the authors, this indicator will reach the level of 2014 in 2020.

The drawbacks of these models include lack of possibility to make predictions for a shorter period. This prevents timely decision making in investment portfolio formation. Moreover, these models do not take into consideration the inflation rate, which, along with the volume of GDP, is one of the most significant factors affecting the volatility of financial instruments [2].

In this paper, we propose an economical model based on HMMs and the multilayer perceptron. We used quarterly data on the indicators that characterize the development of the economy in constructing our models to ensure timely results. In addition, the consumer price index was included in the input parameters of the model to increase the accuracy of prediction.

A combination of the HMM and neural networks using different algorithms of construction and evaluation can be helpful in making predictions of the economic development considering the hidden state of the economy and the inflation rate.

We used the expectation maximization and Baum-Welch algorithms [6] to select HMM parameters. In addition, the HMM received dummy variables corresponding to different intervals of the speed of variation of the GDP as input. The obtained models were compared by the sequential probability ratio test [7].

We used hidden Markov states, consumer price indices, and data on the direction of GDP growth in multi-layer perceptron training. We used the backpropagation of errors for the training [8].

The results obtained in this paper allow for determination of possible direction of the economic situation change quarterly with an accuracy of 73.33%. Thus, the timeliness of financial decisions may be increased.

The paper compares the obtained results with the application of the EM algorithm and the Baum-Welsh approach that improves the quality of the intermediate results. These include hidden Markov states, which form one of the input parameters of a multilayer perceptron.

In addition, the paper proposes a strategy for forming an investment portfolio taking into account the predictions of development of the economic situation, which may reduce losses in investment portfolio formation.

In the first section, we describe the stages of HMM formation and the conclusions obtained in assessing their correspondence to the actual economic processes. In addition, this section reflects the learning process of neural networks. In the second section, we give recommendations on the use of the obtained models. Finally, we describe further directions of research and lay out the main conclusions we came to in the course of the research.

1. Construction of mathematical model

We build a HMM using the indicators that characterize the quarterly growth rate of the gross domestic product in the United States (US GDP) from the first quarter of 1947 to the fourth quarter of 2016. Another model received the rate of variation of GDP as observations (1) [9]:

rk+i — rk-i , 3 1

vk = -, k = 3, m — 1,

k 2

where vk is the growth rate of the GDP growth rate and rk+1 is the indicator of GDP growth rate, where time is k + 1, m is the number of observations.

In addition, some HMMs also include dummy variables, which replace GDP growth rates based on their location between quantiles. For example, the growth rate below the second quantile was replaced by "1", the one that was higher than this quantile, but lower than the third one, was replaced by "2", etc.

The Baum-Welsh and expectation maximization (EM) algorithms allowed determining the optimal parameters of the HMMs. Both approaches help to select parameters while increasing the probability of obtaining a sequence of observations.

The forward-backward algorithm is commonly used to find this probability.

The mentioned algorithm includes two procedures [10]. It is sufficient to use the first procedure to calculate the probability of obtaining a sequence of observations, also called the direct procedure. It defines "direct" variables - the probabilities of obtaining the initial part (from time 1 to t) of the given sequence of observations O = oi,... ,ot under the condition that the motion begins at time 1 and ends at time t at the state si:

at(i) = p(oi, ...,Ot,qt = Si|A).

These probabilities can be calculated recursively using the following expression:

N

at+i(j)= b — j(ot+i)J2 at(i)aij, 1 < j < N, 1 < t < T - 1,

i=i

where

ai(j)= njbj(oi), 1 < j < N.

These calculations are also applied to find direct variables in the end of the sequence

aT(i), 1 < i < N,

The optimized indicator is the sum of direct variables over a finite period of time (1) over all hidden states.

The EM algorithm implemented in R DepmixS4 package [11] is usually applied with some modifications:

• the direct variables calculated at time t are divided by the sum of such indicators calculated at time t — 1;

• the optimized indicator is the logarithm of the product of all direct variables over time periods taking the hidden states into account.

In this case, the hidden states used in the calculation of the direct variables are obtained by the Viterbi algorithm [12].

We compare the models obtained using the Baum-Welsh and EM algorithms by the sequential tests [7]. The null hypothesis claims that the model constructed using the Baum-Welsh algorithm can be considered as closer to the true one, and the alternative claims that the model obtained using the EM algorithm is better. The sequential

tests [8] show that type I and type II errors are equal to 0.0071, 0.9941, respectively. Exceeding type II errors 99% indicates the possibility of rejection of the null hypothesis. Therefore, we decide to use the model obtained by the EM algorithm in the subsequent stages of the work. We use it to reapply the Viterbi algorithm.

We use the resulting hidden states as an input vector in training of the neural networks. The neural network also receives the consumer price index (CPI) as an input.

At the same time, we use dummy variables reflecting the intervals between the quan-tiles instead of actual values of the CPI. In addition, the neural networks receive dummy variables as an input instead of the indicators of GDP growth rate. We replace the growth rate below or equal to the average value throughout the analyzed period by 1, and the growth rate above that by 0.

We use the method of backpropagation of errors and its implementation in the R pyBrain package for training these neural networks.

The prediction of changes in the economic conditions can be helpful in determining the objective function in Tobin's model, which is used to maximize the portfolio returns or minimize the risk.

The yield of the investment portfolio in Tobin's models is calculated as a weighted sum of yields of securities [13].

A separate calculation algorithm to determine the overall portfolio risk is provided. It has the following form [13]:

where p is the overall risk of the investment portfolio, i is the the standard deviation of the yields of the i-th security, kij is the correlation coefficient between the (i,j)-th securities, wi is the share of securities in the investment portfolio, Vij is the covariance of the yields of the i-th and j-th securities, n is the the total number of types of securities in the portfolio.

It is recommended to use the prediction of economic development in determining the objective function, which is the key part in investment portfolio formation. For example, if the model obtained with training of neural networks gives an output of 1, then the investor should reduce their risks by buying assets with a lesser risk. This means that they will minimize the overall portfolio risk. At the same time, it is better to put constraints on the amount of investment portfolio yield. In addition, the sum of weights of the financial instruments must be equal to 1.

The comparison of the probability of obtaining a sequence of observations using different input data shows that the use of dummy variables that replace the ratio of the variation of GDP allows a more reliable prediction of the economic situation.

In addition, sequential tests led to the conclusion that the model constructed using the EM algorithm (Fig. 1) is better than when the Baum-Welch algorithm is applied.

Training of neural networks and their testing on the data from 2000-2002, 20032004, 2010-2012 shows that the optimal number of neurons in the hidden layer is 11.

The obtained mathematical model allows prediction of the economic situation on the quarterly basis with an accuracy of 73%.

2. Strategy of investment portfolio formation

3. Results

initial state probabilties model prl pr2 ргЗ рг4 pr5 ргб рг7 1 0 0 0 0 0 0

Transition matrix

tosl toS2 toS3 toS4 toS5 tOS6 toS7

fromsl 0. 190 0. 0 0. 000 0. 138 0. 000 0. . 672 0. 000

froms2 0. 568 0. 0 0. 000 0. 000 0. 074 0. , 184 0. 174

f romS3 0. 000 0.1 0. 128 0. 000 0. 667 0. , 000 0. 105

froms4 0. 000 1. 0 0. 000 0. 000 0. 000 0. . 000 0. 000

fromS5 0. 316 0. 0 0. 000 0. 080 0. 198 0. , 265 0. 141

frornse 0. 000 0. 0 0. 767 0. 110 0. 000 0. . 12 3 0. 000

fromS7 0. 354 0. 0 0. 000 0. 000 0. 000 0. , 000 0. 646

Response parameters

Ftesp 1 : multinomial

Rel.(intercept).1 Rel.(intercept).2 Rel.(intercept).3 Rel.(intercept).4

Stl 0 -15.268 -17.501 -16.369

St 2 0 2.108 14.347 7.821

St3 0 -0.471 9.996 10.931

St4 0 1.292 14.938 -6. 6B3

St 5 0 1.766 3.714 18.755

St6 0 0.303 -10.609 -11.154

St 7 О 1.935 -0.481 -8.743

Fig. 1. Parameters of a HMM obtained by DepmixS4 library

The prediction constructed for the first quarter of 2017 led to the conclusion that in the considered period the optimal strategy was to maximize the yield of the portfolio. The findings were confirmed by the visual analysis of the S&P 500 index change schedule [14]. It can be seen that the volatility of securities in the first quarter of 2017 is much lower than the indicator for the same period of 2016. This means that the investor will maximize their profit by selecting more risky securities. At the same time, they will adhere to a certain limitation of risk.

Conclusions

In the course of this research, HMMs were constructed and evaluated using various algorithms.

The sequential tests showed that the HMM generated by the EM algorithm is more consistent with the true model.

Thus, the main results of this research are the following:

• we obtained a mathematical model that allows building reliable forecasts of quarterly changes in the economic situation in 70% of cases;

• we developed an approach to determine the optimal investment portfolio formation strategy that includes the optimization of various target functions depending on predictions of macroeconomic situation development.

Our further research will focus on the study of the behavior of various financial instruments in the hidden states of the economy, considering the possibility of combining short- and long-term forecasting tools.

References

1. Shklyaev A.O. Predicting financial time series by hidden Markov models. Nauchn. Zap. Molodykh Issled., 2015, vol. 1, pp. 17-21. (In Russian)

2. Waqasa Y., Hashmia S.H., Nazir M.I. Macroeconomic factors and foreign portfolio investment volatility: A case of South Asian countries. Future Bus. J., 2015, vol. 1, no. 1, pp. 65-74. doi: 10.1016/j.fbj.2015.11.002.

3. Leng C., Wang S. Hidden Markov Model for predicting the turning points of GDP fluctuation. Proc. Int. Conf. on Future Computer and Communication Engineering. Tianjin, Atlantis Press, 2014. doi: 10.2991/icfcce-14.2014.1.

4. Anghelache C., Anghelache G.V. Macroeconomic models used in the structural analysis of the gross domestic product. Rom. Stat. Rev., 2013, vol. 61, no. 6, pp. 15-21.

iНе можете найти то, что вам нужно? Попробуйте сервис подбора литературы.

5. Geras'kin M.I., Porubova P.V. Trend analysis of the dynamics of macroeconomic indicators of the Russian Federation in 1959-2014. Vestn. Samar. Gos. Ekon. Univ., 2017, vol. 4, no. 150, pp. 5-18. (In Russian)

6. Dempster A.P., Laird N.M., Rubin D.B. Maximum likelihood from incomplete data via the em algorithm. J. R. Stat.. Soc., Ser. B, 1977, vol. 39, no. 1, pp. 1-38.

7. Fuh Ch.-D. SPRT and CUSUM in hidden Markov models. Ann. Stat., 2003, vol. 31, no. 3, pp. 942-977.

8. Rumelhart D.E., Hinton G.E., Williams R.J. Learning representations by back-propagating errors. Nature, 1986, vol. 323, no. 6088, pp. 533-536.

9. loan C.A., loan G. Analysis of the evolution of the gross domestic product by means of cyclic regressions. Acta Univ. Danubius, 2011, vol. 4, no. 4, pp. 114-126.

10. Savin A.N., Timofeeva N.E., Geras'kin A.S., Shamshina E.A., Mavlyutova Yu.A. Development of components of a program complex for stream filtration of audiocontent by means of hidden Markov models. Izv. Sarat. Univ., Nov. Ser. Mat. Mekh. Inf., 2015, vol. 15, no. 3, pp. 340-350. (In Russian)

11. Visser I., Speekenbrink M. depmixs4: An r package for hidden Markov models. J. Stat. Software, 2010, vol. 36, no. 7, pp. 1-21.

12. Viterbi A.J. Error bounds for convolutional codes and an asymptotically optimum decoding algorithm. IEEE Trans. Inf. Theory, 1967, vol. 13, no. 2, pp. 260-269.

13. Tobin J. Liquidity preference as behavior towards risk. Rev. Econ. Stud., 1958, vol. 25, no. 2, pp. 65-86. doi: 10.2307/2296205.

14. Yahoo Finance. GSPC Interactive Stock Chart. S&P 500 Stock. Available at: https://finance.yahoo.com.

Received

November 10, 2017

Novikov Petr Andreevich, Candidate of Physical and Mathematical Sciences, Assistant of the Higher School of Information Technologies and Information Systems Kazan Federal University

ul. Kremlevskaya, 18, Kazan, 420008 Russia E-mail: novikov@it.kfu.ru

Valiev Radik Rifatovich, Graduate Student of the Higher School of Information Technologies and Information Systems Kazan Federal University

ul. Kremlevskaya, 18, Kazan, 420008 Russia E-mail: radi.valiev@yandex.ru

УДК 004.85

Скрытые марковские модели и нейронные сети в формировании инвестиционного портфеля

П.А. Новиков, Р.Р. Валиев

Казанский (Приволжский) федеральный университет, г. Казань, 420008, Россия

Аннотация

Математические модели, применяемые инвесторами для прогноза будущего состояния финансового рынка, теряют свою эффективность при ухудшении макроэкономической ситуации. В связи с этим актуальна разработка модели, обеспечивающей минимизацию убытков при формировании инвестиционного портфеля в условиях экономических колебаний. Большинство моделей, описывающих экономические колебания, рассматривают годовые изменения, что приводит к понижению своевременности реагирования на фактические колебания экономики. Модель, позволяющая прогнозировать будущее состояние экономики исходя из более актуальных данных, может помочь выбрать оптимальную стратегию формирования инвестиционного портфеля. В настоящей работе предлагается математическая модель, позволяющая определить возможное направление изменения экономической ситуации поквартально, что позволяет более своевременно принимать решения по поводу стратегии формирования инвестиционного портфеля. Модель построена на основе скрытых марковских моделей и многослойного персептрона.

Ключевые слова: скрытые марковские модели, перцептрон, инвестиционный портфель, валовый внутренний продукт, алгоритм Баума-Велша

Поступила в редакцию 10.11.17

Новиков Петр Андреевич, кандидат физико-математических наук, ассистент Высшей школы информационных технологий и информационных систем Казанский (Приволжский) федеральный университет

ул. Кремлевская, д. 18, г. Казань, 420008, Россия E-mail: novikov@it.kfu.ru

Валиев Радик Рифатович, магистрант Высшей школы информационных технологий и информационных систем

Казанский (Приволжский) федеральный университет

ул. Кремлевская, д. 18, г. Казань, 420008, Россия E-mail: radi.valiev@yandex.ru

I For citation: Novikov P.A., Valiev R.R. Hidden Markov models and neural networks ( in formation of investment portfolio. Uchenye Zapiski Kazanskogo Universiteta. Seriya \ Fiziko-Matematicheskie Nauki, 2018, vol. 160, no. 2, pp. 357-363.

/ Для цитирования: Novikov P.A., Valiev R.R. Hidden Markov models and neural ( networks in formation of investment portfolio // Учен. зап. Казан. ун-та. Сер. Физ.-ма-\ тем. науки. - 2018. - Т. 160, кн. 2. - С. 357-363.

i Надоели баннеры? Вы всегда можете отключить рекламу.