You are on page 1of 11

0

King Fahd University of Petroleum and Minerals


Department of Mathematics and Statistics
Stat 460 - Time Series Analysis

Term Paper

Stochastic And Deterministic Trends


In Saudi Enaya Cooperative Stock Price

Abstract
In this report, we will examine the impact of the performance of Saudi Enaya Cooperative
Insurance on their stock price, trying to discover trends and to select a suitable model to
predict future stock prices.

INSTRUCTOR: DR.MOHAMMED OMAR


STUDENT: MOHAMMED ALBATHER
ID : 201689020
Term: 202
APRIL 1,
2021
1

Table of Contents
Abstract ......................................................................................................................................................... 2
Introduction .................................................................................................................................................. 2
Saudi Enaya ............................................................................................................................................... 2
Time Series Trends Analysis ...................................................................................................................... 2
Data ............................................................................................................................................................... 2
Methodology................................................................................................................................................. 3
1-Trends: ................................................................................................................................................... 3
2-Independence: ....................................................................................................................................... 3
3-Stationarity: ........................................................................................................................................... 3
4-Normality: .............................................................................................................................................. 4
Data Transformation ..................................................................................................................................... 4
Trends analysis: ............................................................................................................................................. 5
Linear models ............................................................................................................................................ 5
Cyclical Trends........................................................................................................................................... 6
Conclusion ..................................................................................................................................................... 6
References and Appendix ............................................................................................................................. 7
R script: ......................................................................................................................................................... 7

Mohammed Albather 201689020


2

Abstract
In this report, we will examine the impact of the performance of Saudi Enaya Cooperative
Insurance on their stock price, trying to discover trends and to select a suitable model to
predict future stock prices.

Introduction
Saudi Enaya
Saudi Enaya Cooperative Insurance was formed in 2011 and started commencing their
operations in 2013, since then until 2015 the company has shown a very strong performance
in terms of sales and loss ratios. But since 2015 onwards, the company has been facing very
difficult time in terms of managing their policies. In this paper we want to see the impact of
the company’s performance on their stock price. Followed by comments on the recent
strategies that the company has implemented to improve their performance.

Time Series Trends Analysis


The time series analysis is generally used to understand or model the stochastic mechanism of
a random variable, also to predict future values of a series based on the historical values.
Stochastic trends: when the perceived trend not actual, and is just due to the strong positive
correlation between the series values at nearby time points.
Deterministic trend: when the actual trend can be determined by an equation, and new
observations that can be predicted by either linear, quadratic, cyclical, or any other constant
deterministic function. For example:

Yt = t + Xt or t =t – 12
Data
The data was collected from Google.Finance and was checked against that actual stock prices
on Tadawul website. Some manual adjustments were made on the data to include the missing
months, those prices were taken from Tadawul website. We have considered the closing stock
prices at two time points of each month (middle and end) to allow for capturing more
information about the stock movements. The data used includes all months from beginning of
2014 until March 2021, so in total we have 174 observations.
3

Methodology
We start by plotting the time series graph to see any trends and seasonal behavior in the data.
1-Trends: as we have mentioned in the intro, Enaya has shown a deterioration in performance
since 2015, this was reflected on their stock price and showed a downward trend, with large
decrease in the variability. The stock has been stable around 40 SR for the past 3 years.

2-Independence: This can be seen by plotting Yt against Yt-1, and the ACF plot. We can see a very
strong relationship between successive time points, also from the autocorrelation functions
we can see that the data maintains high correlations for previous lags.

3-Stationarity: The data is non-stationary from the shape of the graph, and also due to:
1- non constant mean 2-variability changes over time

Mohammed Albather 201689020


4

4-Normality: This can be checked through the Normal QQ-plot and the histogram,

From these graphs we can see that the data is not normally distributed. And the Shapiro test
gives us P-value=2.947e-13 so we will reject the normality. A considerable curvature in the
Normal QQ-plot is witnessed, and the histogram looks something like the exponential
distribution. Hence, we would try the Exponential QQ-plot to see whether the data follows the
exponential distribution or not. We can see from the plot on the right that the exponential
distribution fits the data better, but it is still negatively skewed, hence we will try to transform
the data to satisfy normality.

