• No results found

ON THE PREDICTIVE PERFORMANCE OF THE STOCK RETURNS BY USING THE MARKOV-SWITCHING MODELS

N/A
N/A
Protected

Academic year: 2021

Share "ON THE PREDICTIVE PERFORMANCE OF THE STOCK RETURNS BY USING THE MARKOV-SWITCHING MODELS"

Copied!
53
0
0

Loading.... (view fulltext now)

Full text

(1)

ON THE PREDICTIVE PERFORMANCE OF THE STOCK

RETURNS BY USING THE MARKOV-SWITCHING

MODELS

Submitted by

Yanan Wu

A thesis submitted to the Department of Statistics in partial

fulfillment of the requirements for a two-year Master degree

in Statistics in the Faculty of Social Sciences

Supervisor

Yukai Yang

(2)

ABSTRACT

This paper proposes the basic predictive regression and Markov Regime-Switching regres-sion to predict the excess stock returns in both US and Sweden stock markets. The analysis shows that the Markov Regime-Switching regression models out perform the linear ones in out-of-sample forecasting, which is due to the fact that the regime-switching models capture the economic expansion and recession better.

(3)

Contents

1 Introduction 1 1.1 Background . . . 1 1.2 Literature review . . . 1 2 Methodology 2 2.1 Models . . . 3 2.2 Estimation Method . . . 4

2.3 Notification for Regime-switching Model . . . 5

2.4 Forecast Method . . . 6 2.4.1 Out-of-sample Forecast . . . 6 2.4.2 Forecast Model . . . 7 2.4.3 Criterion Value . . . 7 3 Empirical Analysis 8 3.1 Data . . . 8

3.1.1 The Welch and Goyal Data . . . 9

3.1.2 Swedish Data . . . 9 3.2 Application 1 . . . 11 3.2.1 Description Result . . . 11 3.2.2 Correlations . . . 13 3.2.3 Regime Identification . . . 14 3.2.4 Forecast Result . . . 16 3.3 Application 2 . . . 21 3.3.1 Description Result . . . 21 3.3.2 Forecast Result . . . 22 4 Conclusion 24 5 Acknowledgement 26 6 Appendix 29 6.1 Time Series Plots for Different Variables . . . 29

(4)

1

Introduction

1.1

Background

The stock returns are supposed to reflect the value of underlying assets and stock return pre-diction is important in the field of empirical research in economic and financial aspects. In this paper, I will focus on predicting excess stock returns by using some popular indicators. The aim of the paper is to compare the difference between the baseline linear model and the regime-switching regression model.

In the regime-switching framework, I combine the identified regimes with the real economic link, and find them explain the historical events by capturing the economic expansion and recession. The Markov-switching framework allows for volatility change, therefore, it is also worth checking whether the volatility is related to economic expansions and recessions of the estimation.

The performance could be different in the different time horizons. As a result, the com-parison of different forecast step sizes is important when evaluating the models with different indicators.

In the following section, I do the regime identification for each predictive indicator and compare the results with what Zhu and Zhu(2013) has done. In Section 2, I introduce the methodologies included in the paper. In Section 3 I do the empirical analysis. First identify the regimes of models and then use the model with better performance to research the impact of time horizons. Based on these steps, using another data set to test if the results can be promoted to countries and markets, here I use the data in Swedish stock market. Section 4 concludes.

1.2

Literature review

There are many related research about predicting stock returns based on it important meaning. My paper is mainly focus on the research by Zhu and Zhu(2013) which predict the stock returns by regime-switching model. There are many articles related this topic.

(5)

dif-ferent time horizons into account.Merton(1973) illustrates that there are time-varying relations between the stock returns and predictive variables. The recent paper by Chi(2018) research the stock price forecasting with time series analysis which indicates the importance that time series to stock market.

After that, from the empirical study aspect, the dependent variable I choose is excess stock returns for it is vital in the stock markets and it is related to financial activities as Bradshaw ,Richardson and Sloan(2006) and Cen, Hilary and Wei(2013) have proved. The Chinese data is provided by Zhu and Zhu(2013). For the Swedish data, Waldenstrom(2014) introduces the meaning of Swedish stock and bond returns. The classical research of Welch and Goyal(2008) find the different performance in prediction models by various degrees. It is a good hint to con-sider the economy meaning and constraints as Pettenuzzo, Timmermann and Valkanov(2014) mentioned.

When it comes to the forecast method, Rapach, Strauss and Zhou(2010) and Tang, Hu and Wang(2018) come up with using out-of-sample to predict the equity premium in the real econ-omy. And Wang(2009) use out-of-sample forecasting in an factor model. When considering the short and long-horizons, Henkel et al.(2011) interprets that short-horizon prediction is related to business cycle and economic expansions.

Further, in recent years there are more and more articles about identify the regimes by deep learning methods. For example, Maringer and Ramtohul(2012) and Dietmar and Tikesh(2012) use Regime-switching recurrent reinforcement model to assist to make decisions on investment. Encouraged by approaches above, regime-switching model, different algorithms are used to solve the prediction more accurate for stock returns.

2

Methodology

(6)

2.1

Models

(1) The Baseline model

Let us start with the baseline model. A typical predictive regression of stock returns with lagged variables is:

yt= αi+ βixi,t−1+ ei,t (2.1.1)

where ytis excess stock returns, xi,tthe predictive variable, and ei,tfollows normal distribution.

(2) Regime-switching Regression model(RSR)

By following the model that Zhu and Zhu(2013) has used to predict the stock returns, the general model of regime-switching regression model is:

