# Using Statistical Model to Study the Daily Closing Price Index in the Kingdom of Saudi Arabia (KSA)

Authors: Hassan M. Aljohani; Azhari A. Elhag
Journal: Complexity
 (2021)

---

## Abstract

Classification in statistics is usually used to solve the problems of identifying to which set of categories, such as subpopulations, new observation belongs, based on a training set of data containing information (or instances) whose category membership is known. The article aims to use the Gaussian Mixture Model to model the daily closing price index over the period of 1/1/2013 to 16/8/2020 in the Kingdom of Saudi Arabia. The daily closing price index over the period declined, which might be the effect of corona virus, and the mean of the study period is about 7866.965. The closing price is the last regular deal that took place during the continuous trading period. If there are no transactions on the stock during the day, the closing price is the previous day’s closing price. The closing auction period comes after the continuous trading period (from 3 : 00 PM to 3 : 10 PM), during which investors can enter by buying and selling the stocks at this period. The experimental results show that the best mixture model isE (equal variance) with three components according to the BIC criterion. The expectation-maximization (EM) algorithm converged in 2 repetitions. The data source is from Tadawul KSA.


---

## Body

## 1. Introduction

The stock market index’s direction indicates the movement of the price index or the future trend of fluctuation in the stock market index [1, 2]. Guessing the trend is a practical issue that heavily influences a financial trader buying or selling an instrument [3, 4]. An accurate forecast of the stock index trends can help investors acquire opportunities for gaining profit in the stock exchange [5–7]. Hence, precise forecasting of the stock price index trends can be extremely advantageous for investors [8]. It is essential to study the extent to which the stock price index’s movement can be predicted using the data Tadawul from emerging markets such as the Saudi stock market, since its inception on 6 June 2003, corresponding to 2/6/1424 AH. On March 19, 2007, the Council of Ministers approved it [3]. The Saudi Stock Exchange Company “Tadawul” under Article 20 of the Capital Market Authority. The passage of years is involved the incredible expansion of the local economy and companies which need to reach a wide range of investors. It obtained the total of listings in the market. The leading and parallel 262 companies and securities and debt instruments as many as 190 companies were listed in the leading market and ten firms in growth-parallel market and 62 instrument issues’ debt by the end of 2018. In addition to listing the shares, Tadawul is also listed tading in bonds and Sukuk and funds (RITs) [9] and index traded funds (ETF). The leading market index (TASI) also includes all companies listed on the leading “Tadawul” market, one of the leading indicators trusted by investors. It depends on the performance of the companies listed in the stock market in Saudi Arabia. Tadawul also publishes different types of sector indices following the Global Industry Classification Standard (GICS).


## 2. Gaussian Mixture Model

In this section, we introduced mixture models. Recall that, if our observationsXi come from a mixture model with K mixture components, the marginal probability distribution of Xi is of the form(1)pXi=x=∑k=1Kπkpxi=x|Zi=k,where Zi∈1,…,K is the latent variable representing the mixture component for Xi,PXi|Zi which is the mixture component and πk is the mixture proportion representing the probability that Xi belongs to the kth mixture component [10].


### 2.1. Expectation Maximization (EM)

It is an algorithm within the Gaussian mixture models. ConsiderNμ,σ2 represents the probability distribution function for a normal random variable. Thus, we get that the conditional distribution Xi|Zi=k∼Nμk,σk2 so that the marginal distribution of Xi is(2)pXi=x=∑k=1KpZi=kpXi=x|Zi=k=∑k=1KπkNx,μk,σk2.Similarly, the joint probability of observationsX1,…,Xn is therefore(3)PX1=x1,…,Xn=xn=∏i=1n∑k=1KπkNx,μk,σk2.See [11], for more details. This note defines the EM algorithm that aims to determine the maximum likelihood estimates of πk,μk, andσk2 given a dataset of observations x1,…,xn.


### 2.2. MLE of Normal Distribution

