# ExtremeIndex: Extremal Index Estimation In fExtremes: Rmetrics - Modelling Extreme Events in Finance

## Description

A collection and description of functions to simulate time series with a known extremal index, and to estimate the extremal index by four different kind of methods, the blocks method, the reciprocal mean cluster size method, the runs method, and the method of Ferro and Segers.

The functiona are:

 `thetaSim` Simulates a time Series with known theta, `blockTheta` Computes theta from Block Method, `clusterTheta` Computes theta from Reciprocal Cluster Method, `runTheta` Computes theta from Run Method, `ferrosegersTheta` Computes Theta according to Ferro and Seegers, `exindexPlot` Calculate and Plot Theta(1,2,3), `exindexesPlot` Calculate Theta(1,2) and Plot Theta(1).

## Usage

 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19``` ```## S4 method for signature 'fTHETA' show(object) thetaSim(model = c("max", "pair"), n = 1000, theta = 0.5) blockTheta(x, block = 22, quantiles = seq(0.950, 0.995, length = 10), title = NULL, description = NULL) clusterTheta(x, block = 22, quantiles = seq(0.950, 0.995, length = 10), title = NULL, description = NULL) runTheta(x, block = 22, quantiles = seq(0.950, 0.995, length = 10), title = NULL, description = NULL) ferrosegersTheta(x, quantiles = seq(0.950, 0.995, length = 10), title = NULL, description = NULL) exindexPlot(x, block = c("monthly", "quarterly"), start = 5, end = NA, doplot = TRUE, plottype = c("thresh", "K"), labels = TRUE, ...) exindexesPlot(x, block = 22, quantiles = seq(0.950, 0.995, length = 10), doplot = TRUE, labels = TRUE, ...) ```

## Arguments

 `block` [*Theta] - an integer value, the block size. Currently only integer specified block sizes are supported. [exindex*Plot] - the block size. Either `"monthly"`, `"quarterly"` or an integer value. An integer value is interpreted as the number of data values in each successive block. The default value is `"monthly"` which correpsond for daily data to an approximately 22-day periods. `description` a character string which allows for a brief description. `doplot` a logical, should the results be plotted? `labels` whether or not axes should be labelled. If set to `FALSE` then user specified lables can be passed through the `"..."` argument. `model` [thetaSim] - a character string denoting the name of the model. Either `"max"` or `"pair"`, the first representing the maximimum Frechet series, and the second the paired exponential series. `n` [thetaSim] - an integer value, the length of the time series to be generated. `object` an object of class `"fTHETA"` as returned by the functions `*Theta`. `plottype` [exindexPlot] - whether plot is to be by increasing threshold (`thresh`) or increasing K value (`K`). `quantiles` [exindexesPlot] - a numeric vector of quantile values. `start, end` [exindexPlot] - `start` is the lowest value of `K` at which to plot a point, and `end` the highest value; `K` is the number of blocks in which a specified threshold is exceeded. `theta` [thetaSim] - a numeric value between 0 and 1 setting the value of the extremal index for the maximum Frechet time series. (Not used in the case of the paired exponential series.) `title` a character string which allows for a project title. `x` a 'timeSeries' object or any other object which can be transformed by the function `as.vector` into a numeric vector. `"monthly"` and `"quarterly"` blocks require `x` to be an object of class `"timeSeries"`. `...` additional arguments passed to the plot function.

## Value

`exindexPlot`
returns a data frame of results with the following columns: `N`, `K`, `un`, `theta2`, and `theta`. A plot with `K` on the lower x-axis and threshold Values on the upper x-axis versus the extremal index is displayed.

`exindexesPlot`
returns a data.frame with four columns: `thresholds`, `theta1`, `theta2`, and `theta3`. A plot with quantiles on the x-axis and versus the extremal indexes is displayed.

## Author(s)

Alexander McNeil, for parts of the `exindexPlot` function, and
Diethelm Wuertz for the `exindexesPlot` function.

## References

Embrechts, P., Klueppelberg, C., Mikosch, T. (1997); Modelling Extremal Events, Springer. Chapter 8, 413–429.

`hillPlot`, `gevFit`.

## Examples

 ``` 1 2 3 4 5 6 7 8 9 10 11``` ```## Extremal Index for the right and left tails ## of the BMW log returns: data(bmwRet) par(mfrow = c(2, 2), cex = 0.7) exindexPlot( as.timeSeries(bmwRet), block = "quarterly") exindexPlot(-as.timeSeries(bmwRet), block = "quarterly") ## Extremal Index for the right and left tails ## of the BMW log returns: exindexesPlot( as.timeSeries(bmwRet), block = 65) exindexesPlot(-as.timeSeries(bmwRet), block = 65) ```