yt= αi,st + βi,stxi,t−1+ ei,st (2.1.2)

where st=[L,H] is current regime at time t. It is worth to say that in Zhu and Zhu(2013) article

there are three regimes [L,M,H]. While the results in the regime identification part shows that all the predictive variables have only two regimes. There are no M status at time t. To simplify the process and keep the condition consistent at the same time, here I also only take two regimes into account. To be more specific, L stands for low-volatility regime and H represent high-volatility regime. Besides, ei,tfollows N (0, σi,s2 t). The model allows βi,stand ei,stto be

regime-dependent. The transition probabilities of different regimes is defined as Π, Π =   P (st= L|st= L) P (st= L|st = H) P (st= H|st= L) P (st= H|st = H)   (2.1.3) =   p11 p12 p21 p22   (2.1.4) where    p12= 1 − p11 p21= 1 − p22

and pij are transition probabilities from regime i to regime j. In my case, I use "msmFit"

(7)

2.2

Estimation Method

(1) Markov Chain Monte Carlo method(MCMC)

This estimation method is used in Zhu and Zhu(2013) to estimate the RSR model, which takes sample from random distribution and do Monte Carlo(MC) simulation by some steps.The basic theory is building a Markov Chain to get the stationary posterior distribution for the estimating parameter. Then do MC integration with the posterior distribution sample that is determined by the output from last step. Therefore, the more steps are, the more information that can be used to forecast, leading to more accurate result.

To be more specific, take an typical example of MCMC method, if we want to forecast a passerby’s destination for the next step, taking every previous steps as sample. Then by computation, the destination for the next step is most probability at the place with the most pass-by times.

The general procedure of MCMC is:

• Build a Markov Chain to get the stationary distribution π(P ) by transformation matrix T • Create sample forΠ(P ) by the conditional probability distribution T (P |Pt)

• Monte Carlo integration. The forecast result is the expectation value. n is the sample size. f (P ) = 1 n n X i=1 f (Π(Pi))

(2) Expectation Maximization algorithm(EM)

This estimation method is what I use in this paper to estimate the regime-switching models. The EM algorithm is suitable for finding maximum likelihood estimation or maximum posterior estimation in the model. It is usually used in data clustering. The method typically applied in the model which has latent variables or missing values.

The general process of EM is:

• Calculate expectation. Using the existing estimation in the latent variable to calculate the maximum likelihood estimation for the unknown variable

(8)

• Iteration the first two steps until the result convergent

These two estimation methods are both suitable for regime identification because they are asymptotic equivalent. The reason why I finally choose to use EM is:

First, in this paper, my interest is neither to compare the predictive accuracy nor predictive results by different estimation methods, so I choose one method to estimate. Second, the EM uses maximum likelihood estimation while MCMC uses simulation integration. Definitely, EM algorithm is more efficient and in the sense that it is less time consuming. I use the "MSwM" package for EM estimation. Using a different estimation method to predict the same data set used in the previous article is an interesting point to analysis, which is also one contribution of my study.

2.3

Notification for Regime-switching Model

(9)

Table 1: Notifications for different models for Regime Switching Models

Switching one regime two regimes

None I -Swithching µ - IIA Swithching β - IIB Swithching σ2 - IIC Swithching µ,β - IID Swithching µ,σ2 - IIE Swithching β,σ2 - IIF Swithching µ,β,σ2 - IIG

Table 1 illustrates the notations for different models that I will investigate in the following work. One regime stands for a linear model and two-regime model implies that the correspond model can switch intercept, slope and variance. Thus, there are seven combinations for two-regime models.

The critical value I use to choose the best regime model is AIC. The smaller the AIC is, the better the model performs. After identifying the regime status for each regime-switching model, it comes to the forecast part.

2.4

Forecast Method

2.4.1 Out-of-sample Forecast

Out of sample forecast is an experiment that divide the parameter data into two parts and use the first part as the train part to forecast the next one. The goal is to check whether the predictive variable is useful when forecasting.

(10)

Then decide how many steps ahead to forecast. I choose first to do one-quarter-ahead forecast. Based on the paper Zhu and Zhu(2013), long-horizon returns have more information than short one but there still need to consider data overlap. Therefore, to compare the different predictive performance for the short and long time period, 4-quarter-ahead and 8-quarter-ahead are proper to consider.

2.4.2 Forecast Model

(1) Linear Regression forecast

As has mentioned in Methodology part,the basic predictive regression is: ˆ

yt= ˆαi+ ˆβixˆi,t−1+ ˆei,t (2.4.1)

Where the error term ei,t follows normal distribution. Therefore, when taking the expectation

of the model, error term equals to 0. Then the formula is:

E(ˆyt) = ˆαi+ ˆβiE(ˆxi,t−1) (2.4.2)

(2) RSR forecast

As we have mentioned in the model section, for the two regime model, we use the RSR model to forecast:

ˆ

yt= ( ˆαi,s1 + ˆβi,s1xˆi,t−1+ ˆei,s1) ∗ p1+ ( ˆαi,s2 + ˆβi,s2xˆi,t−1+ ˆei,s2) ∗ p2 (2.4.3)

Where Piis the probability of different regimes, to be more specific, p1stands for the predicting

model probability determined by regime 1 and p2 is the percentage of regime 2. When we take

the expectation of the dependent variable, the formula becomes:

E(ˆyt) = (E( ˆαi,s1 + ˆβi,s1xˆi,t−1+ ˆei,s1) ∗ p1) + (E( ˆαi,s2 + ˆβi,s2xˆi,t−1+ ˆei,s2) ∗ p2) (2.4.4)

