Stock Trading Using PE ratio: A Dynamic Bayesian Network Modeling on Behavioral Finance and Fundamental Investment
Abstract
On a daily investment decision in a security market, the price earnings (PE) ratio is one of the most widely applied methods being used as a firm valuation tool by investment experts. Unfortunately, recent academic developments in financial econometrics and machine learning rarely look at this tool. In practice, fundamental PE ratios are often estimated only by subjective expert opinions. The purpose of this research is to formalize a process of fundamental PE estimation by employing advanced dynamic Bayesian network (DBN) methodology. The estimated PE ratio from our model can be used either as a information support for an expert to make investment decisions, or as an automatic trading system illustrated in experiments. Forwardbackward inference and EM parameter estimation algorithms are derived with respect to the proposed DBN structure. Unlike existing works in literatures, the economic interpretation of our DBN model is welljustified by behavioral finance evidences of volatility. A simple but practical trading strategy is invented based on the result of Bayesian inference. Extensive experiments show that our trading strategy equipped with the inferenced PE ratios consistently outperforms standard investment benchmarks.
Keywords: Bayesian Inference, Dynamic Bayesian Network, Fundamental Investment, PE Ratio, Behavioral Finance
1 Introduction
With the rapid advancement of machine learning technology, recent works make attempts to incorporate these machine learning techniques to construct trading systems that support decisions of investors in security markets [1, 2, 3, 4, 5, 6] (see also references therein). These recent works have the following common philosophical theme.
Common Philosophy of Applying Machine Learning to Financial Data:
There exist hidden patterns in financial time series. Complicated techniques (and their combinations) such as support vector machine, multiple kernel learning, independent component analysis, hidden Markov models, fuzzy modeling and so on, can help investors discover hidden patterns represented by complicated mathematical formulas. The retrieved formulas can be used as forecasting rules to predict stock’s directional movements, which in turn can be incorporated into investor’s trading strategy (buy low and sell high, as predicted by the rules) to make an excess return in the market.
Based on the same philosophy mentioned above, existing works, however, have common limitations. Firstly, the discovered patterns are so complicated (highly nonlinear) and lacked of financial interpretation; note that, in general, higher degree of pattern complexities are more risky to overfit the training data [7]. Secondly, each financial timeseries has to be trained separately, resulting in one set of distinct patterns for each different security. In other words, there is no common pattern in the data of interested securities. Thirdly, because of pattern complexities, practical trading implementations are not easy for some investors. In fact, sophisticated trading program has to be constructed by users themselves. Lastly, there is no direct way to incorporate existing expert information (such as professional security analysts’ recommendations) into the learning system. Fairly speaking, although having the mentioned limitations, the core philosophy of existing research matches the philosophy of one certain investor group called technical analysts [8, 9]. Technical analysts believe in price patterns and do not pay much attention to economic interpretation of the patterns. Therefore, this line of existing research may benefit this group of investors.
On another side of investment practitioners, there is a group named fundamentalists whose trading strategies have clear financial interpretations and are based on welldefined financial information [10, 11, 12]. Priceearning ratio (simply called PE ratio, to be defined below shortly) is one of the most widely applied valuation toolkits for fundamentalists to make their investment decisions [11, 13]. Also, investment recommendations by security analysts are often based on PE ratios [14]. Nevertheless, it is unfortunate that recent academic advancements in financial econometrics and machine learning rarely look at this tool so that the current practical application of PE ratio has to depend solely on expert knowledge. To our knowledge, there is currently no formal framework capable of integrating expert knowledge with historical financial timeseries data to make a systematic inference of PE ratio from available information.
In this research, we focus on applying a Bayesian statistical analysis to formalize the process of stock valuation using the PE ratio. We apply the powerful framework of dynamic Bayesian network [7, 15] to model the valuation process. In contrast to existing machine learning frameworks mentioned above on price pattern discovery where the discovered patterns have no meaning in finance, the interpretation of our model is well justified according to behavioral finance [16] as explained in the Section 2. The main contributions of our work are threefold. Firstly, to our knowledge, we are the first to propose applying the machine learning framework to formalize the PE ratio valuation process which somehow rarely gets attention from academic researchers. Secondly, unlike existing works where there are different discovered patterns for different securities, our proposed trading strategy resulted by the Bayesian framework is unified, i.e. we propose a single trading strategy which can be applied to every security as explained in Subsection 1.1. The proposed strategy is simple and has a clear financial interpretation so that it can be easily applied by every practitioner (no requirement on writing a sophisticated system trading program). Moreover, expert opinions can be naturally integrated to our Bayesian learning framework. Thirdly, as our proposed dynamic Bayesian network having nonstandard structure compared to literatures [7, 15], we have successfully derived the new inference formulas by applying the forwardbackward methodology, and the new parameter estimation algorithm according to the concept of ExpectationMaximization [7, 15].
Note that in this paper, we focus on investment in individual firmlevel securities which are usually preferred by individual investors; in contrast to investment institutions whose investment strategy is usually on portfolio level based on Modern Portfolio Theory [17].
1.1 Background of fundamental investment based on PE ratio
The core idea of the PE ratio valuation method is simply that the value of the firm (and hence the value of its stock) is directly proportional to the annual net income (also called earning) of the company, i.e. for each firm ,
(1) 
where denotes the value of firm , denotes the firm’s current annual earnings and is the firm’s appropriate PE ratio, usually assumed to be a constant (at least for some period of time). Here, the annual earning is defined by the summation of the latest four quarterly earnings. The earnings information of each firm listed in the stock market is normally available to all investors, i.e., it is observable.
The PE ratio, intuitively, can be thought of as a premium of an individual firm, i.e., given the same earning for two firms, the firm with higher PE ratio is considered to be of higher value. Conceptually, the appropriate PE ratio of each firm is usually determined by experts using business and financial accounting factors such as debt burden, cash flow, growth rate, business risk, etc. There exists an alternative approach to estimate the PE ratio called the relative approach [11] which still requires experts to select a group of similar firms altogether, and the ratio is heuristically calculated from this group. To summarize, the current best practice for PE ratio estimation is to be heuristically calculated by experts or experienced investors.
Once we get the PE ratio, we can simply calculate firm value, often called intrinsic value, by Eq.(1). A simple trading strategy is to compare the firm value with a market price of the firm.
Strategy A: if the firm value is higher than its market price by some threshold, it is considered to be at low price, so that we can buy the firm’s stock. We expect to sell it later when its market price is higher than the firm’s intrinsic value by some threshold.
It is important to note that the philosophy of this trading strategy is that market price is not always equal to the value of the firm. We can observe that the price of firm’s stock changes almost every working day in a stock market. In contrast, by Eq. (1), the firm’s value will not change in a short time period provided that there is no new announcement on annual earnings in that period. There has been long controversy about this âprice vs. valueâ issue [10], but it is beyond the scope of this paper. In any cases, it is a fact that there exists a large group of individual investors namely fundamentalists employing the PE ratio as their main tool. Instead of solely relying on expert opinions, the goal of this paper is to support that group of investors to systematically determine the appropriate PE ratio, by the method of Bayesian statistical analysis which is able to formally combine information from historical data with expert beliefs.
Finally, we emphasize that there is another quantity called an observed PE calculated from firm’s current market price divided by its earnings (note again difference between value and price ), that is,
(2) 
where is the current market price of a firm . In Bayesian analysis of the PE ratio, it is important to distinguish between the observed (changing everyday due to changes of ) and . Here we will call as the fundamental PE ratio. The reason behind this name is the following: only a group of fundamentalists believe that the quantity , or firm value, is able to calculated by Eq. (1). Therefore, they usually call as the fundamental price or fundamental value, and so as fundamental PE. To them, there exist various kinds of investors in the market: some are rational and some are irrational. The current market price and hence, too, the observed can fluctuate from the fundamental price by actions of those irrational investors. We shall formally model this argument in Section 2.
2 Statistical model of stock price dynamics
2.1 Motivation of statistical modelling: behavioral volatility
In Subsection 1.1 we mentioned about fundamentalists’ belief that market price of a security may not equal to its fundamental value. Why does stock price deviates from its fundamental price? Works on behavioral finance [16] found many evidences for this question. For example, researchers argue that there are noise traders in the market who tend to make irrational actions so the price can move away from its value [18, 19, 20]. One of the works found that some investors cannot process new information correctly and so overreact to new information [21]. What is worse, information which investors overreact is, many times, unconfirmed [22] or unreliable [23, 24] or even unimportant [25, 26]. Also, investors who consult experts may not get much helpful advice since security analysts tend to be overoptimistic [27] and having conflict of interest [28]. Finally, it is well known that even rational investors in the market cannot immediately eliminate this irrational pricing due to limit of arbitrage [29]. All the effects mentioned here are able to temporarily move away a stock price from its value for a period of time. This is what we call behavioral volatility. The effects continue until either they are cancelled out, or rational investors finally eliminate this mispricing. This reversion phenomena is called mean reversion in literatures.
2.2 Dynamic Bayesian Network of stock price movement
Our model simplifies and formalizes the observations described in Subsection 2.1. We divide the temporary effects which cause mispricing into two categories: (1) shortterm effects: mispricing effects which last about a few days, e.g. effects causing by noise trading or overreaction to unreliable information and (2) mediumterm effects : mispricing effects which last several weeks or months, e.g. effects caused by reaction to unconfirmed information which may take time to confirm, or overoptimistic prediction of analysts which may take time to prove. Mathematically, the relation between market price and its fundamental value can be described as the following equation. To simplify the equation, since we consider only one firm at a time, we now replace the firmindex subscript with a timeindex subscript to emphasize the dynamic relationship between price and its fundamental value.
(3) 
where
(a) is a random variable modeling the mediumterm noisy effects. To make its effects persist for a period of time, we model as a Markov chain.
(b) is a random variable for the shortterm noisy effects which is modeled by a Gaussian random noise, .
Assuming as a constant for the period which we observed, and following Eq. (1) of Section 1, we have
(4) 
and, therefore, we get the relationship between the fundamental PE and the observed PE:
(5) 
Note that our model is suitable only for a firm with positive earnings . Fortunately, most firms satisfy this criterion. Eq. (5) is central to our idea and can be visualized as shown in Figure 1.
We can mathematically simplify Eq. (5) further
(6) 
Since is usually small, it can be approximated by , and denote , we then have
(7) 
Note that as explained in Section 1, is an observable quantity, while and are unobservable, i.e. they are hidden state or latent variables. Note that these are two different types of latent variables, i.e. is constant and is timevarying. Thus, Eq. (7) is different from standard statespace and graphical models such as Hidden Markov Models or Linear State Space Model [7]. The graphical model of our proposed stock price dynamic has three layers as represented in Figure 2. In our case, where the model is temporal, the graphical model framework is also called dynamic Bayesian network (DBN). The main advantage of DBN is its ability to encode conditional independent properties, and hence simplifying probabilistic inference [15]. Another advantage of this framework is that expert knowledge can be integrated in the model naturally as shown in the next section.
To derive mathematical equations for inference and parameter estimation in the DBN framework, we shall assume that all latent random variables are discrete: , . Furthermore, we have to set up the conditional probability distribution function for each node given its parents. We define the conditional probability distribution functions of all nodes as follows:
The transition probability distribution function:
Let ,
(8) 
Note that , . The matrix is called a transition matrix, i.e. is a Markov chain.
The emission probability distribution function:
The inital probability distribution functions:
For each ,
(10) 
where and .
For each ,
(11) 
where and .
The vectors and are called initial vectors.
Therefore, in this Bayesian framework, the set of model parameters is and our parameters space is
(12) 
If we know all parameters, we can make an inference by deriving inference equations based on the forwardbackward algorithm as shown in Subsection 3.1. If the parameters are unknown, we have to estimate them first. In this paper, we derive the estimation procedures based on Maximum a Posteriori (MAP) and ExpectationMaximization (EM) algorithms. In the next section, we show how we derive both the inference and parameter estimation algorithms.
3 Bayesian inference on the DBN of stock price dynamic
As explained in previous sections, our goal is to make an inference on PE* so that we can estimate the fundamental price of a stock. In Section 4, we will show that estimations of is also useful in investment. To infer the values of these two latent variables, similar to Hidden Markov Models (HMM) and Linear State Space Model (LSSM) [7, 15], we need to derive equations in two steps. First, the inference algorithms with known parameters, second, the parameter estimation algorithms given that parameters are unknown. However, because there are two types of latent states as explained in the previous section, our graphical model shown in Figure 2 is more sophisticated than HMM and LSSM. In this section, we show the new equations for both inference tasks. To simplify the notation, we use notation to denote .
3.1 Inference with known parameters
Suppose is known, together with the observed data . Similar to HMM, in order to estimate the latent states of and , we need to find recurrent formulas to calculate two quantities: the filtering probabilities and the smoothing probabilities , . To keep our formulas simple, in this Section, we will omit writing in the probability notations, e.g., we simply write for filtering.
The filtering formula, which estimates conditional joint probabilities of the most recent mediumterm effect and given all the observed variables, is given by the following recurrent formula:
(13) 
In the above derivation, Bayes’s rule, conditional independent properties [15] with respect to DBN shown in Figure 2 and sum rule are applied consecutively to get the above result, similar to the filtering equation of HMM. The initial equation of the recurrent formula can be derived similarly: .
Next, the smoothing formula, which estimates conditional joint probabilities of the anydate mediumterm noisy effect and given all the observed variables, is given by the following socalled forwardbackward formula in Eq. (14) :
For all , (note that
(14) 
Note that conditional independent properties of our DBN are applied in the first term. Also note that the second term is in fact a filtering probability. Therefore, we need to concentrate only on the first term, which has the following recurrent relation:
(15) 
The end condition can be solved similarly
With the derived recurrent formulas, we can get the most probable values of wanted latent variables and each by using marginalization, e.g.
where . To implement both filtering and smoothing in computer program, we also need to solve the formulas for the constants appeared in the above derivations. To fulfil this task, using matrix reformulation of the above recurrent equations is the most convenient and efficient way. Below, we give only the end results because the details exceed space limitation. Derivation details can be found in the full version of this paper [30].
To get matrix formula, first denote a filtering density as . When , define and define . From Eq.(13), we then have . Define . It can be shown that . Denote the matrix , we can show that
(16) 
where denotes the entrywise (or Hadamard) product of the matrix. and W denote the emission matrix and transtion matrix, respectively, as described in Section 2. For the initial case, we have
(17) 
where u and v are as defined in Section 2. To get a matrix formula for a smoothing density, we first define
(18) 
From Eq.(14), we then have the smoothing density for
(19) 
Denote the matrix , we can show that
(20) 
and
(21) 
3.2 Inference with unknown parameters
In general situations, is unknown, so only the observed data is available. In this case, must be estimated first. Expectation Maximization (EM) is a general method capable of estimating the parameters in Maximum Likelihood and Maximum a Posteriori (MAP) problem settings for probabilistic models with latent variables [31]. Here, we formulate our parameter estimation in the MAP setting so that expert’s prior knowledge can be employed into the model. Formally, we would like to solve the following problem of maximizing the posterior pdf of .
(22) 
EM find a solution of Eq. (22) by iteratively solving the following two steps with the arbitrary set of initial parameters and a prior . Iterating from , do
EStep: Calculating smoothing probabilities ,
Mstep: Solving the constraint maximization problem,
(23) 
where
(24) 
EM repeats the two steps until converges. Note that EM guarantees to find a local maxima of Eq. (22) [7]. The argument in the expectation of Eq. (24) is simply the loglikelihood of the model:
(25) 
According to DBN, they are simply the logarithms of the emission pdf, transition pdf and initial pdf, respectively. By equation manipulations, the expectation Eq. (24) can be calculated by employing the smoothing probabilities already done in the Estep. As a result, we get a closed form of Eq. (24). Combining with the term described below, the constraint maximization Eq. (24) is well defined and readily to be solved by using the method of Lagrange multipliers [32]. All derivations details, which have the same mathematical structure for the simpler case of HMM [7], are quite long and can be found in the full version of this paper [30].
Experts can put their knowledge into the parameter estimation procedure via in Eq. (23). Here, we assume that all parameters are independent, . In our experience, investment experts usually have two types of knowledge which are useful to estimate . The first type of knowledge is about . Often, experts may be able to estimate the range of appropriate level by analyzing a firm’s business strategy together with competitions in its industry. The second type of knowledge is about the degree of persistence of the mediumterm noisy effect which makes a stock price deviates from its fundamental for a considerable amount of time as explained in Section 2. For some firms, e.g. a firm with nonexistent investor relation department, when there exist some unconfirmed rumors, its price can deviate from its fundamental for a long period. In contrast, some firms with both strong public and investor relation departments can clear up unconfirmed rumors rather quickly, so this rumor effect will not stay long. The two types of expert information can be encoded on and , respectively. The prior for the vector can be represented via the Dirichlet distribution:
(26) 
Intuitively, is a degree of belief for each possible value . Experts can employ their believes that some value of , e.g. is relatively more probable than other values by giving relatively higher value than other . See [33] for more details on the Dirichlet prior. The prior on transition matrix encoding the average persistence degree of the mediumterm noisy effect can also be described by a product of Dirichlet priors: , where as defined in Section 2, denotes a vector of a probability , and
(27) 
The persistence degree of the mediumterm effect can be set by relatively increasing the values of compared to other values . The relatively higher of , the more persistence of the mediumterm effect. Since mediumterm effect appears at random, other values can symmetrically be set: , for .
4 Experiments
In this section, we illustrate benefits of our methodology in realworld applications. To do this, we will conduct comprehensive trading simulations to show consistent superior performances of our method over standard benchmark. In literatures of Finance, according to Efficient Market Hypothesis [34, 35, 10] which is widely accepted by mainstream researchers, the gold standard benchmark is, surprisingly, the simple “buy and hold” method which empirically proves to be efficient in the long run. Astonishingly, many evidences clearly indicate that most mutual fund managers who apply complex active portfolio management techniques cannot beat the simple “buy and hold” of the market portfolio [36, 37]. In this paper, we will test our method against this gold standard “buy and hold” method both on individual stock level and on portfolio level.
4.1 Experiment setting
In this paper, we will make trading simulations in the markets of two different countries where we can access historical data: NYSE (New York Stock Exchange) and NASDAQ in US and SET (Stock Exchange of Thailand) in Thailand. While NYSE and NASDAQ represent matured stock markets, SET represents an emerging market, so that we are able to test our methodology to firms on both market phases. For each country, we collect 10 firms from various industries to ensure that our methodology is not just limited to one specific industry. Each selected firm is well established and has at least 5 year historical trading data. The names of selected companies with their respective sectors for Thai stocks and US stocks are shown in Table 1 and Table 2, respectively.
We collect daily 5year historical closingprice data for each firm (Jan 1, 2012 to Sep 30, 2016) consisting of 1160 closing prices for stocks in SET and 1195 closing prices for stocks in NYSE and NASDAQ, respectively. The difference in the number of data is due to different working days in the two countries. All data are adjusted for stock splitting and stock dividending if occuring during this 5year period. To avoid duplicated writing, here, we shall explain only experiment settings for stocks in SET with historical price .The experiment settings for stocks in NYSE and NASDAQ are done similarly.
Symbol  Industry  Size 

CPALL  RetailingFood and Staples  BigCap 
CPN 
DeveloperDepartment Stores  BigCap 
EASTW 
UtilitiesWater Resources  MidCap 
GLOW 
UtilitiesPower Plant  BigCap 
HMPRO 
RetailingHousehold Products  BigCap 
QH 
DeveloperHousing  MidCap 
ROBINS 
RetailingGeneral  MidCap 
SCB 
Banking  BigCap 
SNC 
Electrical Equipments  SamllCap 
TTW 
UtilitiesTap Water  MidCap 

Symbol  Industry  Size 

WMT  ServicesDiscount and Variety stores  
HD 
ServicesHome improvement stores  
KO 
Consumer GoodBeverages soft drinks  
G 
ServicesBusiness services  
AAPL 
Consumer GoodsElectronic equipment  
NKE 
Consumer GoodsTextileApparel Footwear and Accessories  
BK 
FinancialAsset Management  
CF 
Basic MaterialsAgricultural Chemicals  
CSCO 
Technology Networking and Communication Devices  
DIS 
ServicesEntertainment Diversified  

For each firm, the corresponding yearly earnings data in those years are also collected. are defined as the summation of the most recent 4 quarterly earnings on each data . The first 3year historical data (Jan 1,2012 to Dec 31,2014) and will be used as a training data for our Bayesian methodology to learn the appropriate parameters using the EM algorithm as well as estimate the most probable values of and by the method of smoothing as explained in Section 3. The constants and are set by experts. Since the constant determines the size of the transition matrix , we make a constraint so that the model is not overparameterized and that 3year historical data is enough to learn W. For all prior distributions, we employ noninformative priors with the exception of where our “security experts” emphasize the prior knowledge of persistency as described in Subsection 3.2.
Each trading simulation is conducted for each individual stock with the remaining 2year historical data to measure the performance of both our method and the benchmark. The performance measurement metric is, as used by practitioners, a profit generated by each method. The profit calculation is straightforward: for each trading simulation, each method is equally given an initial amount of cash to make a trade (which taken into account a commission fee), and the profit are simply all the asset values at the end of a simulation minus . For simplicity, we assume that each stock can be bought with all the money we have, e.g. supposing we have and a stock’s price is , then we are able to buy stocks.
Using the benchmark “buy and hold" strategy we simply need to buy the stock with all the cash at the beginning and then do nothing until the end. Initially, this method will get shares where represents the value of assets after taking SET’s commission fee into account. At the end of the simulation this asset will have a value of , so the profit can be calculated easily. For a trading strategy employed by our method, there are two possible versions inspired by our model’s main idea (see Figure 1) and Strategy A (buy low, sell high) described in Section 1. The first version called longterm strategy is simply to “buy low, sell high" with respect to the static value of , and the second version called mediumterm strategy is to “buy low, sell high" with respect to the dynamic values of where each is dynamically estimated by the method of filtering described in Subsection 3.2. Both versions can be formally described as follows.
Let and be available cash and total shares at date , respectively. Initially, and . Now, both trading versions can be defined simply by the following procedure: for each date , exactly one of the following cases holds:
(i) and (buylow case) where is a threshold, for the longterm strategy and for the mediumterm strategy. In this case, buy the stock with all cash, so that and .
(ii) and (sellhigh case). In this case, sell all the holding stock to get cash and .
(iii) If case (i) and case (ii) are not satisfied, do nothing. So, and . At the end of a trading simulation , the total profit is simply , so that we can compare with the "buy and hold" profit.
We give some illustrations of our trading in actions which are shown in Figure 3 and Figure 4. Figure 3 is an example of longterm trading of CPALL with threshold 0.05 and Figure 4 is an example of mediumterm trading of CPALL with threshold 0.05.
4.2 Experimental results and discussions
4.2.1 Individualfirm level experiments
To ensure that our experimental results are not biased because of a threshold choice, we test 4 different thresholds for each trading strategy. Note that the thresholds in the mediumterm trading are relatively smaller than those in the longterm. This is due to the nature of mediumterm strategy where has a smaller deviation from its base line compared to the longterm strategy’s base line, not containing the effect of . The experimental results with respect to Thai stocks and US stocks are shown in Table 3 and Table 4, respectively.
Symbol  Longterm Thresholds  Mediumterm Thresholds  Buy & Hold  
5%  10%  15%  20%  3%  5%  7%  10%  
CPALL  58.40%  38.74%  49.74%  56.42%  26.92%  42.59%  32.08%  36.34%  44.46% 
CPN  30.67%  30.67%  30.67%  30.67%  1.06%  6.39%  4.32%  14.04%  30.67% 
EASTW  9.16%  6.18%  4.29%  4.29%  10.49%  3.93%  15.07%  20.64%  9.16% 
GLOW  11.78%  11.78%  11.78%  11.78%  3.24%  14.16%  10.66%  3.13%  11.78% 
HMPRO  31.88%  47.93%  58.00%  0%  51.69%  69.87%  86.49%  8.87%  32.28% 
QH  24.08%  24.08%  24.08%  9.70%  5.73%  0.49%  4.08%  2.31%  24.08% 
ROBINS  36.28%  36.28%  36.28%  36.28%  32.70%  36.77%  45.64%  36.97%  36.28% 
SCB  17.46%  17.46%  14.10%  9.08%  11.67%  14.09%  14.74%  4.79%  17.46% 
SNC  4.45%  4.45%  7.00%  0.91%  18.46%  8.20%  8.02%  8.20%  4.45% 
TTW  0.00%  0.00%  0.00%  0.00%  1.31%  0.50%  3.67%  0%  3.73% 
Average  10.86%  10.20%  12.19%  9.62%  12.92%  12.67%  16.55%  12.90%  9.14% 
W/D/L  2/7/1  2/6/2  4/4/2  5/3/2  7/0/3  6/0/4  8/0/2  7/0/3  
13/20/7  28/0/12 
Symbol  Longterm Thresholds  Mediumterm Thresholds  Buy & Hold  
5%  10%  15%  20%  3%  5%  7%  10%  
WMT  6.07%  13.00%  23.04%  0.00%  20.47%  5.97%  12.02%  0.00%  11.98% 
HD  10.56%  28.71%  28.71%  28.71%  48.35%  40.77%  27.55%  27.48%  28.71% 
KO  6.06%  6.06%  6.06%  6.06%  20.61%  17.24%  0.00%  0.00%  6.06% 
G  5.33%  26.50%  26.50%  26.50%  37.40%  29.74%  21.22%  1.14%  26.50% 
AAPL  5.19%  5.19%  5.19%  5.19%  18.69%  22.83%  41.27%  26.84%  6.77% 
NKE  12.72%  12.72%  12.72%  12.72%  22.53%  25.00%  24.50%  32.96%  12.72% 
BK  26.36%  23.72%  1.42%  1.42%  5.52%  6.44%  3.68%  4.84%  1.42% 
CF  27.16%  15.87%  53.74%  53.74%  17.60%  16.84%  36.21%  41.05%  53.74% 
CSCO  12.00%  23.00%  20.48%  20.48%  8.42%  10.98%  14.98%  20.00%  20.48% 
DIS  0.82%  0.82%  0.82%  0.82%  14.37%  12.17%  1.45%  8.47%  0.82% 
Average  11.23%  15.56%  7.12%  4.82%  17.88%  15.43%  10.02%  6.37%  3.78% 
W/D/L  3/3/4  4/5/1  1/8/1  1/8/1  9/0/1  9/0/1  4/0/6  5/0/5  
9/24/7  27/0/13 
From the tables, we can see that in the total of 80 trading simulations on SET firms, our method results in greater performance 41 times, while “buy and hold" results in better performance 19 times (the remaining 20 times are draws). Similarly, in the total of 80 trading simulations on NYSE and NASDAQ firms, our method results in greater performance 36 times, while “buy and hold" results in better comparison 20 times (the remaining 24 times are draws). Summing up results of markets in the two countries, our method outperforms the benchmark 77 times, yet underperforms only 39 times. These are promising results where we shall analyze statistically significancy of the results more formally in the next subsection. Here, we shall firstly interpret and discuss about experimental results in Tables 3 and 4 in details.
From Tables 3 and 4, it can be seen that there are 44 draws, which occur only in the cases of the longterm trading strategy. All 44 draws happen because of the exact same reason: our model predicts of undervaluation at the beginning of the testing period. i.e. the first observed PE falls deeply below the base line (exceeding the specified threshold). After that, the observed PE is never once able to overly exceed with respect to the given threshold, i.e. is quite high in the test set so that no selling is possible. Therefore, in this case, our trading behaves exactly just like the benchmark “buy and hold". Note that there is no draw in the results of the mediumterm trading strategy. The reason is because the estimated mediumterm noisy effect makes the base line move near to the observed PE which results in more frequent trading.
Disregarding the draws, our longterm trading strategy still beats the benchmark with 22 wins versus 14 loses. This is mainly due to the volatility of the observed PE in most stocks so that our strategy of buying in an undervalued price and selling in an overvalued price with respect to is possible. However, it is not the case that trading induced from our model constantly outperforms the benchmark. For the case of the socalled growth stocks [12], i.e. stocks with consistently increasing earnings and price, it is not so easy for our model to beat the benchmark. If the threshold is set too low, our method will lead to buying and selling early, and thus results in less profit. See Figure 5 for example. If the threshold is set too high, our method may lead to buying when the price is already high or lead to doing nothing at all because it is never undervalued with respect to the specified threshold. Another special case where our method fails to beat the benchmark is when there are the socalled nonrecurring earnings, i.e. extra incomes which occur only once and should not be taken into account the calculation of fundamental value. In this case, the market knows that these extra earnings are temporary and do not give it credit, i.e. the price does not go up according to this profit. Our method has not taken this information into account and thus is fooled to believe that a stock is undervalued. See Figure 6.
On the other hand, The results of our method equipped with mediumterm trading strategy show impressive superiority, 55 wins versus 25 loses to the benchmark. The key factor of success is its tracking ability of the mediumterm noisy effect by our filtering algorithm presented in Section 3. When the new base line is predicted accurately, undervalued and overvalued prices are also accurately detected and so the probability of our profitable trading is increasing. Nevertheless, with more frequent trading, commission fees increase substantially and sometimes can significantly reduce our performance as shown in Figure 4.
4.2.2 portfolio level experiments
In this subsection, to more realistically simulate a realworld individual investor, we construct a portfolio of stocks and test its performance against the benchmark. Here, we use a ruleofthumb commonly employed in practice saying that a good portfolio should consists of around 15 stocks [38, 39] (which contradicts to the mainstream theory [40]). For individual value investors who believe they can beat the market by analyzing each firm carefully, usually, they do not feel comfortable to hold too many stocks (like stocks recommended by academic financial literatures) because investors need time to update and analyze the information of all their holding stocks.
To test the performance of a 15stock portfolio of our method against the benchmark, we employ the method of boostrap resampling [41]. For each boostrap sample, a set of 15 stocks are selected randomly from Tables 3 and 4 to form an equallyweighted portfolio. We are interested in the difference in performance between our method and the benchmark on each boostrap sample. After all bootsrap samples are drawn, we can also estimate the average difference in performance between the two methods. More precisely, let be a random variable representing difference in % profit between our model and the benchmark (our % profit minus the benchmark’s % profit). By repeating the boostrap resampling 10,000 times, we are able to construct an empirical distribution of . This empirical distribution allows us to calculate , the average % profit difference between the two methods, and , the probability that our method has superior or equal performance to the benchmark. In addition to a portfolio consisting of stocks from the two markets, we also test portfolio performance from SET or US alone. Since the number of stocks considered in this work shown in Tables 3 and 4 is 10, a 7stock portfolio is constructed for these cases instead of a 15stock portfolio. The results are shown in Table 5.
Portfolio  Longterm Thresholds  Mediumterm Thresholds  

5%  10%  15%  20%  3%  5%  7%  10%  
SET  
1.70%  1.07%  3.12%  0.45%  3.73%  3.52%  7.46%  3.70%  
86.76%  66.72%  84.99%  57.45%  71.16%  69.53%  81.44%  74.28%  
US  
7.30%  11.88%  3.35%  1.03%  14.04%  11.75%  6.22%  2.62%  
72.25%  97.06%  72.51%  72.29%  99.82%  99.78%  88.48%  70.35%  
SET+US  
4.62%  6.42%  3.19%  0.77%  8.89%  7.55%  6.87%  3.18%  
80.64%  97.47%  92.78%  66.04%  97.94%  96.30%  92.74%  80.58% 
From Table 5, our method beats the benchmark on every case on average (since for all cases). However, on a singlecountry portfolio, about half of the cases have the confidence levels of superiority less than 80%. Most of them have satisfactory confidence levels greater than 70% though. On the other hand, on a twocountry 15stock portfolio, although is roughly an average of the two singlecountry portfolios, is significantly increasing so that most cases have the confidence levels of superiority greater than , half of them is greater than . This statistically confirms the superiority of our method over the benchmark on selected stocks. This phenomenon of confidencelevel increasing is due to the diversification effect on portfolio with a higher number of stocks. Finally, we note that the empirical distribution of is usually skewed and longtail as illustrated in Figure 7. In this nonsimple probability distribution case, boostrap empiricaldistibution estimation employed in the present paper usually provides more accurate result than traditional analytical asymptotic estimations [41].
5 Conclusion and Future Directions
In this paper, we propose to apply the advanced Dynamic Bayesian Network (DBN) methodology to model stock price dynamics with two latent variables, namely, the fundamental PE and the mediumterm noisy effect, respectively. This model is most suitable for one majority category of practitioners, namely, value investors in a security market (our model is not suitable for technical investors and mainstream academic investors). We have derived both inference and parameter estimation algorithms. The resulted model can be used as a decision support system to investment experts, or used to construct a trading strategy directly as illustrated in Section 4. Experiments in both individual firmlevel and portfolio level show statistically significant superiority of our method.
There are many possible future directions for the present work. The first direction is to more formally reformulate the stock price dynamics model to reflect other important economic and financial variables, e.g. interest rate, equity risk premium and return of equity. This modeling process is possible used by the socalled Gordon Growth Model [11] which links to the mentioned variables. Dynamic Gordon Growth Model [42] can be a further future work in this direction. It is also possible to make our DBN model more realistic by allowing timevarying shortterm noisy effect, the socalled dynamic volatility [43] or allowing dynamic volume [44]. Another promising direction in Behavioral finance which can be taken into account in our model is the topic of heterogeneous agents [20]. To improve our inference procedure, approximate inference such as Variational Bayes [15], or stochastic inference such as Markov chain Monte Carlo [7] are very promising future directions.
References
References
 [1] C. Yeh, C. Huang, and S. Lee. A multiplekernel support vector regression approach for stock market price forecasting. Expert System and Applications, 38(3):2177–2186, 2011.
 [2] C. Lu, T. Lee, and C. Chiu. Financial time series forecasting using independent component analysis and support vector regression. Decision Support Systems, 47(2):115–125, 2009.
 [3] Q. Wen, Z. Yang, Y. Song, and P. Jia. Automatic stock decision support system based on box theory and svm algorithm. Expert Systems with Applications, 37(2):1015–1022, 2010.
 [4] R. Hassan. A combination of hidden markov model and fuzzy model for stock market forecasting. Neurocomputing, 72(16):3439–3446, 2009.
 [5] L. Kao, C. Chiu, and C. Lu. A hybrid approach by integrating waveletbased feature extraction with mars and svr for stock index forecasting. Decision Support Systems, 54(3):1228–1244, 2013.
 [6] A. Kazem, E. Shariff, and F. Hussain. Support vector regression with chaosbased firefly algorithm for stock market price forecasting. Applied Soft Computing, 13(2):947–958, 2013.
 [7] C. M. Bishop. Pattern Recognition and Machine Learning. Springer Science Press, New York, 2006.
 [8] J. Murphy. Technical analysis of the financial markets: A comprehensive guide to trading methods and applications. Penguin, 1999.
 [9] B. Shannon. Technical Analysis using Multiple Time Frames. LifeVest Publishing, Inc., 2008.
 [10] H. Mark. The Most Important Things: Uncommon Sense for the Thoughtful Investor, . Columbia University Press, 2011.
 [11] A. Damodaran. Investment Valuation, . LifeVest Publishing, Inc., 2012.
 [12] P. Lynch and J. Rothchild. One Up on Wall Street, Ed. Simon & Schuster, 2000.
 [13] E. Henry, T. Robinson, J. Stowe, and J. Pinto. Equity Asset Valuation, ed. CFA Institute, 2010.
 [14] S. A. Carvell, T. Sullivan, and R. Pari. Analysts Forecast and Price/Earning Ratios. School of Hotel Administration Collection, Cornell University, 1989.
 [15] K. P. Murphy. Machine Learning: A Probabilistic Approach. MIT Press, 2012.
 [16] A. Szyszka. Behavioral Finance and Capital Markets. Palgrave Mackmillan, New York, 2013.
 [17] B. M. Barber and T. Odean. The behavior of individual investors. Available at SSRN 1872211, 2011.
 [18] F. Black. Noise. The Journal of Finance, pages 529–543, 1986.
 [19] J. B. De Long, A. Shleifer, L. H. Summers, and R. J. Waldmann. Noise trader risk in financial markets. J. Polit. Econ., 98:703–738, 1990.
 [20] C. Hommes. Behavioral Rationality and Heterogenous Expectation in Complex Economic Systems. Cambridge University Press, 2013.
 [21] W. De Bondt and R. H. Thaler. Does the stock market overreact? The Journal of Finance, pages 793–807, 1986.
 [22] R. Bloomfield, R. Libby, and M. Nelson. Underreactions, overreactions and moderated confidence. Journal of Financial Markets, 3(2):113–137, 2000.
 [23] J. Pound and R. Zeckhauser. Clearly heard on the street: The effect of takeover rumors on stock prices. The Journal of Business, 63(3):291–308, 1990.
 [24] R. Tumarkin and R. F. Whitelaw. News or noise? internet postings and stock prices. Financial Analysts Journal, 57(3):41–51, 2001.
 [25] M. Rashes. Massively confused investors making conspicuously ignorant choices. The Journal of Finance, 56(5):1911–1927, 2001.
 [26] M. J. Cooper, O. Dimitrov, and P. R. Rau. A rose.com by any other name. The Journal of Finance, 56(6):2371–2388, 2001.
 [27] P. M. Dechow, A. Hutton, and R. Sloan. The relation between analysts’ forecasts of longterm earnings growth and stock price performance following equity offering. Journal of Contemporary Accounting Research, 17(1):1–32, 2000.
 [28] A. Cowen, B. Groysberg, and P. Healy. Which types of analysts firms are more optimistic? Journal of Accounting and Economics, 41(1–2):119–146, 2006.
 [29] A. Shleifer and R. Vishny. The limits of arbitrage. Journal of Finance, 52(1):35–55, 1997.
 [30] W. Haizhen. Bayesian Probabilistic Inference on FirmLevel Stock Price Dynamics. Suranaree University of Techonology, Ph.D. Dissertation (available upon request), 2017.
 [31] N. M. Laird A. P. Dempster and D. B. Rublin. Maximum likelihood from incomplete data via the EM algorithm. Journal of the royal statistical society. Series B (methodological), pages 1–38, 1977.
 [32] L. Vandenberghe S. Boyd, S. J. Kim and A. Hassibi. A tutorial on geometric programming. Optimization and engineering, 8(1):67–127, 2007.
 [33] A. Gelman, J. B. Carlin, H. S. Stern, and D. B. Rubin. Bayesian Data Analysis. CRC Press, New York, 2003.
 [34] E. Fama. Foundation of Finance. Basic Books, 1976.
 [35] E. Fama. Efficient capital markets: II. The Journal of Finance, pages 1575–1634, 1991.
 [36] B. Malkiel. A Random Walk Down Wall Street: The Timetested Strategy for Successful Investing, . W.W. Norton and Company, 2016.
 [37] M. Carhart. On persistence in mutual fund performance. The Journal of Finance, pages 57–82, 1997.
 [38] Investopedia: What is the ideal number of stocks to have in a portfolio? http://www.investopedia.com/ask/answers/05/optimalportfoliosize.asp. Accessed: 20161231.
 [39] Efficient frontier: The 15stock diversification myth. http://www.efficientfrontier.com/ef/900/15st.htm. Accessed: 20161231.
 [40] M. Racine D. Domian, D. Louton. Diversification in portfolios of individual stocks: 100 stocks are not enough. The Financial Review, 42(4):557–570, 2007.
 [41] J. L. Horowitz. Bootstrap methods in econometrics: theory and numerical performance. Econometric Society Monographs, 28:188–222, 1997.
 [42] J. Y. Campbell and R. J. Shiller. The dividendprice ratio and expectations of future dividends and discount factors. Review of financial studies, 1(3):195–228, 1988.
 [43] Y. Wu, J. HernándezLobato, and Z. Ghahramani. Dynamic covariance models for multivariate financial time series. ICML (3), pages 558–566, 2013.
 [44] G. Llorente, R. Michaely, G. Saar, and J. Wang. Dynamic volumereturn relation of individual stocks. Review of Financial studies, 15(4):1005–1047, 2002.