Suppose we havenn observations X1,…,Xn from a Gaussian distribution with an unidentified mean μ and a recognized variance σ2. To define the maximum likelihood estimate for μ, we get the log-likelihood ℓμ to take the derivative concerning μ, set it equal zero, and resolve for μ:(4)Lμ=∏i=1n12πσ2exp−xi−μ2σ2⟹ℓμ=∑i=1nlog12πσ2−xi−μ22σ2⟹ddμℓμ=∑xi−μσ2.Defining the result equal to zero and resolving forμ, we have that μMLE=1/n∑i=1nxi. Furthermore, applying the log function to the likelihood helped decompose the product and eliminated the exponential function. Thus, the MLE could be resolved easily.


### 2.3. MLE of Gaussian Mixture Model

Now, we attempt the same strategy for deriving the MLE of the Gaussian mixture model. Our unknown parameters are(5)θ=μ1,…,μk,σ1,…,σk,π1,…,πk,based on the first section of the note, and our likelihood is(6)Lθ|X1,…,Xn=∏i=1n∑k=1kπkNπk;μk,σk2.So, our log-likelihood is(7)ℓθ=∑i=1nlog∑k=1kπkNπk;μk,σk2.Considering the expression above, we already see a difference between this scenario and the simple setup in the preceding section. The summation over thek constituents “blocks” our log function from application to the ordinary densities. When following the same earlier steps, differentiating concerning μk and setting the expression equal to zero, the result would be(8)∑i=1n1∑k=1kπkNπk;μk,σk2πkNxk,μk,σkxk−μkσk2=0.We are currently stuck due to the inability to resolve analytically forμk, but a significant observation is made when we defined the latent variables Zi. After that, we could collect all samples Xi such that Zi=k and utilize the estimate from the preceding section to estimate μk.


## 2.1. Expectation Maximization (EM)

It is an algorithm within the Gaussian mixture models. ConsiderNμ,σ2 represents the probability distribution function for a normal random variable. Thus, we get that the conditional distribution Xi|Zi=k∼Nμk,σk2 so that the marginal distribution of Xi is(2)pXi=x=∑k=1KpZi=kpXi=x|Zi=k=∑k=1KπkNx,μk,σk2.Similarly, the joint probability of observationsX1,…,Xn is therefore(3)PX1=x1,…,Xn=xn=∏i=1n∑k=1KπkNx,μk,σk2.See [11], for more details. This note defines the EM algorithm that aims to determine the maximum likelihood estimates of πk,μk, andσk2 given a dataset of observations x1,…,xn.


## 2.2. MLE of Normal Distribution

Suppose we havenn observations X1,…,Xn from a Gaussian distribution with an unidentified mean μ and a recognized variance σ2. To define the maximum likelihood estimate for μ, we get the log-likelihood ℓμ to take the derivative concerning μ, set it equal zero, and resolve for μ:(4)Lμ=∏i=1n12πσ2exp−xi−μ2σ2⟹ℓμ=∑i=1nlog12πσ2−xi−μ22σ2⟹ddμℓμ=∑xi−μσ2.Defining the result equal to zero and resolving forμ, we have that μMLE=1/n∑i=1nxi. Furthermore, applying the log function to the likelihood helped decompose the product and eliminated the exponential function. Thus, the MLE could be resolved easily.


## 2.3. MLE of Gaussian Mixture Model

Now, we attempt the same strategy for deriving the MLE of the Gaussian mixture model. Our unknown parameters are(5)θ=μ1,…,μk,σ1,…,σk,π1,…,πk,based on the first section of the note, and our likelihood is(6)Lθ|X1,…,Xn=∏i=1n∑k=1kπkNπk;μk,σk2.So, our log-likelihood is(7)ℓθ=∑i=1nlog∑k=1kπkNπk;μk,σk2.Considering the expression above, we already see a difference between this scenario and the simple setup in the preceding section. The summation over thek constituents “blocks” our log function from application to the ordinary densities. When following the same earlier steps, differentiating concerning μk and setting the expression equal to zero, the result would be(8)∑i=1n1∑k=1kπkNπk;μk,σk2πkNxk,μk,σkxk−μkσk2=0.We are currently stuck due to the inability to resolve analytically forμk, but a significant observation is made when we defined the latent variables Zi. After that, we could collect all samples Xi such that Zi=k and utilize the estimate from the preceding section to estimate μk.