= ( ˆαi,s1 + ˆβi,s1 ∗ E(ˆxt−1)) ∗ p1+ ( ˆαi,s2 + ˆβi,s2 ∗ E(ˆxt−1)) ∗ p2 (2.4.5)

2.4.3 Criterion Value

(11)

First, compute the forecast of excess stock returns at time t + 1, ˆ yt+1= N X i=1 wi,tyˆi,t+1 (2.4.6)

where N is the number of predictive variables and ˆyt+1 is weighted average of forecasters at

time t. In my case, I choose wi,t = 1/N .

Then compute the R2OOS

SE = n X i=1 (ybi− yi)2 (2.4.7) ST = n X i=1 (E(yi) − yi)2 (2.4.8) R2OOS = 1 − SE ST (2.4.9)

Where real stands for the empirical out-of-sample-set.The bigger the R2

OOS is, the better the

predicting performance is.

3

Empirical Analysis

The empirical analysis mainly contains three parts, data introduction and two application re-sults. And there are two data sets, one from US and another from Sweden, matching with application 1 and 2 respectively. There are mainly two tasks for this part: first, compare the model performance when forecasting excess stock returns and find a better one. Then using the better model to study and make comparison between short and long time horizons. To make the conclusions more credible, do the same analysis using a different data set, in my situation, Swedish data.

3.1

Data

(12)

3.1.1 The Welch and Goyal Data

The empirical data studied is quarterly ones from 1947:1 to 2008:4. The data is provided by Zhu and Zhu(2013), which is originally from Welch and Goyal(2008). The dependent variable is excess stock returns which is the difference between aggregate stock return and treasury bill rate on S&P500 index. Besides, the independent variables in the predictive model are shown in the table.

3.1.2 Swedish Data

(13)

Variable List

Variable Definition

Dividend Price Ratio(d/p) the log ratio of shareholders dividend to share price. For the dividend, it is 12-month sums on S&P500 index.

Earning Price Ratio(e/p) the log ratio of earnings per share to earnings. Earnings are 12-month sums on S&P500.

Dividend Yield(d/y) the log ratio of dividends to lagged stock price. Dividend Payout Ratio(d/e) the log ratio of dividends to earnings.

Stock Variance(svar) the sum of squared daily returns on S&P500 that measures the differ-ence the stock’s returns and the average return. A higher variance indi-cates the higher uncertainty and risks in stock market.

Book-to-Market Ratio(b/m) the ratio of book value to market value that is used to help investors compare the company value. The book value is determined by the his-torical cost and market value is from share price, number and capital-ization in the market.

Net Equity Expansions(ntis) the ratio of one-year moving sums of net issues to total stock market ones in NYSE.

Treasury Bill Rate(tbl) the treasury bill is the 3 months debt obligation in the secondary market. In most circumstances, investors can take higher investment rate when the longer transaction maturity.

Long Term Yield(lty) the long-term government bond yield that related to bonds price and interest payment which is the return of the bond by investors.

Long Term Return(ltr) long-term government bonds returns.

Term Spread(tms) long-term government bond yield minus 3-month treasury bill rate. Default Yield Spread(dfy) the yield on the difference between long term BAA and AAA corporate

bonds.

Default Return Spread(dfr) long-term corporate bond minus government bond returns.

Inflation(infl) it is influenced by the increase of Consumer Price Index. In the model, when doing the stock return forecast we use one-quarter lagged data. Investment to Capital

Ra-tio(i/k)

(14)

3.2

Application 1

3.2.1 Description Result

Table 2 shows the estimation results of regime-switching model using the quarterly data from 1947:1 2008:4. The dependent variable is excess stock returns and the left 15 ones are inde-pendent variables. The numbers in the table are the estimation results of the model, besides, "-" means regime-independent which keep the same coefficient with Regime I. Only two regime models are considered in these predictors. The d/y parameter suitable for one regime while the other fourteen predictive variables are better estimated by two regimes. The second column shows the model selection in the previous article written by Zhu and Zhu(2013). In my case, I use "msmFit" function which estimates the model by EM algorithm. To be more specific, µ1,β1

and σ1 are the estimated intercept, slope and variance coefficients of models in regime 1 and

µ2,β2 and σ2 are the ones in regime 2. The coefficients in table 2 are estimated by EM and the

values of intercept and slope are multiplied by 100. Further, in parenthese shows the t-value of MLE that can indicate whether the estimators are significant.

From the result, we can observe that the model selection for regime-switching is differ-ent except d/y, svar, dfr and i/k. Besides, some of the coefficidiffer-ents are not significant at 95% significant level.

(15)
(16)

3.2.2 Correlations

Table 3 shows the correlation coefficients of individual RSR forecasts. From the result, there are some RSR forecasts correlated significantly, which are easy to understand when consider the background and connections of the forecasting variables. For example, there are high cor-relation that up to 0.85 between b.m and dfy forecasts with 0.1% significance level, which the back potential economic link is that the default risk is influenced to the book-to-market in stock market. Besides, it is worth to say that some correlation values are significantly negative. The negative correlations lead to less variation forecast.

Table 3: correlation matrix of RSR forecast

d.p e.p d.e svar b.m ntis tbl lty ltr tms dfy dfr infl ik

(17)

3.2.3 Regime Identification

(18)

There are two conditions of two regime model, low-volatility regime(L) and high-volatility(H) regime as the introduction of Π. The identify results for fourteen predictive variables(except d/y which has only one regime)

