Financial Returns: Normal Distribution

library(readxl)
week6 = read_excel("TLKM.JK.xlsx")
stock.return = week6$Return*100

Finding Mean and Variance

stock.mean = mean(stock.return)
stock.mean
## [1] 0.001097486
stock.var = var(stock.return)
stock.var
## [1] 3.398987

5% Quantile

The Lowest 5% in Return Percentage

lower.05 = qnorm(0.05, stock.mean, sqrt(stock.var))
lower.05
## [1] -3.031411

The Highest 5% in Return Percentage

high.05 = qnorm(0.95, stock.mean, sqrt(stock.var))
high.05
## [1] 3.033606

The Probability of Having No Return (return = 0)

return.0 = dnorm(0, stock.mean, sqrt(stock.var))
return.0
## [1] 0.216389

The Probability of Loss (return < 0)

loss = pnorm(0, stock.mean, sqrt(stock.var))
loss
## [1] 0.4997625

The Probability of Getting Profit (return > 0)

profit = 1 - pnorm(0, stock.mean, sqrt(stock.var))
profit
## [1] 0.5002375

Loss Distribution: Pareto Distribution

library(CASdatasets)
## Loading required package: xts
## Loading required package: zoo
## 
## Attaching package: 'zoo'
## The following objects are masked from 'package:base':
## 
##     as.Date, as.Date.numeric
## Loading required package: sp
## The legacy packages maptools, rgdal, and rgeos, underpinning the sp package,
## which was just loaded, will retire in October 2023.
## Please refer to R-spatial evolution reports for details, especially
## https://r-spatial.org/r/2023/05/15/evolution4.html.
## It may be desirable to make the sf package available;
## package maintainers should consider adding sf to Suggests:.
## The sp package is now running under evolution status 2
##      (status 2 uses the sf package in place of rgdal)
library (fitdistrplus)
## Loading required package: MASS
## Loading required package: survival
library(MASS)
data(danishuni)
head(danishuni)
##         Date     Loss
## 1 1980-01-03 1.683748
## 2 1980-01-04 2.093704
## 3 1980-01-05 1.732581
## 4 1980-01-07 1.779754
## 5 1980-01-07 4.612006
## 6 1980-01-10 8.725274

Data used in this distribution fitting is from a data set called “danishuni”, containing of Danish reinsurance claim data. The smallest value of this data is is 1.00, while the largest value is 263.250.

x = danishuni$Loss
head(x, n = 96)
##  [1]   1.683748   2.093704   1.732581   1.779754   4.612006   8.725274
##  [7]   7.898975   2.208045   1.486091   2.796171   7.320644   3.367496
## [13]   1.464129   1.722223  11.374817   2.482739  26.214641   2.002430
## [19]   4.530015   1.841753   3.806735  14.122076   5.424253  11.713031
## [25]   1.515373   2.538589   2.049780  12.465593   1.735445   1.683748
## [31]   3.323852   1.821025   2.415813   1.464129   5.875902   1.792439
## [37]   3.338214   1.584488   1.931321   2.049780   1.573758   1.756955
## [43]   4.931186   5.417277   1.537335  17.569546   1.691123   1.581612
## [49]   1.467116   2.049780   1.928712   3.263154   1.704246   2.074608
## [55]   3.294290   1.839975   7.320644   7.320644   1.576215   4.856098
## [61]   1.542275  13.620791   1.756955   1.639824   2.036378  21.961933
## [67]   1.799026   2.452416   2.669107   2.024146   1.724744   1.643864
## [73]   1.961933   4.626647   1.464129   3.963250   5.563852   4.392387
## [79]   3.640313   1.677892   1.449488 263.250366   2.500732   1.825769
## [85]   9.882870   2.146618   2.870259   6.319914   2.123461   2.923865
## [91]   2.036376   1.736457   2.049780   1.903367   1.610542   1.717423
summary(x)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   1.000   1.321   1.778   3.385   2.967 263.250

Histogram

From histogram below, we know that this data distribution mostly pooled in the smaller value below 50 rater that above.

hist(x, breaks = 100,main = "Histogram of Loss", xlab = "Loss")
lines(density(x), lty = 5, col = "red")

We will first fit this data set with gamma distribution using multiple methods, such as:

  • Maximum Likelihood Estimation (MLE)

  • Moment Matching Estimation (MME)

  • Quantile Matching Estimation (QME)

  • Maximum Goodnes-of-Fit Estimation (MGE)

Maximum Likelihood Estimation

fgamMLE <- fitdist (x, "gamma", method="mle")
summary(fgamMLE)
## Fitting of the distribution ' gamma ' by maximum likelihood 
## Parameters : 
##        estimate Std. Error
## shape 1.2976762 0.03548677
## rate  0.3833939 0.01273545
## Loglikelihood:  -4767.096   AIC:  9538.191   BIC:  9549.554 
## Correlation matrix:
##           shape      rate
## shape 1.0000000 0.8232389
## rate  0.8232389 1.0000000

Moment Matching Estimation

fgamMME <- fitdist (x, "gamma", method="mme")
summary(fgamMME)
## Fitting of the distribution ' gamma ' by matching moments 
## Parameters : 
##         estimate
## shape 0.15839499
## rate  0.04679198
## Loglikelihood:  -6665.992   AIC:  13335.98   BIC:  13347.35

Quantile Matching Estimation

fgamQME <- fitdist (x, "gamma", method="qme", probs=c (0.95, 0.05))
summary(fgamQME)
## Fitting of the distribution ' gamma ' by matching quantiles 
## Parameters : 
##         estimate
## shape 0.13187546
## rate  0.07444676
## Loglikelihood:  -7023.213   AIC:  14050.43   BIC:  14061.79

Maximum Goodness-of-Fit Estimation

fgamMGE <- fitdist (x, "gamma", method="mge", gof="CvM")
summary(fgamMGE)
## Fitting of the distribution ' gamma ' by maximum goodness-of-fit 
## Parameters : 
##       estimate
## shape 3.750012
## rate  1.772281
## Loglikelihood:  -6882.448   AIC:  13768.9   BIC:  13780.26

Model Fitting Comparison

We try to compare, which method is more suitable by comparing each of the AIC and BIC values. The smaller the value, the more suitable the method.

data.frame("Method" = c("MLE", "MME", "QME", "MGE"), 
           "AIC" = c(fgamMLE$aic, fgamMME$aic, fgamQME$aic, fgamMGE$aic), 
           "BIC" = c(fgamMLE$bic, fgamMME$bic, fgamQME$bic, fgamMGE$bic), 
           "Log-Likelihood" = c(fgamMLE$loglik, fgamMME$loglik, 
                                fgamQME$loglik, fgamMGE$loglik), 
           check.names=FALSE)
##   Method       AIC       BIC Log-Likelihood
## 1    MLE  9538.191  9549.554      -4767.096
## 2    MME 13335.984 13347.346      -6665.992
## 3    QME 14050.426 14061.788      -7023.213
## 4    MGE 13768.895 13780.257      -6882.448

In comparing both AIC and BIC value, MLE seems like the most suitable model. From this statement, we will use Gamma Distributed Loss with MLE method with the following parameters:

fgamMLE$estimate
##     shape      rate 
## 1.2976762 0.3833939

5% Quantile

The Lowest 5% in Loss

lower.05 = qgamma(0.05, fgamMLE$estimate[1], fgamMLE$estimate[2])
lower.05
## [1] 0.306883

The Highest 5% in Loss

high.05 = qgamma(0.95, fgamMLE$estimate[1], fgamMLE$estimate[2])
high.05
## [1] 9.260058