R : Copyright 2005, The R Foundation for Statistical Computing Version 2.1.1 (2005-06-20), ISBN 3-900051-07-0 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for a HTML browser interface to help. Type 'q()' to quit R. > ### *
> ### > attach(NULL, name = "CheckExEnv") > assign(".CheckExEnv", as.environment(2), pos = length(search())) # base > ## add some hooks to label plot pages for base and grid graphics > setHook("plot.new", ".newplot.hook") > setHook("persp", ".newplot.hook") > setHook("grid.newpage", ".gridplot.hook") > > assign("cleanEx", + function(env = .GlobalEnv) { + rm(list = ls(envir = env, all.names = TRUE), envir = env) + RNGkind("default", "default") + set.seed(1) + options(warn = 1) + delayedAssign("T", stop("T used instead of TRUE"), + assign.env = .CheckExEnv) + delayedAssign("F", stop("F used instead of FALSE"), + assign.env = .CheckExEnv) + sch <- search() + newitems <- sch[! sch %in% .oldSearch] + for(item in rev(newitems)) + eval(substitute(detach(item), list(item=item))) + missitems <- .oldSearch[! .oldSearch %in% sch] + if(length(missitems)) + warning("items ", paste(missitems, collapse=", "), + " have been removed from the search path") + }, + env = .CheckExEnv) > assign("..nameEx", "__{must remake R-ex/*.R}__", env = .CheckExEnv) # for now > assign("ptime", proc.time(), env = .CheckExEnv) > grDevices::postscript("evir-Examples.ps") > assign("par.postscript", graphics::par(no.readonly = TRUE), env = .CheckExEnv) > options(contrasts = c(unordered = "contr.treatment", ordered = "contr.poly")) > options(warn = 1) > library('evir') > > assign(".oldSearch", search(), env = .CheckExEnv) > assign(".oldNS", loadedNamespaces(), env = .CheckExEnv) > cleanEx(); ..nameEx <- "decluster" > > ### * decluster > > flush(stderr()); flush(stdout()) > > ### Name: decluster > ### Title: Decluster Point Process > ### Aliases: decluster > ### Keywords: manip > > ### ** Examples > > # decluster the 200 exceedances of a particular threshold in > # the negative BMW data > data(bmw) > out <- pot(-bmw, ne = 200) > decluster(out$data, 30) Declustering picture... Data reduced from 200 to 70 [1] 0.05525992 0.05084288 0.06689143 0.06887800 0.04688708 0.10617520 [7] 0.05865478 0.04071008 0.02896766 0.02913723 0.04122546 0.03094040 [13] 0.02659780 0.03465775 0.02606819 0.02710781 0.06955422 0.03859640 [19] 0.03845126 0.06807869 0.02732490 0.04194781 0.02563799 0.04957226 [25] 0.03744841 0.02652559 0.03021099 0.04541566 0.02695412 0.03051167 [31] 0.03984488 0.02648610 0.04525858 0.03938106 0.03236528 0.05561317 [37] 0.03191673 0.04609111 0.06519183 0.03668970 0.03540193 0.04491698 [43] 0.04880244 0.04565154 0.04148352 0.02619353 0.10852160 0.02954286 [49] 0.03225168 0.14061565 0.02895132 0.02834847 0.03360120 0.07529138 [55] 0.04328683 0.03405556 0.02677080 0.03221330 0.10577463 0.02764203 [61] 0.05806183 0.03004121 0.03973532 0.02892858 0.02688352 0.04001846 [67] 0.03412405 0.03232889 0.03123302 0.03490287 attr(,"times") [1] "1973-02-05 01:00:00 CET" "1973-07-26 02:00:00 CEST" [3] "1973-11-14 01:00:00 CET" "1973-12-31 01:00:00 CET" [5] "1974-05-09 01:00:00 CET" "1974-07-05 02:00:00 CEST" [7] "1974-09-30 01:00:00 CET" "1975-05-27 01:00:00 CET" [9] "1976-04-06 01:00:00 CET" "1976-07-28 02:00:00 CEST" [11] "1976-10-12 01:00:00 CET" "1976-11-15 01:00:00 CET" [13] "1977-02-18 01:00:00 CET" "1977-07-08 02:00:00 CEST" [15] "1977-12-06 01:00:00 CET" "1978-06-21 02:00:00 CEST" [17] "1979-07-11 02:00:00 CEST" "1980-01-21 01:00:00 CET" [19] "1980-03-18 01:00:00 CET" "1980-06-20 02:00:00 CEST" [21] "1980-09-08 02:00:00 CEST" "1981-01-27 01:00:00 CET" [23] "1981-04-29 02:00:00 CEST" "1981-06-26 02:00:00 CEST" [25] "1981-08-25 02:00:00 CEST" "1982-04-27 02:00:00 CEST" [27] "1982-08-17 02:00:00 CEST" "1982-09-27 01:00:00 CET" [29] "1983-01-24 01:00:00 CET" "1983-07-12 02:00:00 CEST" [31] "1984-02-09 01:00:00 CET" "1984-03-12 01:00:00 CET" [33] "1984-07-05 02:00:00 CEST" "1984-10-19 01:00:00 CET" [35] "1985-03-25 01:00:00 CET" "1985-07-10 02:00:00 CEST" [37] "1985-09-13 02:00:00 CEST" "1985-11-05 01:00:00 CET" [39] "1986-02-27 01:00:00 CET" "1986-04-28 02:00:00 CEST" [41] "1986-06-03 02:00:00 CEST" "1986-07-04 02:00:00 CEST" [43] "1986-09-05 02:00:00 CEST" "1987-02-04 01:00:00 CET" [45] "1987-04-27 02:00:00 CEST" "1987-06-02 02:00:00 CEST" [47] "1987-11-09 01:00:00 CET" "1988-03-25 01:00:00 CET" [49] "1988-05-11 02:00:00 CEST" "1989-10-16 01:00:00 CET" [51] "1990-01-04 01:00:00 CET" "1990-02-26 01:00:00 CET" [53] "1990-04-23 02:00:00 CEST" "1990-09-25 02:00:00 CEST" [55] "1991-01-14 01:00:00 CET" "1991-02-26 01:00:00 CET" [57] "1991-05-17 02:00:00 CEST" "1991-06-28 02:00:00 CEST" [59] "1991-08-19 02:00:00 CEST" "1992-05-13 02:00:00 CEST" [61] "1992-09-24 02:00:00 CEST" "1993-01-25 01:00:00 CET" [63] "1993-05-14 02:00:00 CEST" "1993-07-27 02:00:00 CEST" [65] "1993-11-22 01:00:00 CET" "1994-06-20 02:00:00 CEST" [67] "1994-11-23 01:00:00 CET" "1995-03-09 01:00:00 CET" [69] "1995-09-22 02:00:00 CEST" "1995-10-23 01:00:00 CET" > > > > cleanEx(); ..nameEx <- "emplot" > > ### * emplot > > flush(stderr()); flush(stdout()) > > ### Name: emplot > ### Title: Plot of Empirical Distribution Function > ### Aliases: emplot > ### Keywords: hplot > > ### ** Examples > > ## Not run: data(danish) > ## Not run: emplot(danish) > # Danish fire insurance data show Pareto tail behaviour > > > > cleanEx(); ..nameEx <- "exindex" > > ### * exindex > > flush(stderr()); flush(stdout()) > > ### Name: exindex > ### Title: Estimate Extremal Index > ### Aliases: exindex > ### Keywords: hplot > > ### ** Examples > > ## Not run: data(bmw) > ## Not run: exindex(bmw, 100) > ## Not run: exindex(-bmw, 100) > # calculate extremal index for the right and left tails of the BMW > # log returns > > > > cleanEx(); ..nameEx <- "findthresh" > > ### * findthresh > > flush(stderr()); flush(stdout()) > > ### Name: findthresh > ### Title: Find Threshold > ### Aliases: findthresh > ### Keywords: manip > > ### ** Examples > > # Find threshold giving (at least) fifty exceedances for Danish data > data(danish) > findthresh(danish, 50) [1] 17.06847 > > > > cleanEx(); ..nameEx <- "gev" > > ### * gev > > flush(stderr()); flush(stdout()) > > ### Name: gev > ### Title: Fit Generalized Extreme Value Distribution > ### Aliases: gev > ### Keywords: models > > ### ** Examples > > # Fit GEV to monthly maxima > data(bmw) > out <- gev(bmw, "month") > # Fit GEV to maxima of blocks of 100 observations > out <- gev(bmw, 100) > # Fit GEV to the data in nidd.annual, the annual maximum water > # levels of the River Nidd, using the "BFGS" optimization method > data(nidd.annual) > out <- gev(nidd.annual, method = "BFGS", control = list(maxit = 500)) > > > > cleanEx(); ..nameEx <- "gpd" > > ### * gpd > > flush(stderr()); flush(stdout()) > > ### Name: gpd > ### Title: Fit Generalized Pareto Model > ### Aliases: gpd > ### Keywords: models > > ### ** Examples > > data(danish) > out <- gpd(danish, 10) > # Fits GPD to excess losses over 10 for the Danish > # fire insurance data > > > > cleanEx(); ..nameEx <- "gpd.q" > > ### * gpd.q > > flush(stderr()); flush(stdout()) > > ### Name: gpd.q > ### Title: Add Quantile Estimates to plot.gpd > ### Aliases: gpd.q > ### Keywords: iplot > > ### ** Examples > > ## Not run: data(danish) > ## Not run: out <- gpd(danish, 10) > ## Not run: tp <- tailplot(out) > ## Not run: gpd.q(tp, 0.999) > # Estimates 99.9th percentile of Danish fire losses > > > > cleanEx(); ..nameEx <- "gpd.sfall" > > ### * gpd.sfall > > flush(stderr()); flush(stdout()) > > ### Name: gpd.sfall > ### Title: Add Expected Shortfall Estimates to a GPD Plot > ### Aliases: gpd.sfall > ### Keywords: iplot > > ### ** Examples > > ## Not run: data(danish) > ## Not run: out <- gpd(danish, 10) > ## Not run: tp <- tailplot(out) > ## Not run: gpd.q(tp, 0.999) > # Estimates 99.9th percentile of Danish fire losses > ## Not run: gpd.sfall(tp, 0.999) > # Estimates associated expected shortfall for Danish fire losses > > > > cleanEx(); ..nameEx <- "gpdbiv" > > ### * gpdbiv > > flush(stderr()); flush(stdout()) > > ### Name: gpdbiv > ### Title: Implements Bivariate POT Method > ### Aliases: gpdbiv > ### Keywords: models > > ### ** Examples > > data(bmw) ; data(siemens) > out <- gpdbiv(-bmw, -siemens, ne1 = 100, ne2 = 100) > interpret.gpdbiv(out, 0.05, 0.05) Thresholds: 0.0342151 0.02688724 Extreme levels of interest (x,y): 0.05 0.05 P(X exceeds x) 0.005060484 P(Y exceeds y) 0.002131820 P(X exceeds x AND Y exceeds y) 0.001316135 P(X exceeds x) * P(Y exceeds y) 1.078804e-05 P(Y exceeds y GIVEN X exceeds x) 0.2600809 P(X exceeds x GIVEN Y exceeds y) 0.6173762 > ## Not run: plot(out) > > > > cleanEx(); ..nameEx <- "gumbel" > > ### * gumbel > > flush(stderr()); flush(stdout()) > > ### Name: gumbel > ### Title: Fit Gumbel Distribution > ### Aliases: gumbel > ### Keywords: models > > ### ** Examples > > # Fit Gumbel to maxima of blocks of 100 observations > data(bmw) > out <- gumbel(bmw, 100) Warning in gumbel(bmw, 100) : final group contains only 46 observations > # Fit Gumbel to the data in nidd.annual, the annual maximum water > # levels of the River Nidd, using the "BFGS" optimization method > data(nidd.annual) > out <- gumbel(nidd.annual, method = "BFGS", control = list(maxit = 500)) > > > > cleanEx(); ..nameEx <- "hill" > > ### * hill > > flush(stderr()); flush(stdout()) > > ### Name: hill > ### Title: Create Hill Plot > ### Aliases: hill > ### Keywords: hplot > > ### ** Examples > > ## Not run: data(danish) > ## Not run: hill(danish) > # Hill plot of heavy-tailed Danish fire insurance data > ## Not run: hill(danish, option = "quantile", end = 500, p = 0.999) > # Hill plot of estimated 0.999 quantile of Danish fire insurance data > > > > cleanEx(); ..nameEx <- "interpret.gpdbiv" > > ### * interpret.gpdbiv > > flush(stderr()); flush(stdout()) > > ### Name: interpret.gpdbiv > ### Title: Interpret Results of Bivariate GPD Fit > ### Aliases: interpret.gpdbiv > ### Keywords: htest > > ### ** Examples > > data(bmw) ; data(siemens) > out <- gpdbiv(-bmw, -siemens, ne1 = 100, ne2 = 100) > interpret.gpdbiv(out, 0.05, 0.05) Thresholds: 0.0342151 0.02688724 Extreme levels of interest (x,y): 0.05 0.05 P(X exceeds x) 0.005060484 P(Y exceeds y) 0.002131820 P(X exceeds x AND Y exceeds y) 0.001316135 P(X exceeds x) * P(Y exceeds y) 1.078804e-05 P(Y exceeds y GIVEN X exceeds x) 0.2600809 P(X exceeds x GIVEN Y exceeds y) 0.6173762 > # probabilities of 5% falls in BMW and Siemens stock prices > > > > cleanEx(); ..nameEx <- "meplot" > > ### * meplot > > flush(stderr()); flush(stdout()) > > ### Name: meplot > ### Title: Sample Mean Excess Plot > ### Aliases: meplot > ### Keywords: hplot > > ### ** Examples > > ## Not run: data(danish) > ## Not run: meplot(danish) > # Sample mean excess plot of heavy-tailed Danish fire insurance data > > > > cleanEx(); ..nameEx <- "plot.gev" > > ### * plot.gev > > flush(stderr()); flush(stdout()) > > ### Name: plot.gev > ### Title: Plot Fitted GEV Model > ### Aliases: plot.gev > ### Keywords: hplot > > ### ** Examples > > data(bmw) > out <- gev(bmw, 100) > ## Not run: plot(out) > > ## Not run: Make a plot selection (or 0 to exit): > ## Not run: 1: plot: Scatterplot of Residuals > ## Not run: 2: plot: QQplot of Residuals > > > > cleanEx(); ..nameEx <- "plot.gpd" > > ### * plot.gpd > > flush(stderr()); flush(stdout()) > > ### Name: plot.gpd > ### Title: Plot Fitted GPD Model > ### Aliases: plot.gpd > ### Keywords: hplot > > ### ** Examples > > data(danish) > out <- gpd(danish, 10) > ## Not run: plot(out) > > ## Not run: Make a plot selection (or 0 to exit): > ## Not run: 1: plot: Excess Distribution > ## Not run: 2: plot: Tail of Underlying Distribution > ## Not run: 3: plot: Scatterplot of Residuals > ## Not run: 4: plot: QQplot of Residuals > > > > cleanEx(); ..nameEx <- "plot.gpdbiv" > > ### * plot.gpdbiv > > flush(stderr()); flush(stdout()) > > ### Name: plot.gpdbiv > ### Title: Plot Fitted Bivariate GPD Model > ### Aliases: plot.gpdbiv > ### Keywords: hplot > > ### ** Examples > > data(bmw) ; data(siemens) > out <- gpdbiv(-bmw, -siemens, ne1 = 100, ne2 = 100) > ## Not run: plot(out) > > ## Not run: Make a plot selection (or 0 to exit): > ## Not run: 1: plot: Exceedance data > ## Not run: 2: plot: Contours of Bivariate Distribution Function > ## Not run: 3: plot: Contours of Bivariate Survival Function > ## Not run: 4: plot: Tail of Marginal 1 > ## Not run: 5: plot: Tail of Marginal 2 > > > > cleanEx(); ..nameEx <- "plot.pot" > > ### * plot.pot > > flush(stderr()); flush(stdout()) > > ### Name: plot.pot > ### Title: Plot Fitted POT Model > ### Aliases: plot.pot > ### Keywords: hplot > > ### ** Examples > > data(danish) > out <- pot(danish,10) > ## Not run: plot(out) > > ## Not run: Make a plot selection (or 0 to exit): > ## Not run: 1: plot: Point Process of Exceedances > ## Not run: 2: plot: Scatterplot of Gaps > ## Not run: 3: plot: Qplot of Gaps > ## Not run: 4: plot: ACF of Gaps > ## Not run: 5: plot: Scatterplot of Residuals > ## Not run: 6: plot: Qplot of Residuals > ## Not run: 7: plot: ACF of Residuals > ## Not run: 8: plot: Go to GPD Plots > > > > cleanEx(); ..nameEx <- "pot" > > ### * pot > > flush(stderr()); flush(stdout()) > > ### Name: pot > ### Title: Peaks Over Thresholds Model > ### Aliases: pot > ### Keywords: models > > ### ** Examples > > data(danish) > out <- pot(danish, 10) > # Fits POT model to Danish fire insurance losses > > > > cleanEx(); ..nameEx <- "qplot" > > ### * qplot > > flush(stderr()); flush(stdout()) > > ### Name: qplot > ### Title: Exploratory QQplot for Extreme Value Analysis > ### Aliases: qplot > ### Keywords: hplot > > ### ** Examples > > ## Not run: data(danish) > ## Not run: qplot(danish) > # QQplot of heavy-tailed Danish fire insurance data > > > > cleanEx(); ..nameEx <- "quant" > > ### * quant > > flush(stderr()); flush(stdout()) > > ### Name: quant > ### Title: Plot of GPD Tail Estimate of a High Quantile > ### Aliases: quant > ### Keywords: hplot > > ### ** Examples > > ## Not run: data(danish) > ## Not run: quant(danish, 0.999) > # Estimates of the 99.9th percentile of the Danish losses using > # the GPD model with various thresholds > > > > cleanEx(); ..nameEx <- "records" > > ### * records > > flush(stderr()); flush(stdout()) > > ### Name: records > ### Title: Calculate Record Development > ### Aliases: records > ### Keywords: hplot > > ### ** Examples > > ## Not run: data(danish) > ## Not run: records(danish) > # Record fire insurance losses in Denmark > > > > cleanEx(); ..nameEx <- "riskmeasures" > > ### * riskmeasures > > flush(stderr()); flush(stdout()) > > ### Name: riskmeasures > ### Title: Calculates Quantiles and Expected Shortfalls > ### Aliases: riskmeasures > ### Keywords: htest > > ### ** Examples > > data(danish) > out <- gpd(danish, 10) > riskmeasures(out, c(0.999, 0.9999)) p quantile sfall [1,] 0.9990 94.28956 191.3697 [2,] 0.9999 304.62448 609.3696 > # gives estimates of 0.999 and 0.9999 quantiles of Danish loss > # distribution as well as the associated expected shortfall estimates > > > > cleanEx(); ..nameEx <- "rlevel.gev" > > ### * rlevel.gev > > flush(stderr()); flush(stdout()) > > ### Name: rlevel.gev > ### Title: Calculate Return Levels Based on GEV Fit > ### Aliases: rlevel.gev > ### Keywords: htest > > ### ** Examples > > data(bmw) > out <- gev(bmw, "month") > # Fit GEV to monthly maxima of daily returns on BMW share price > ## Not run: rlevel.gev(out, 40) > # Calculate the 40 month return level > > > > cleanEx(); ..nameEx <- "shape" > > ### * shape > > flush(stderr()); flush(stdout()) > > ### Name: shape > ### Title: Plot for GPD Shape Parameter > ### Aliases: shape > ### Keywords: hplot > > ### ** Examples > > ## Not run: data(danish) > ## Not run: shape(danish) > # Shape plot of heavy-tailed Danish fire insurance data > > > > cleanEx(); ..nameEx <- "tailplot" > > ### * tailplot > > flush(stderr()); flush(stdout()) > > ### Name: tailplot > ### Title: Plot Tail Estimate From GPD Model > ### Aliases: tailplot > ### Keywords: hplot > > ### ** Examples > > data(danish) > out <- gpd(danish, 10) > ## Not run: tailplot(out) > > > > ### *