As Figure 1 indicates, it obviously classifies two regimes in each variable estimation from time period 1947:1 to 2008:4 quarterly data. The shaded part is the suggested regime status at that time period and the value on y-axis indicates the probability of being status with low-volatility. To understand the meaning more clearly, take e.p variable as an example(other plots are shown in Appendix):

Figure 2: e.p classification of Regime

Figure 2 shows the e.p estimation trend with time. The shaded area representsbxi,t−1> 0.5,

(19)

to have status H in the stock market.

In my case, as far as e.p concerned, there are mainly three shaded part in Figure 2 around 104-110, 216-224 and 240-248 on x-axis, which are corresponding to time period 1973:1-1974:2, 2001:1-2003:1 and 2008:1-2008:4.

Link with the historical real economic status, there are three financial crisis during these three time periods. For example, the oil crisis broke out in 1973 as the result of Middle East War, and the surging in crude oil price influenced the economic growth(GDP) fell all around the world. Besides, 2007-2009 is the most famous financial crisis, which is from secondary housing credit crisis in real estate industry resulting in lots of financial institutions went bankrupt and were taken over by government. The whole world experienced a serious economic recession during that period.

Therefore, it shows the regime identification of the variables can successfully connect with the real historical events and financial status. It gives us the idea that when predicting the stock returns, economic status is an important factor needed to be taken into account. And the regime identification results by EM algorithm prove out to be reasonable. As a result, I will do predictions for the next part.

3.2.4 Forecast Result

For this part, I first compare the performance of different models to get a better one and then extend the discussion to longer time horizons.

(1) 1-quarter-ahead forecasting

From the result shown in table 4, there are positive and negative R2. In out-of-sample R2, positive value means the forecasters’ average from regime-switching model has smaller mean square error(MSE) than historical ones.

(20)

Table 4: 1-step-ahead forecast for LR and RSR model

predictive variable R2

OOS predictive variable R2OOS

LR model d.p −3.01 lty −0.14 e.p −1.54 ltr 0.00 d.e −0.05 tms −0.09 svar −0.13 dfy 0.02 b.m −0.22 dfr −0.02 ntis −0.06 infl −0.18 tbl −0.19 ik −3.26 RSR model d.p −0.17 lty −0.07 e.p −0.12 ltr −0.06 d.e −0.41 tms −0.04 svar −0.40 dfy 0.02 b.m −0.10 dfr −0.02 ntis −0.16 infl −0.10 tbl −0.15 ik −0.06

Further, only depending on R2OOSis not enough to evaluate one model superior to another, so it is also important to check the trend plot.

(21)

Figure 4: comparison of RSR predictors and the true values

Figure 3 shows the time series trends of LR forecasts from fourteen predictive variables with the colored lines. Besides, the true value from the out-of-sample part(201-248) of the data is the black line in the plot. From the plot, we can observe that the trend of predictors are flat. Among the 14 variables, three of them are far away from the true value while the other 11 have the flat trend and the predictive values are around the actual mean value.

Figure 4 indicates the time series trends of RSR forecasts in colored lines. There are no abnormal predictive variable results and each variable seems close to the mean of true average. It is worth to mention that the general trend fluctuations of the predictors and the actual values keep almost consistent. Interestingly, some predictors successfully forecast the trend of the last decline trend.

Therefore, from R2OOSthere is not such a big different performance between two models as the results of using average value when computation. However, from the plot we can get the conclusion that the RSR prediction power is superior to LR. As a result, next step, I want to discuss the situation at longer horizon, that is whether there are differences related to forecast steps ahead. Generally speaking, 4-quarter-ahead and 8-quarter-ahead forecasting are suitable.

(2) 4-quarter-ahead and 8-quarter-ahead forecasting

In table 5, we can see the result of out of sample R2 of 4-quarter-ahead and 8-quarter-ahead forecasting. The out-of-sample size is determined by both the in-sample set and the forecast steps. Thus out-of-sample size of 4-quarter-ahead is 45 and 8-quarter-ahead is 41. There are 7 forecast R2

OOS of 4-quarter-ahead is larger than 8-quarter-ahead. It is interesting that all

(22)

performs better only compare these two status.

Table 5: 4-and 8-quarter-ahead excess stock return forecast

predictive variable R2OOS predictive variable R2OOS

4-quarter-ahead d.p −0.180 lty −0.086 e.p −0.122 ltr −0.112 d.e −0.229 tms −0.049 svar −0.448 dfy −0.012 b.m −0.128 dfr −0.030 ntis −0.167 infl −0.035 tbl −0.076 ik −0.009 8-quarter-ahead d.p −0.222 lty −0.080 e.p −0.079 ltr −0.025 d.e −0.260 tms −0.040 svar −0.533 dfy −0.023 b.m −0.150 dfr −0.096 ntis −0.113 infl −0.100 tbl −0.067 ik −0.004

(23)

Figure 5: comparison of 4-quarter-ahead predictors and the true values

Figure 6: comparison of 8-quarter-ahead predictors and the true values

(24)

3.3

Application 2

For this section, I use the methods above into different data set which I choose the similar stock index in Sweden. The target is to check whether the regime switching model still works when using a different sample. Further, discuss the forecast horizon to compare the result with the conclusion in the previous part.

3.3.1 Description Result

In table 6, we can observe the regime identify in the second column, which d/p, d/y and infl are suitable to predict in linear regression not using two-regime RSR model. The values of β of these three regressions are not significant at 95% significant level.