## 3. Numerical Results

The available historical data consisted of the daily closing price index over the period of 1/1/2013 to 16/8/2020 in the Kingdom of Saudi Arabia. The data source is from Tadawul KSA [12].Figure1 displays the data that is taken daily over 1/1/2013 to 16/8/2020. It can be seen that the data contains numerous of information. However, the proposed methodology can answer questions that we need it. On the contrary, Table 1 shows the summary statistics. This information can be obtained quickly from any software. From Table 1, the mean is 7866.965 and the standard deviation is 1126.780, where the first impression can be given from this primary information.Figure 1
The series for the daily closing price index over the period of 1/1/2013 to 16/8/2020.Table 1
The descriptive statistics for the daily closing price index over the period of 1/1/2013 to 16/8/2020.
Summary statisticsStd. DeviationMeanMaximumMinimumObs. without missing dataObs. with missing dataObservationsVariable1126.7807866.96511149.3605416.470189901899The daily closing price indexThe comparison among these models can be found using BIC in Table2, where this method is used in the maximum likelihood and then compared between them. It can be seen that the model number 3 has the smallest figure, although the model number 2 gives negative result.Table 2
Selection criterion is Bayesian information criterion.
Evolution of the BIC for each model5432The daily closing price index over−32040.623−32025.525−32010.427−32107.323ESince mixed model is used, it is beneficial to study the proportion between two normal distributions, where the model numbers 1 and 2 have the same number of the balance and larger than model 3, see Table2.Table3 shows the means after the proposed methods are implemented. It is easy to see that the model number 3 gives a high figure of mean, where model numbers 1 and 2 are closer to 7385, though the variances are similar in the three models.Table 3
The mean by the three components.
Means by class321Class9232.9957385.0677385.066Mean (open)In contrast, the selection criterion can be used to find the class in the data. It shows that there is more than one clustering in this data, where the method gives 25.436. This means that two or three groups can be given (see Table4).Table 4
Selection criterion for selection model. The NEC criterion is more than one which indicates that there is no clustering structure in the data.
Selection criterion for the selected modelDFEntropyNECLog-likelihoodICLAICBIC6.0001424.34925.436−15982.566−34859.124−31977.132−32010.427Figure2 shows that there are two clusters: the red line shows first groups and the green shows the other. This means that two groups of companies can be gathered together. More precisely, from the data there are one group going down and the other going up. It is not easy to find this information from the data directly.Figure 2
The MAP classification shows that there is no assignment to classes 2.The plots of three model can be found in Figure3, where the mixed model gives the larger maximum likelihood than the other models “1, 2.”Figure 3
The mixture model.It can be seen that the proposed method gives curve close to the empirical components. This means that the proposed method gives excellent results, even compared to various models, see Figures4 and 5.Figure 4
The mixture model. It is clear that the estimated CDF is very close to empirical CDF, which confirms the accuracy of the estimation.Figure 5
The quintiles of the estimated mixture density.


## 4. Conclusion

This paper used the Gaussian mixtures model to classify the daily closing price index over 1/1/2013 to 16/8/2020 in KSA and describe the problem of predicting the daily closing price index in KSA which represents a huge problem. The mean of the daily closing price index over the study period is 7866.965. The decline of the daily closing price index in KSA, which occurred last year, might have been due to COVID-19 pandemic. The EM algorithm converged in 124 iterations; according to Bayesian information criterion, the best mixture model is the equal variance with three components (see Table2). The proportions of the three ingredients are varied between 0.261 and 0.370 (see Table 5). The mean of the three components is run between 9232.995 and 7385.066 (see Table 3). The variance of the four ingredients is 610676.444 (see Table 6). Finally, we must point out that implementing such a mechanism to predict the daily closing price index in the KSA is beneficial.Table 5
The proportions of three components.
Proportions321Class0.2610.3700.370ProportionsTable 6
The variance by the three components.
Variance by class321Class610676.444610676.444610676.444Variance



---

*Source: 5593273-2021-03-22.xml*