### Example output

```Loading required package: timeDate

Rmetrics Package fBasics
Analysing Markets and calculating Basic Statistics
Copyright (C) 2005-2014 Rmetrics Association Zurich
Educational Software for Financial Engineering and Computational Science
Rmetrics is free software and comes with ABSOLUTELY NO WARRANTY.
https://www.rmetrics.org --- Mail to: info@rmetrics.org
N  K         un    theta2     theta
1    5  5 0.08502851 1.0000000 1.0220368
2    6  6 0.07947459 1.0000000 1.0276218
3    8  7 0.07356377 0.8750000 0.9040559
4   10  8 0.06993022 0.8000000 0.8311017
5   11  9 0.06860589 0.8181818 0.8547711
6   12 10 0.06841199 0.8333333 0.8755451
7   13 11 0.06767476 0.8461538 0.8941150
8   15 12 0.06634279 0.8000000 0.8501742
9   16 13 0.06628046 0.8125000 0.8685126
10  17 14 0.06627812 0.8235294 0.8855087
11  20 15 0.05909805 0.7500000 0.8111325
12  21 16 0.05814339 0.7619048 0.8289841
13  23 17 0.05777954 0.7391304 0.8090475
14  24 18 0.05717683 0.7500000 0.8260107
15  26 19 0.05700682 0.7307692 0.8097854
16  28 20 0.05559860 0.7142857 0.7964470
17  29 21 0.05408877 0.7241379 0.8125826
18  31 22 0.05166061 0.7096774 0.8014279
19  32 23 0.05128512 0.7187500 0.8169703
20  33 24 0.05106974 0.7272727 0.8321155
21  35 25 0.05046767 0.7142857 0.8226489
22  38 26 0.04774362 0.6842105 0.7932093
23  39 27 0.04770410 0.6923077 0.8080891
24  40 28 0.04740888 0.7000000 0.8227289
25  42 29 0.04676699 0.6904762 0.8171619
26  43 30 0.04619415 0.6976744 0.8315473
27  44 31 0.04524335 0.7045455 0.8457803
28  46 32 0.04470772 0.6956522 0.8411246
29  47 33 0.04428878 0.7021277 0.8552269
30  53 34 0.04331344 0.6415094 0.7869202
31  62 35 0.04132586 0.5645161 0.6972745
32  64 36 0.04099796 0.5625000 0.7000752
33  65 37 0.04099124 0.5692308 0.7139833
34  67 38 0.04069590 0.5671642 0.7169668
35  68 39 0.04052802 0.5735294 0.7308400
36  69 40 0.04031627 0.5797101 0.7447417
37  71 41 0.04012086 0.5774648 0.7479391
38  73 42 0.04006161 0.5753425 0.7513952
39  79 43 0.03901445 0.5443038 0.7166364
40  81 44 0.03842747 0.5432099 0.7213444
41  84 45 0.03807012 0.5357143 0.7175484
42  89 46 0.03727675 0.5168539 0.6982656
43  90 47 0.03726731 0.5222222 0.7119538
44  92 48 0.03679377 0.5217391 0.7178373
45  93 49 0.03643146 0.5268817 0.7317598
46  95 50 0.03609579 0.5263158 0.7379425
47  97 51 0.03595831 0.5257732 0.7443409
48  99 52 0.03540772 0.5252525 0.7509631
49 101 53 0.03514756 0.5247525 0.7578184
50 103 54 0.03500941 0.5242718 0.7649165
51 104 55 0.03452181 0.5288462 0.7797583
52 107 56 0.03425181 0.5233645 0.7798859
53 111 57 0.03366442 0.5135135 0.7734600
54 123 58 0.03309369 0.4715447 0.7176033
55 142 59 0.03136727 0.4154930 0.6386410
56 148 60 0.03091335 0.4054054 0.6302252
57 152 61 0.03043850 0.4013158 0.6312448
58 153 62 0.03040552 0.4052288 0.6452854
59 159 63 0.03002665 0.3962264 0.6386869
60 165 64 0.02972372 0.3878788 0.6331032
61 168 65 0.02967623 0.3869048 0.6398440
62 174 66 0.02939661 0.3793103 0.6356322
63 181 67 0.02910800 0.3701657 0.6287536
64 182 68 0.02901700 0.3736264 0.6438596
65 183 69 0.02897511 0.3770492 0.6594960
66 193 70 0.02839504 0.3626943 0.6437149
67 194 71 0.02837364 0.3659794 0.6599239
68 198 72 0.02820872 0.3636364 0.6663709
69 200 73 0.02813696 0.3650000 0.6802685
70 204 74 0.02792824 0.3627451 0.6879089
71 208 75 0.02777174 0.3605769 0.6962559
72 221 76 0.02706787 0.3438914 0.6761348
73 227 77 0.02674273 0.3392070 0.6800346
74 232 78 0.02665524 0.3362069 0.6879523
75 233 79 0.02656937 0.3390558 0.7090750
76 267 80 0.02478442 0.2996255 0.6393667
77 273 81 0.02467931 0.2967033 0.6483589
78 299 82 0.02359398 0.2742475 0.6135391
79 312 83 0.02297398 0.2660256 0.6109630
80 319 84 0.02268866 0.2633229 0.6223163
81 326 85 0.02224307 0.2607362 0.6354953
82 342 86 0.02173349 0.2514620 0.6332502
83 344 87 0.02170679 0.2529070 0.6609209
84 373 88 0.02082339 0.2359249 0.6408374
85 403 89 0.02015991 0.2208437 0.6265744
86 407 90 0.02004808 0.2211302 0.6611411
87 412 91 0.01988137 0.2208738 0.7023112
88 442 92 0.01913396 0.2081448 0.7122501
89 455 93 0.01893024 0.2043956 0.7722222
90 556 94 0.01714157 0.1690647 0.7388529
N  K         un     theta2     theta
1     9  5 0.06955422 0.55555556 0.5676133
2    10  6 0.06887800 0.60000000 0.6163722
3    11  7 0.06807869 0.63636364 0.6573346
4    15  8 0.06519183 0.53333333 0.5538421
5    17  9 0.05806183 0.52941176 0.5528167
6    20 10 0.05561317 0.50000000 0.5249845
7    22 11 0.05525992 0.50000000 0.5279530
8    24 12 0.05188483 0.50000000 0.5309689
9    25 13 0.05084288 0.52000000 0.5554401
10   28 14 0.04957226 0.50000000 0.5371479
11   31 15 0.04880244 0.48387097 0.5228416
12   32 16 0.04845330 0.50000000 0.5435324
13   33 17 0.04743187 0.51515152 0.5634213
14   35 18 0.04688708 0.51428571 0.5658987
15   38 19 0.04609111 0.50000000 0.5535207
16   39 20 0.04565154 0.51282051 0.5712943
17   40 21 0.04541566 0.52500000 0.5885929
18   42 22 0.04525858 0.52380952 0.5909984
19   45 23 0.04466626 0.51111111 0.5803393
20   49 24 0.04328683 0.48979592 0.5596713
21   54 25 0.04194781 0.46296296 0.5323699
22   59 26 0.04148352 0.44067797 0.5100027
23   60 27 0.04122546 0.45000000 0.5243553
24   62 28 0.04071008 0.45161290 0.5298371
25   64 29 0.04001846 0.45312500 0.5352966
26   66 30 0.03984488 0.45454545 0.5407453
27   67 31 0.03973532 0.46268657 0.5543916
28   69 32 0.03938106 0.46376812 0.5596932
29   74 33 0.03859640 0.44594595 0.5419830
30   78 34 0.03744841 0.43589744 0.5336061
31   83 35 0.03668970 0.42168675 0.5199577
32   89 36 0.03511537 0.40449438 0.5023913
33   93 37 0.03490287 0.39784946 0.4978729
34   95 38 0.03474840 0.40000000 0.5044870
35   97 39 0.03465775 0.40206186 0.5111205
36  101 40 0.03412405 0.39603960 0.5074457
37  104 41 0.03378306 0.39423077 0.5092268
38  106 42 0.03360120 0.39622642 0.5160658
39  109 43 0.03353101 0.39449541 0.5181146
40  116 44 0.03236529 0.37931034 0.5022458
41  117 45 0.03232889 0.38461538 0.5137627
42  118 46 0.03225168 0.38983051 0.5253993
43  119 47 0.03221330 0.39495798 0.5371654
44  125 48 0.03123302 0.38400000 0.5268906
45  129 49 0.03051167 0.37984496 0.5259814
46  132 50 0.03012671 0.37878788 0.5294738
47  135 51 0.03004121 0.37777778 0.5331455
48  145 52 0.02913723 0.35862069 0.5107792
49  148 53 0.02896766 0.35810811 0.5151523
50  149 54 0.02895132 0.36241611 0.5267584
51  150 55 0.02892858 0.36666667 0.5385777
52  159 56 0.02800260 0.35220126 0.5225726
53  163 57 0.02764203 0.34969325 0.5244465
54  164 58 0.02732490 0.35365854 0.5363747
55  165 59 0.02710781 0.35757576 0.5485690
56  169 60 0.02695412 0.35502959 0.5509504
57  170 61 0.02688352 0.35882353 0.5635628
58  177 62 0.02659780 0.35028249 0.5566761
59  178 63 0.02652559 0.35393258 0.5696107
60  193 64 0.02606819 0.33160622 0.5399919
61  211 65 0.02505288 0.30805687 0.5076232
62  214 66 0.02485020 0.30841121 0.5150980
63  215 67 0.02476860 0.31162791 0.5278203
64  229 68 0.02392479 0.29694323 0.5097049
65  241 69 0.02356405 0.28630705 0.4983520
66  246 70 0.02337980 0.28455285 0.5027888
67  255 71 0.02308842 0.27843137 0.4994964
68  257 72 0.02295675 0.28015564 0.5108542
69  259 73 0.02273563 0.28185328 0.5227077
70  263 74 0.02272718 0.28136882 0.5309486
71  282 75 0.02185151 0.26595745 0.5103622
72  289 76 0.02169963 0.26297578 0.5140897
73  310 77 0.02111121 0.24838710 0.4944831
74  314 78 0.02092427 0.24840764 0.5047865
75  323 79 0.02060147 0.24458204 0.5076223
76  342 80 0.02019178 0.23391813 0.4959875
77  344 81 0.02014457 0.23546512 0.5114477
78  384 82 0.01930148 0.21354167 0.4742776
79  385 83 0.01929721 0.21558442 0.4920408
80  439 84 0.01832385 0.19134396 0.4475760
81  446 85 0.01821111 0.19058296 0.4597481
82  469 86 0.01775376 0.18336887 0.4567505
83  472 87 0.01772653 0.18432203 0.4764060
84  474 88 0.01765599 0.18565401 0.4999094
85  483 89 0.01745796 0.18426501 0.5191853
86  518 90 0.01687691 0.17374517 0.5144854
87  589 91 0.01559548 0.15449915 0.4837260
88  609 92 0.01520563 0.15106732 0.5094261
89  721 93 0.01341753 0.12898752 0.4759909
90 1024 94 0.01051625 0.09179688 0.3844014
quantiles thresholds    theta1    theta2     theta3
1      0.950 0.02317123 0.6709388 0.2745098 0.04248366
2      0.955 0.02456731 0.6876392 0.2981818 0.06181818
3      0.960 0.02586054 0.6656592 0.3183673 0.08979592
4      0.965 0.02726772 0.6677954 0.3457944 0.11214953
5      0.970 0.02897511 0.6502202 0.3715847 0.15300546
6      0.975 0.03040552 0.6169275 0.3921569 0.20261438
7      0.980 0.03309369 0.6655263 0.4471545 0.25203252
8      0.985 0.03679377 0.7246781 0.5217391 0.31521739
9      0.990 0.04132586 0.7025594 0.5645161 0.50000000
10     0.995 0.05166061 0.8916387 0.7741935 0.67741935
quantiles thresholds    theta1    theta2     theta3
1      0.950 0.02129113 0.5495298 0.2581699 0.03921569
2      0.955 0.02210840 0.5712815 0.2800000 0.05090909
3      0.960 0.02343573 0.5459433 0.2938776 0.06122449
4      0.965 0.02485020 0.5382960 0.3130841 0.09813084
5      0.970 0.02642584 0.5746327 0.3478261 0.13586957
6      0.975 0.02867510 0.5494520 0.3660131 0.18300654
7      0.980 0.03135542 0.5084452 0.3739837 0.25203252
8      0.985 0.03498221 0.5252085 0.4130435 0.34782609
9      0.990 0.04071008 0.5564688 0.4677419 0.46774194
10     0.995 0.04880244 0.5258103 0.4838710 0.58064516
```

fExtremes documentation built on Nov. 17, 2017, 2:21 p.m.