Besides, the other three predictors are using two regimes model IIG, which need to switch intercept, slope and standard error in different regimes. I choose the model by the smallest AIC. It is worth to say that all the coefficients are significant at 99% significant level in these three RSR models. In the forecast part, I will only consider three predictors with two regimes: d/y, lty and tms.

Table 6: Regime Switching Models using Swedish Data

(25)

3.3.2 Forecast Result (1) 1-quarter-ahead

Table 7 shows the R2OOS for LR models and RSR models in one-quarter-ahead forecast. As for R2

OOS, the bigger it is, the better prediction performs. The R2OOS of RSR model are larger

than LRs’. What’s more, there are four models have negative ROOS2 that means the forecasting average is larger than historical average.

Table 7: One-quarter-ahead forecast for Swedish Data

predictive variable R2

OOS predictive variable R2OOS

LR model RSR model

d.y −21.74 d.y −4.65

lty −1.90 lty 0.71

tms −3.76 tms 0.50

Further, it is need to check the prediction behaviour in the time series plot.

(26)

Figure 8: RSR prediction behaviour for Swedish data

In Figure 7, the LR model predictors are flat and almost parallel. There are no obvious trend compared with the actual value that is no prediction value on the excess stock returns using these model.

In contrast, there are two models keep the consistent trend with the true values as are plotted in Figure 8. And the predictor d/y in red line does not perform well in the middle while it keeps the similar trend after 60 forecasters. Interestingly, all the three model shows upper trend which have the same trend as actual esr goes, indicating the prediction value on the next time period.

All in all, it shows the same conclusion as the previous part that the RSR models are more suitable to predict in one-quarter-ahead situation. Then compare the results of 4- and 8-quarter-ahead process.

(2) 4 and 8-quarter-ahead

Table 8 presents the 4-quarter-ahead and 8-quarter-ahead out-of-sample predict result for three predictive variables. From the result, we can see that each R2

OOS in 4-quarter-ahead is larger

than 8-quarter-ahead within the same parameter. Besides, when taking the one-quarter-ahead into account, all the R2

OOS values are bigger than what in 4-quarter-ahead status. Therefore, it

(27)

Table 8: 4- and 8-step-ahead forecast for Swedish Data

predictive variable R2

OOS predictive variable R2OOS

4-quarter-ahead 8-quarter-ahead

d.y −5.84 d.y −8.02

lty 0.51 lty 0.04

tms 0.18 tms −0.61

4

Conclusion

For this study, I predict the excess stock returns in both US and Sweden by basic predictive regression and regime-switching regression, considering the regime uncertainty and real eco-nomic status uncertainty. I find that regime-switching regression improve the forecast perfor-mance, which indicate taking different economic status into account is important when predict the excess stock returns.

Besides, when comparing the regime identify results and matching the real history events in the financial market, I find the regime with high-volatility always come along with reces-sion status, for example, the financial crisis in 2008. It confirms that only using one regime model(linear model) to predict stock returns is not enough.

Further more, when using the regressions to predict excess stock return by out-of-sample forecasting, it shows the regime-switching regression performs better than basic predictive re-gression. And the shorter horizons have more accurate prediction. To be more specific, 4-quarter-ahead forecasts is better than 8-4-quarter-ahead ones, which is easy to understand because the closest historical data contribute more accurate information to predict the next step.

(28)

do the regime switching model and extend the method to another application study.

For future studies, using more accurate methods to identify regime models is a good idea since considering economic status proved to be important. In the report I use "MSwM" pack-age with EM algorithm which mainly uses maximum likelihood estimation, while I am also interested in using deep learning methods to extract features of the time series data. There are mainly two models that are popular in this area, Recurrent reinforcement learning and Regimes Switching Recurrent reinforcement learning. It must be interesting to compare the regime identify accuracy and explanatory effect among the basic model and these two machine learning model.

(29)

5

Acknowledgement

(30)

References

[1] Zhu, X. Zhu, J. 2013, "Predicting stock returns: A regime-switching combination ap-proach and economic links", Journal of Banking and Finance, vol. 37, no. 11, pp. 4120-4133.

[2] Welch, I. Goyal, A. 2008, "A Comprehensive Look at the Empirical Performance of Equity Premium Prediction", The Review of Financial Studies, vol. 21, no. 4, pp. 1455-1508.

[3] Rapach, D.E., Strauss, J.K. Zhou, G. 2010, "Out-of-Sample Equity Premium Predic-tion: Combination Forecasts and Links to the Real Economy", The Review of Financial Studies, vol. 23, no. 2, pp. 821-862.

[4] Waldenstrom, D. 2014, Swedish stock and bond returns, 1856â2012: Elektronisk resurs, , Uppsala.

[5] Goyal, A. Welch, I. 2003, "Predicting the Equity Premium with Dividend Ratios", Man-agement Science, vol. 49, no. 5, pp. 639-654.

[6] Maringer, D., Maringer, D., Ramtohul, T. Ramtohul, T. 2012, "Regime-switching re-current reinforcement learning for investment decision making", Computational Manage-ment Science, vol. 9, no. 1, pp. 89-107.

[7] Cao, J. Wang, J. 2019, "Stock price forecasting model based on modified convolution neural network and financial time series analysis", International Journal of Communica-tion Systems, vol. 32, no. 12, pp. e3987-n/a.

[8] Chi, W.L. 2018, "Stock price forecasting based on time series analysis", AIP Conference Proceedings, vol. 1967, no. 1.