Data Transformation
This step is needed to fix the non-normality issue by transforming the data using the Box-Cox
transformation. To do so, we use the function BoxCox(Data ,lambda = "auto") in R, which results in
lambda to be between [-0.415 , 5x10-4] and the optimal lambda to be λ = -0.2070947.
After applying the transformation, we can
see from the new QQ-plot that our
transformation did not solve the non-
normality. This is because Box-Cox
transformation works for skewed data, while
it fails for data sets that have small min to
max value ratio.

Mohammed Albather 201689020


5

Trends analysis:
The previous data analysis was taking into account the whole available data on Enaya stock
prices. Considering a very long-time-horizon could potentially be misleading as those past
years might be irrelevant. The performance of the company, along with their strategies have
obviously changed. This makes as willing to consider those diagnostics for the most recent
years to discover any trends in the data.
The company’s performance started showing more stability in 2018, and since then until 2020
the stock price has been quite stable. By the beginning of 2020, the company started
implementing reformative strategies, which were reflected on the stock price. Since 2020 the
stock has been slightly increasing.
To discover trends in the data, we will apportion the data into three time frames based on the
company’s performance, For each of these periods, we are going to test both Linear
deterministic trends & cyclical trends through seasonal means.
Linear models

We aim to fit the deterministic component


of the process Yt = t + Xt by fitting a linear
model, such that: t = 0 + 1t
For the first time frame we find a slight
decreasing trend given by:
t =  -0.0275 t

For the second time frame we also find a


decreasing trend at a higher rate, given by:
t =  -1.297 t

While for the period from 2018 onwards, the


stock price has shown an increasing trend. With
the tendency to have an increasing trend in the
future. The trend component is estimated by:
t =  + 0.02 t

Note that the scaling for each graph is different.

Mohammed Albather 201689020


6

Cyclical Trends
We will now consider fitting cyclical trend models satisfying Yt = t + Xt such that t = t – 24 . note
that we are comparing t with the one that is 24 periods before. This is because we are using
two time points for each month, so 24 periods annually.
We fit the seasonal means models for each of the periods independently:

there are no apparent patterns relating to similar


months of the year for the firsts two time frames.
While for the third time frame that is 2018-2021
there is slight similarity in similar months
throughout the years. Which potentially indicates
a cyclical trend from 2018 onwards.

Conclusion
We have seen a potential increasing trend in Enaya stock
price, this could be an evidence of an improvement in
performance. especially after the management’s
announcement in 2019 about new management
restructuring operations, and merger with Amana Insurance
and advancing company performance.

Mohammed Albather 201689020


7

References and Appendix

https://www.isixsigma.com/topic/box-cox-wont-transform/

https://www.analyticsvidhya.com/blog/2015/12/complete-tutorial-time-series-modeling/

R script:
library(TSA)

library(MASS)

library(tseries)

library(forecast)

library(readxl)

library(xts)

library(munsell)

library(tidyverse)

#Data

s.d=read_excel("/Users/Mohammed/Desktop/202/STAT 460- Time Series/TS project//Data worked.xlsx",sheet = "final")

p=ts(s.d$Price,start = 2014,frequency = 24) # converts the list data into time series format

summary(p) # creates summary of the data, min max meidan...

show(p) # displays the data set

#See the data

plot(p,col = "#006600",xlab="Time",ylab="Price",main="Enaya Stock Price")

acf(as.vector(p),xaxp=c(0,24,12),main="ACF",col = "#006600")

pacf(as.vector(p),xaxp=c(0,25,25),main="PACF",col = "#006600")

plot(zlag(p),p, pch=20 , cex=1 , col="#006600",xlab=expression("Y"[t-1]) , ylab=expression("Y"[t]))

## Normal QQ Plot

qqnorm(p,col = "#006600",pch=20)

qqline(p, col = "#00cc33",lwd=2,lty=2)

## Exponential QQ Plot

