Fitting stock returns to the GHD

Một phần của tài liệu Financial risk modelling and portfolio optimization with r second edition (Trang 87 - 90)

6.6 Applications of the GHD to risk modelling

6.6.1 Fitting stock returns to the GHD

In this subsection the daily returns of Hewlett Packard (HWP) stock are fitted to the GHD and its special cases, the HYP and NIG. TheRcode is shown in Listing 6.1.

The sample runs from 31 December 1990 to 2 January 2001 and consists of 2529 ob- servations. The following analysis has been conducted with the functions contained in the package ghyp. In the listing this package is loaded into the workspace first.

The packagefBasicscontains the data setDowJones30, which includes the HWP stock price. This series is converted into atimeSeriesobject and the continuous percentage returns are then computed. For comparison of the fitted distributions, the empirical distribution (EDF) is first retrieved from the data with the functionef().

Then the returns are fitted to GHD, HYP, and NIG distributions. In each case, possible asymmetries in the data are allowed (i.e., non-zero skewness). In the next chunk of code the shapes of the estimated densities are computed, along with a Gaussian dis- tribution which serves as the benchmark. A plot of the empirical and fitted densities is then produced (see Figure 6.4).

The rather poor description of the empirical return distribution for the Gaussian case is immediately evident from this plot. The normal distribution falls short of capturing the excess kurtosis of 4.811. Matters are different for the class of gener- alized hyperbolic distributions. In these instances the empirical distribution function is tracked rather well. The fitted HYP and NIG models almost coincide, and from this plot these two distributions cannot be discerned. The fitted GHD seems to mirror the returns slightly better. In particular, the values of the density are closer to their empirical counterparts around the median of the EDF.Ceteris paribus, this implies higher probability masses in the tails of the distribution compared to the𝜆-restricted HYP and NIG distributions.

As a second means of graphically comparing the fitted distributions, QQ plots are produced in the ensuing code lines of Listing 6.1. These are shown in Figure 6.5. For clarity the marks of the fitted normal distribution have been omitted from the plot.

The reader is encouraged to adopt the plot accordingly. What has already been con- cluded from the density becomes even more evident when the QQ plot is examined.

k k Rcode 6.1Fitting HPW returns to the GHD.

l i b r a r y ( ghyp ) 1

l i b r a r y ( t i m e S e r i e s ) 2

l i b r a r y ( f B a s i c s ) 3

# # R e t u r n c a l c u l a t i o n 4

d a t a ( DowJones30 ) 5

y <− t i m e S e r i e s ( DowJones30 [ , "HWP" ] , c h a r v e c = 6

a s . c h a r a c t e r ( DowJones30 [ , 1 ] ) ) 7

y r e t <− na . o m i t ( d i f f ( l o g ( y ) ) 1 0 0 ) 8

# # F i t t i n g 9

e f <− d e n s i t y ( y r e t ) 10

g h d f i t <− f i t . ghypuv ( y r e t , s y m m e t r i c = FALSE , 11

c o n t r o l = l i s t ( m a x i t = 1 0 0 0 ) ) 12

h y p f i t <− f i t . hypuv ( y r e t , s y m m e t r i c = FALSE , 13

c o n t r o l = l i s t ( m a x i t = 1 0 0 0 ) ) 14

n i g f i t <− f i t . NIGuv ( y r e t , s y m m e t r i c = FALSE , 15

c o n t r o l = l i s t ( m a x i t = 1 0 0 0 ) ) 16

# # D e n s i t i e s 17

g h d d e n s <− dghyp ( e f $x , g h d f i t ) 18

h y p d e n s <− dghyp ( e f $x , h y p f i t ) 19

n i g d e n s <− dghyp ( e f $x , n i g f i t ) 20

n o r d e n s <− dnorm ( e f $x , mean = mean ( y r e t ) , s d = 21

s d ( c ( y r e t [ , 1 ] ) ) ) 22

c o l . d e f <− c ( " b l a c k " , " r e d " , " b l u e " , " g r e e n " , " o r a n g e " ) 23

p l o t ( e f , x l a b = " " , y l a b = e x p r e s s i o n ( f ( x ) ) , y l i m = c ( 0 , 0 . 2 5 ) ) 24

l i n e s ( e f $x , g h d d e n s , c o l = " r e d " ) 25

l i n e s ( e f $x , h y p d e n s , c o l = " b l u e " ) 26

l i n e s ( e f $x , n i g d e n s , c o l = " g r e e n " ) 27

l i n e s ( e f $x , n o r d e n s , c o l = " o r a n g e " ) 28