[9] Merton, R.K. Storer, N.W. 1973, The sociology of science: theoretical and empirical investigations, Univ. of Chicago Pr, Chicago.

(31)

[11] Wang, T. Wei, J. 2019, "Meanâvariance portfolio selection under a non-Markovian regime-switching model", Journal of Computational and Applied Mathematics, vol. 350, pp. 442-455.

[12] Shi, Y. Ho, K. 2015, "Long memory and regime switching: A simulation study on the Markov regime-switching ARFIMA model", Journal of Banking and Finance, vol. 61, pp. S189-S204.

[13] Guidolin, M. Timmermann, A. 2008, "International Asset Allocation under Regime Switching, Skew, and Kurtosis Preferences", The Review of Financial Studies, vol. 21, no. 2, pp. 889-935.

[14] Ward, G., Hastie, T., Barry, S., Elith, J. Leathwick, J.R. 2009, "Presence-Only Data and the EM Algorithm", Biometrics, vol. 65, no. 2, pp. 554-563.

[15] Tang, X., Hu, F. Wang, P. 2018, "Outâofâsample equity premium prediction: A scenario analysis approach", Journal of Forecasting, vol. 37, no. 5, pp. 604-626.

[16] Pettenuzzo, D., Timmermann, A. Valkanov, R. 2014, "Forecasting stock returns under economic constraints", Journal of Financial Economics, vol. 114, no. 3, pp. 517-553. [17] Bradshaw, M.T., Richardson, S.A. Sloan, R.G. 2006, "The relation between corporate

financing activities, analystsâ forecasts and stock returns", Journal of Accounting and Economics, vol. 42, no. 1, pp. 53-85.

(32)

6

Appendix

6.1

Time Series Plots for Different Variables

Figure 9: d.p classification of Regime

(33)

Figure 11: svar classification of Regime

(34)

Figure 13: ntis classification of Regime

(35)

Figure 15: lty classification of Regime

(36)

Figure 17: tms classification of Regime

(37)

Figure 19: dfr classification of Regime

(38)

Figure 21: ik classification of Regime

6.2

R code

Application 1 library(tidyverse) library(forecast) library(dplyr) library(MASS) library(MSwM) library(ggplot2) ori_data <- as.tibble(read.csv( "C:\\Users\\Administrator\\Desktop\\modeldata.csv")) data <- as.matrix(ori_data) #Markov-Switching model

(39)

dp_MS <- msmFit(dp, k = 2, sw = c(T,F,T),control=list(parallel=FALSE)) summary(dp_MS)

plotProb(dp_MS, which = 1)

dy <- lm(esr ~ d.y, data = ori_data) summary(dy)

ep <- lm(esr ~ e.p, data = ori_data) summary(ep)

ep_MS <- msmFit(ep, k = 2, sw = c(F,T,T)) summary(ep_MS)

plotProb(ep_MS, which = 2)

de <- lm(esr ~ d.e, data = ori_data) summary(de)

de_MS <- msmFit(de, k = 2, sw = c( T,T,T), control=list(parallel=FALSE))

summary(de_MS)

plotProb(de_MS, which = 2)

svar <- lm(esr ~ svar, data = ori_data) summary(svar)

svar_MS <- msmFit(svar, k = 2, sw = c(T,T,T)) summary(svar_MS)

plotProb(svar_MS, which = 1) plotProb(svar_MS, which = 2)

bm <- lm(esr ~ b.m, data = ori_data) summary(bm)

bm_MS <- msmFit(bm, k = 2, sw = c(T,F,T)) summary(bm_MS)

(40)

ntis <- lm(esr ~ ntis, data = ori_data) summary(ntis)

ntis_MS <- msmFit(ntis, k = 2, sw = c(T,T,T)) summary(ntis_MS)

plotProb(ntis_MS, which = 2)

tbl <- lm(esr ~ tbl, data = ori_data) summary(tbl)

tbl_MS <- msmFit(tbl, k = 2, sw = c(T,F,T)) summary(tbl_MS)

plotProb(tbl_MS, which = 1)

lty <- lm(esr ~ lty, data = ori_data) summary(lty)

lty_MS <- msmFit(lty, k = 2, sw = c(T,T,T)) summary(lty_MS)

plotProb(lty_MS, which = 1)

ltr <- lm(esr ~ ltr, data = ori_data) summary(ltr)

ltr_MS <- msmFit(ltr, k = 2, sw = c(F,T,T)) summary(ltr_MS)

plotProb(ltr_MS, which = 1)

tms <- lm(esr ~ tms, data = ori_data) summary(tms)

tms_MS <- msmFit(ep, k = 2, sw = c(F, T, T)) summary(tms_MS)

plotProb(tms_MS, which = 2)

(41)

summary(dfy)

dfy_MS <- msmFit(dfy, k = 2, sw = c(F, T, T)) summary(dfy_MS)

plotProb(dfy_MS, which = 1)

dfr <- lm(esr ~ dfr, data = ori_data) summary(dfr)

dfr_MS <- msmFit(dfr, k = 2, sw = c(F, F, T)) summary(dfr_MS)

plotProb(dfr_MS, which = 1)

infl <- lm(esr ~ infl, data = ori_data) summary(infl)

infl_MS <- msmFit(infl, k = 2, sw = c(T,T,T)) summary(infl_MS)

plotProb(infl_MS, which = 2)

ik <- lm(esr ~ ik, data = ori_data) summary(ik)

ik_MS <- msmFit(ik, k = 2, sw = c(F, F,T)) summary(ik_MS)