qqplot(x=qexp(ppoints(100)), y=p,col = "#006600", main="Exponential Q-Q Plot",xlab="Theoretical Quantiles", ylab= "The Data
Quantiles")

Mohammed Albather 201689020


8

qqline(p, distribution=qexp, col = "#00cc33")

##Histogram

hist(p, prob = TRUE, col = "#006600",main="Histogram of Enaya Stock",xlab="Stock Price",ylab="Price")

curve(dexp(x, rate = 0.02), lty = 2, lwd = 2, add = TRUE , col = "#00cc33")

curve(dexp(x), col = 2, lty = 2, add = TRUE)

shapiro.test(p)

#Transform

# rm(s) # To delete from storage

s=read_excel("/Users/Mohammed/Desktop/202/STAT 460- Time Series/TS project//Data worked.xlsx",sheet="BoxCoxDATA")

z=as.matrix(p)

show(z)

BoxCox(z,lambda = "auto")

bestNormalize::boxcox(z)

p.tran=p^(-0.2070947)

qqnorm(p.tran,col = "#006600",pch=20,main="Lambda=-0.21")

qqline(p.tran, col = "#00cc33",lwd=2,lty=2)

hist(((p-mean(p))/sd(p)),probability = T, main="Histogram Plot\n??=1" , breaks=10 , col="#9966CC" , xlab="Log(Price)" ,


ylab="Probability")

curve(dnorm,add=TRUE, col="#663399", lwd=2)

hist(((p.tran-mean(p.tran))/sd(p.tran)),probability = T, main="Histogram Plot\n??=0" , breaks=10 , col="#FF6600" , xlab="Price" ,


ylab="Probability")

curve(dnorm,add=TRUE, col="#CC0003", lwd=2)

## Fitting lieanr models

trend1=read_excel("/Users/Mohammed/Desktop/202/STAT 460- Time Series/TS project//Data worked -


2.xlsx",sheet="T1")

t1=ts(trend1$Price1,start = 2014,end = 2016,frequency = 24) # converts the list data into time series format

show(t1)

t1=head(t1,-1) #to remove the last zero element - Run Only once !

t2=ts(trend1$Price2,start = 2016,end = 2018,frequency = 24) # converts the list data into time series format

show(t2)

Mohammed Albather 201689020


9

t2=head(t2,-1) #to remove the last zero element - Run Only once !

t3=ts(trend1$Price3,start = 2018,end = 2022,frequency = 24) # converts the list data into time series format

show(t3)

t3=head(t3,-19) #to remove the last zero element - Run Only once !

## Fitting lieanr models

m1=lm(t1~seq(1,48))

summary(m1)

m2=lm(t2~seq(1,48))

summary(m2)

m3=lm(t3~seq(1,78))

summary(m3)

win.graph(width=30,height=15,pointsize=10)

par(mfrow = c(3,1))

plot(t1,col = "#006600",xlab="Time",ylab="Price",main="Enaya Stock Price 2014-2015")

plot(t2,col = "#006600",xlab="Time",ylab="Price",main="Enaya Stock Price 2016-2017")

plot(t3,col = "#006600",xlab="Time",ylab="Price",main="Enaya Stock Price 2018-2021")

# Fitting seasonal means

t1.seas.=season(t1)

m1.seas=lm(t1~t1.seas.-1) # -1 removes the intercept term

summary(m1.seas)

t2.seas.=season(t2)

m2.seas=lm(t2~t2.seas.-1) # -1 removes the intercept term

summary(m2.seas)

Mohammed Albather 201689020


10

t3.seas.=season(t3)

m3.seas=lm(t3~t3.seas.-1) # -1 removes the intercept term

summary(m3.seas)

win.graph(width=30,height=15,pointsize=10)

plot(y=rstudent(m1.seas),x=as.vector(time(t1)),xlab='Time',

ylab='Standardized Residuals',type='l',main="Enaya Stock Price 2014-2015")

points(y=rstudent(m1.seas),x=as.vector(time(t1)), pch=seq(1,24),cex = 3, col ="red")

win.graph(width=30,height=15,pointsize=10)

plot(y=rstudent(m2.seas),x=as.vector(time(t2)),xlab='Time',

ylab='Standardized Residuals',type='l',main="Enaya Stock Price 2016-2017")

points(y=rstudent(m2.seas),x=as.vector(time(t2)), pch=seq(1,24),cex = 3, col ="red")

win.graph(width=30,height=15,pointsize=10)

plot(y=rstudent(m3.seas),x=as.vector(time(t3)),xlab='Time',

ylab='Standardized Residuals',type='l',main="Enaya Stock Price 2018-2021")

points(y=rstudent(m3.seas),x=as.vector(time(t3)), pch=seq(1,24),cex = 3, col ="red")

class(m1)

tsdiag(m1) #time series Diagnostics function

Mohammed Albather 201689020

You might also like