l e g e n d ( " t o p l e f t " , 29

l e g e n d = c ( " e m p i r i c a l " , "GHD" , "HYP" , " NIG " , "NORM" ) , 30

c o l = c o l . d e f , l t y = 1 ) 31

# # QQP l o t s 32

qqghyp ( g h d f i t , l i n e = TRUE , ghyp . c o l = " r e d " , 33

p l o t . l e g e n d = FALSE , g a u s s i a n = FALSE , 34

main = " " , c e x = 0 . 8 ) 35

qqghyp ( h y p f i t , add = TRUE , ghyp . pch = 2 , ghyp . c o l = " b l u e " , 36

g a u s s i a n = FALSE , l i n e = FALSE , c e x = 0 . 8 ) 37

qqghyp ( n i g f i t , add = TRUE , ghyp . pch = 3 , ghyp . c o l = " g r e e n " , 38

g a u s s i a n = FALSE , l i n e = FALSE , c e x = 0 . 8 ) 39

l e g e n d ( " t o p l e f t " , l e g e n d = c ( "GHD" , "HYP" , " NIG " ) , 40

c o l = c o l . d e f [−c ( 1 , 5 ) ] , pch = 1 : 3 ) 41

# # D i a g n o s t i c s 42

AIC <− s t e p A I C . ghyp ( y r e t , d i s t = c ( " ghyp " , " hyp " , " NIG " ) , 43

s y m m e t r i c = FALSE , 44

c o n t r o l = l i s t ( m a x i t = 1 0 0 0 ) ) 45

LRghdnig <− l i k . r a t i o . t e s t ( g h d f i t , n i g f i t ) 46

LRghdhyp <− l i k . r a t i o . t e s t ( g h d f i t , h y p f i t ) 47

k k

−20 −10 0 10

0.000.050.100.150.200.25

density.default(x = yret)

f(x)

empirical GHD HYP NIG NORM

Figure 6.4 Fitted densities for HWP returns.

−15 −10 −5 0 5 10 15

−20−15−10−5051015

Theoretical Quantiles

Sample Quantiles

GHD HYP NIG

Figure 6.5 QQ plot of fitted GHD for HWP returns.

The daily returns can be tracked better with the GHD than with the HYP and NIG distributions, especially in the tails. Furthermore—this conclusion was less clear from the density plot—the returns can be slightly better explained by the NIG than by the HYP distribution.

In the last three lines of the listing, diagnostic measures for the three models are produced. First, the functionstepAIC.ghyp()is utilized to determine with which distribution the data can be explained best in terms of the AIC. This function returns a

k k Table 6.2 Results of distributions fitted to HWP returns.

Distribution AIC LLH 𝜆 ̄𝛼 𝜇 𝜎 𝛾

GHD 11684.07 −5837.04 −2.270 0.051 0.093 2.584 −0.013

NIG 11691.90 −5841.95 −0.500 1.110 0.078 2.552 0.003

HYP 11704.41 −5848.21 1.000 0.903 0.069 2.528 0.011

listobject with three elements:best.model,all.models, andfit.table.

The latter is of most interest because it not only provides information about the AICs and the values of the log-likelihood (LLH), but also returns the estimates of the distri- bution parameters, whether a symmetric distribution has been fitted or not, whether the optimizer achieved convergence, and the number of iterations required. An ex- cerpt from these results is provided in Table 6.2.

The conclusions drawn from the graphical inspection of the results are mirrored by their quantitative counterparts. Clearly, a GHD-based model is favored over the NIG and HYP distributions according to the AIC. However, the differences between the AIC and/or the log-likelihood of the GHD and NIG are rather small.

A cross-comparison to the values of the HYP model would yield a preference for the NIG, if one had to choose between the restricted distributions. The reason for this is primarily that the unrestricted estimate of ̂𝜆is−2.27 closer to the parameter restriction for𝜆 of the NIG than that of the HYP. Whether the differences in the values for the log-likelihoods are significantly different from zero can be tested by means of a likelihood ratio test. These tests are carried out in the last two lines of the Rcode listing. First, it is checked whether the GHD can be replaced by the NIG. The value of the test statistic is 0.007 and thep-value is 0.002. Hence, the null hypothesis that the explanatory power of the two distributions is equal must be rejected at a confidence level of 95%. The corresponding value of the test statistic for comparing the GHD with the HYP is 0 and the impliedp-value is 0. Here, the null hypothesis must be rejected even more clearly, which is plausible given the ordering of the three log-likelihood values.

Một phần của tài liệu Financial risk modelling and portfolio optimization with r second edition (Trang 87 - 90)

Tải bản đầy đủ (PDF)

(436 trang)