plotProb(ik_MS, which = 2)

# compute out of sample R2

MSForecast <- function(var, sw, winsize, stepsize){ pred = rep(0, 248-winsize-stepsize + 1)

for(iter in 1:(248-winsize-stepsize+1)){ model <- lm(formula(paste0("esr~", var)), data = ori_data[iter:(iter+winsize-1),]) MS <- msmFit(model, k=2, sw=sw,

(42)

mu1 <- MS@Coef[1,1] beta1 <- MS@Coef[1,2] mu2 <- MS@Coef[2,1] beta2 <- MS@Coef[2,2] tranmat <- diag(2) for(jter in 1:stepsize){

tranmat <- tranmat %*% MS@transMat }

train <- data[iter+winsize-1, var]

pp <- MS@Fit@smoProb[winsize,] %*% tranmat p1 <- pp[1]

p2 <- pp[2]

(43)

"tms", "dfy", "dfr", "infl", "ik" ) ss = list(c(T,F,T), c(F,T,T), c(T,T,T), c(T,T,T), c(T,F,T), c(T,T,T), c(T,F,T), c(T,T,T), c(F,T,T), c(F,T,T), c(F,T,T), c(F,F,T), c(T,T,T), c(F,F,T)) #one-step forecast winsize = 200 stepsize = 1 pred = NULL for(iter in seq_along(vv)){

pred = cbind(pred, MSForecast(var=vv[iter],

sw=ss[[iter]], winsize=winsize,stepsize=stepsize)) }

(44)

pred

actual = data[(winsize+stepsize):248,2] matplot(cbind(actual, pred), type=’l’)

#model 1 BRSC

SSE = colSums((pred - actual)**2) SST = sum((actual - mean(actual))**2) OOS_RSR = 1 - SSE/SST

library(stargazer) stargazer(OOS_RSR)

#LR forecast

lmForecast <- function(var, winsize, stepsize){ lm_pred = rep(0, 248-winsize-stepsize + 1) for(iter in 1:(248-winsize-stepsize+1)){

model <- lm(formula(paste0("esr~", var)), data = ori_data[iter:(iter+winsize-1),]) mod <- summary(model)

mu <- mod$coefficients[1,1] beta <- mod$coefficients[1,2]

(45)

lm_pred = NULL

for(iter in seq_along(vv)){

lm_pred = cbind(lm_pred, lmForecast(var=vv[iter], winsize=winsize,stepsize=stepsize))

}

colnames(lm_pred)=vv lm_pred

lm_actual = data[(winsize+stepsize):248,2] matplot(cbind(lm_actual, lm_pred), type=’l’)

#BRSC for lm

lm_SSE = colSums((lm_pred - lm_actual)**2) lm_SST = sum((lm_actual - mean(lm_actual))**2) lm_OOS = 1 - lm_SSE/lm_SST stargazer(lm_OOS) #####RSR 4-quarter ahead winsize4 = 200 stepsize4 = 4 rsr_pred4 = NULL for(iter in seq_along(vv)){

rsr_pred4 = cbind(rsr_pred4, MSForecast(var=vv[iter], sw=ss[[iter]], winsize=winsize4,stepsize=stepsize4))

}

colnames(rsr_pred4)=vv rsr_pred4

(46)

#RSR 4-quarter ahead R2 BY BRSC

rsr_SSE4 = colSums((rsr_pred4 - actual4)**2) rsr_SST4 = sum((actual4 - mean(actual4))**2) RSR_OOS4 = 1 - rsr_SSE4/rsr_SST4

stargazer(RSR_OOS4)

##lm 4-quarter ahead forecast lm_pred4 = NULL

for(iter in seq_along(vv)){

lm_pred4 = cbind(lm_pred4, lmForecast(var=vv[iter], winsize=winsize4,stepsize=stepsize4))

}

colnames(lm_pred4)=vv lm_pred4

matplot(cbind(actual4, lm_pred4), type=’l’)

#BRSC for lm4

(47)

pred8 = cbind(pred8, MSForecast(var=vv[iter], sw=ss[[iter]], winsize=winsize8,stepsize=stepsize8)) } colnames(pred8)=vv pred8 actual8 = data[(winsize8+stepsize8):248,2] matplot(cbind(actual8, pred8), type=’l’)

#RSR 8-quarter ahead R2

SSE8 = colSums((pred8 - actual8)**2) SST8 = sum((actual8 - mean(actual8))**2) OOS_BRSC8 = 1 - SSE8/SST8

stargazer(OOS_BRSC8)

##lm 8-quarter ahead forecast lm_pred8 = NULL

for(iter in seq_along(vv)){

lm_pred8 = cbind(lm_pred8, lmForecast(var=vv[iter], winsize=winsize8,stepsize=stepsize8))

}

colnames(lm_pred8)=vv lm_pred8

matplot(cbind(actual8, lm_pred8), type=’l’) ##

#BRSC for lm8

lm_SSE8 = colSums((lm_pred8 - actual8)**2) lm_SST8 = sum((actual8 - mean(actual8))**2) lm_OOS8 = 1 - lm_SSE8/lm_SST8

(48)

Application 2

ori_data <- as.tibble(read.csv

("C:\\Users\\Administrator\\Desktop\\swedata.csv")) data <- as.matrix(ori_data)

#Markov-Switching model

DP <- lm(esr ~ dp, data = ori_data) summary(DP)

DY <- lm(esr ~ d.y, data = ori_data) summary(DY)

DY_MS <- msmFit(DY, k = 2, sw = c(T,T,T)) summary(DY_MS)

plotProb(DY_MS, which = 1)

TBL <- lm(esr ~ tbl, data = ori_data) summary(TBL)

TBL_MS <- msmFit(TBL, k = 2, sw = c(T,T,T)) summary(TBL_MS)

plotProb(TBL_MS, which = 1)

LTY <- lm(esr ~ lty, data = ori_data) summary(LTY)

LTY_MS <- msmFit(LTY, k = 2, sw = c(T,T,T)) summary(LTY_MS)

plotProb(LTY_MS, which = 1)

TMS <- lm(esr ~ tms, data = ori_data) summary(TMS)

TMS_MS <- msmFit(TMS, k = 2, sw = c( T,T,T)) summary(TMS_MS)

(49)

INFL <- lm(esr ~ infl, data = ori_data) summary(INFL)

# compute out of sample R2

MSForecast <- function(var, sw, winsize, stepsize){ pred = rep(0, 475-winsize-stepsize + 1)

for(iter in 1:(475-winsize-stepsize+1)){ model <- lm(formula(paste0("esr~", var)), data = ori_data[iter:(iter+winsize-1),]) MS <- msmFit(model, k=2, sw=sw, control=list(parallel=FALSE)) mu1 <- MS@Coef[1,1] beta1 <- MS@Coef[1,2] mu2 <- MS@Coef[2,1] beta2 <- MS@Coef[2,2] tranmat <- diag(2) for(jter in 1:stepsize){

tranmat <- tranmat %*% MS@transMat }

train <- data[iter+winsize-1, var]

pp <- MS@Fit@smoProb[winsize,] %*% tranmat p1 <- pp[1]

p2 <- pp[2]

pred[iter] <- (mu1 + beta1*train)*p1 + (mu2 + beta2*train)*p2 }

(50)

vv = c("d.y", "lty", "tms" ) ss = list(c(T,T,T), c(T,T,T), c(T,T,T)) #one-step forecast winsize = 380 stepsize = 1 pred1 = NULL for(iter in seq_along(vv)){

pred1 = cbind(pred1, MSForecast(var=vv[iter],

sw=ss[[iter]], winsize=winsize,stepsize=stepsize))

}

colnames(pred1)=vv pred1

actual = data[(winsize+stepsize):475,2] matplot(cbind(actual, pred1), type=’l’)

SSE = colSums((pred1 - actual)**2) SST = sum((actual - mean(actual))**2) OOS_RSR = 1 - SSE/SST

stargazer(OOS_RSR)

#LR forecast

(51)

lm_pred = rep(0, 475-winsize-stepsize + 1) for(iter in 1:(475-winsize-stepsize+1)){

model <- lm(formula(paste0("esr~", var)), data = ori_data[iter:(iter+winsize-1),]) mod <- summary(model)

mu <- mod$coefficients[1,1] beta <- mod$coefficients[1,2]

train <- data[iter+winsize-1, var] lm_pred[iter] <- mu + beta*train } return(lm_pred) } #lm one-step forecast lm_pred = NULL for(iter in seq_along(vv)){

