13.8 Example

We analyze the daily returns of the exchange rate of the Yen related to the U.S. Dollar from Dec. 1, 1978 to Jan. 31, 1991. Our aim is to fit a generalized Pareto model to the lower tail of the returns to estimate the probability of extreme losses. We start the analysis by loading the finance library and the data set dyr.dat :

  library("finance")
  dyr=read("dyr.dat")
A scatter plot of the data set can be obtained using the command
  plot(1:rows(dyr)~dyr)
In the Academic Version of XploRe the following examples can be executed with the smaller data set dyr1000.dat . Although slightly different results are obtained, one can still recognize that the Hill estimator is unsuited for that data set.

Figure 13.3: Scatter plot of daily returns of Yen related to U.S. Dollar from Dec. 1978 to Jan. 1991
\includegraphics[scale=0.425]{xtrfig4}

One recognizes from Figure 13.3 that the distribution of the returns possesses a fat tail. Because our estimators are defined for the upper tail, one must change the sign of the data set with the command

  dyr = -dyr
A suitable threshold can be selected by plotting an estimator diagram. The call
  r=momentgpdiag(dyr,5:500)
  plot(5:500~r)
produces the diagram in Figure 13.4. We select $ k=160$ extremes (yielding the threshold $ t=0.00966$) and plot the empirical quantile function as well as the estimated parametric one to check the quality of the fit.

Figure 13.4: Diagram of moment estimator applied to daily returns.
\includegraphics[scale=0.425]{xtrfig2}

This task is performed by the following code (calls to format the graphical output are not shown):

  m=momentgp(dyr,160)

  d=createdisplay(1,1)
  t=aseq(0.965,350,0.0001)
  qf=t~m.mu+m.sigma*qfx("gp",t,m.gamma)
  show(d,1,1,qf)

  empqf=(4284:4444)/4445~sort(dyr)[4284:4444]
  adddata(d,1,1,empqf)
32498 XLGxtrm01.xpl

The resulting plot is shown in Figure 13.5.

Figure 13.5: GP qf fitted to tail of returns.
\includegraphics[scale=0.425]{xtrfig5}

The Hill estimator yields a similar picture (execute the following lines to add the pertaining Pareto quantile function to the plot).

  h=hillgp1(dyr,160)
  hqf=t~h.sigma*qfx("gp1",t,h.alpha)
  adddata(d,1,1,hqf)
32505 XLGxtrm01.xpl

To decide which estimator should be preferred, we employ the mean excess function. Execute the next lines to create the plot of the empirical mean excess function as well as the parametric ones that is shown in Figure 13.6.
  h=hillgp1(dyr,160)
  m=momentgp(dyr,160)
  d=createdisplay(1,1)
  t=aseq(0.009,210,0.0001)
  ;
  ; plot empirical mean excess function
  ;
  et=sort(dyr)[rows(dyr)-160:rows(dyr)-1]
  eme=et~empme(dyr,et)
  show(d,1,1,eme)
  ;
  hme=t~gp1me(h.alpha,t/h.sigma)*h.sigma
  adddata(d,1,1,hme)
  ;
  mme=t~gpme(m.gamma,(t-m.mu)/m.sigma)*m.sigma
  adddata(d,1,1,mme)
32511 XLGxtrm02.xpl

Figure 13.6: Empirical mean excess function (solid) and GP mean excess function fitted by Hill (dotted) and Moment estimator (dashed).
\includegraphics[scale=0.425]{xtrfig6}

One can recognize that the empirical mean excess function is close to a straight line, which justifies the GP modeling. Yet, the GP mean excess function, based on the Hill estimator, strongly deviates from the empirical mean excess function. This indicates that the Hill estimator is not applicable.