lm_pred = cbind(lm_pred, lmForecast(var=vv[iter], winsize=winsize,stepsize=stepsize))

}

colnames(lm_pred)=vv lm_pred

matplot(cbind(actual, lm_pred), type=’l’)

(52)

sw_rsr_pred4 = NULL for(iter in seq_along(vv)){ sw_rsr_pred4 = cbind(sw_rsr_pred4, MSForecast(var=vv[iter], sw=ss[[iter]], winsize=winsize4,stepsize=stepsize4)) } colnames(sw_rsr_pred4)=vv sw_rsr_pred4 swactual4 = data[(winsize4+stepsize4):475,2]

matplot(cbind(swactual4, sw_rsr_pred4), type=’l’)

#RSR 4-quarter ahead R2 BY BRSC

(53)

swactual8 = data[(winsize8+stepsize8):475,2]

matplot(cbind(swactual8, sw_rsr_pred8), type=’l’)

#RSR 4-quarter ahead R2 BY BRSC

sw_rsr_SSE8 = colSums((sw_rsr_pred8 - swactual8)**2) sw_rsr_SST8 = sum((swactual8 - mean(swactual8))**2) sw_RSR_OOS8 = 1 - sw_rsr_SSE8/sw_rsr_SST8

References

Related documents

The results which have been found with a 10 % significance level, but there still needs to exist an understanding that the results are not facts. As the tests within an event study

In the cross section, I find that firms which borrow from high-leverage financial intermediaries have on average 4% higher risk-adjusted annualized returns relative to firms

Ferm, L., Gustavsson, M., Persson Thunqvist, D., Svensson, L., (2017), Students' strategies for learning identities as industrial workers in a Swedish upper secondary school

30 Mål nr PMT 11949-16; KO./. Kissie Media Sweden AB m.fl.. näringsidkaren, handlar å dennes vägnar eller någon annan som väsentligt har bidragit till marknadsföringen. Med andra

Another study examining autoregressive models to predict European stock indices found that while the performance using the past 1 to 10 days return was generally poor, it improved

Similarly, for the interest rate regressions, the standard short-run fixed effects estimate is used rather than the pooled estimator for recursively demeaned data since

Ytterligare en skillnad är dock att deras studie även undersöker hur sentiment påverkar specifika aktie segment, det gör inte vår studie, vilket leder till att det

These results, together with earlier confirmed research on the positive correlation between liquidity and analyst coverage implies that firms with low liquidity and market value