## SOURCE("fExtremes.51A-ExtremesData")
## emdPlot -
xmpExtremes("Start: Empirical Distribution Function >")
# Danish fire insurance data show Pareto tail behaviour:
par(mfrow = c(2, 2))
data(danish)
emdPlot(danish, plottype = "xy", labels = FALSE)
title(xlab = "x", ylab = "1-F(x)", main = "Danish Fire")
# BMW Stocks:
data(bmw)
emdPlot(bmw, plottype = "xy", labels = FALSE)
title(xlab = "x", ylab = "1-F(x)", main = "BMW Stocks")
# Simulated Student-t:
emdPlot(rt(5000, 4), plottype = "xy")
## qqPlot -
xmpExtremes("Next: Quantile-Quantile Plot >")
# QQ-Plot of Simulated Normal rvs:
par(mfrow = c(2, 2))
set.seed(4711)
qqPlot(rnorm(5000))
text(-3.5, 3, pos = 4, "Simulated Normal rvs")
# QQ-Plot of simulated Student-t rvs:
qqPlot(rt(5000, 4))
text(-3.5, 11.0, pos = 4, "Simulated Student-t rvs")
# QQ-Plot of BMW share residuals:
data(bmw)
qqPlot(bmw)
text(-3.5, 0.09, pos = 4, "BMW log returns")
## qPlot -
xmpExtremes("Next: QQ-Plot of Heavy Tails >")
# QQ-Plot of heavy-tailed Danish fire insurance data:
data(danish)
qPlot(danish)
## mePlot -
xmpExtremes("Next: Mean Excess Plot >")
# Sample mean excess plot of heavy-tailed Danish fire
# insurance data
par(mfrow = c(3, 2))
data(danish)
mePlot(danish, labels = FALSE)
title(xlab = "u", ylab = "e", main = "mePlot - Danish Fire Data")
## mrlPlot -
xmpExtremes("Next: mean Residual Live Plot >")
# Sample mean residual live plot of heavy-tailed Danish Fire
# insurance data
mrlPlot(danish, labels = FALSE)
title(xlab = "u", ylab = "e", main = "mrlPlot - Danish Fire Data")
## mxfPlot -
xmpExtremes("Next: Mean Excess Function Plot >")
# Plot the mean excess functions for randomly distributed
# residuals
par(mfrow = c(2, 2))
n = 10000
set.seed(4711)
xlab = "Threshold: u"; ylab = "Mean Excess: e"
mxfPlot(rnorm(n), tail = 0.5, labels = FALSE)
title(xlab = xlab, ylab = ylab, main = "mxf Plot - Normal DF")
set.seed(7138)
mxfPlot(rexp(n, 2), tail = 0.5, labels = FALSE)
title(xlab = xlab, ylab = ylab, main = "mxfPlot - Exponential DF")
abline(1/2, 0)
set.seed(6952)
mxfPlot(rlnorm(n, 0, 2), tail = 0.5, xlim = c(0,90),
ylim = c(0, 120), labels = FALSE)
title(xlab = xlab, ylab = ylab, main = "mxfPlot - Lognormal DF")
set.seed(8835)
mxfPlot(rgpd(n, 1/2), tail = 0.10, xlim = c(0,200),
ylim=c(0,200), labels = FALSE)
title(xlab = xlab, ylab = ylab, main = "mxfPlot - Pareto")
abline(0, 1)
## msratioPlot -
xmpExtremes("Next: Maximum/Sum Ratio Plot >")
# Examples for Ratio of Maximum and Sum Plots:
par(mfrow = c(3, 2))
data(bmw)
xlab = "n"; ylab = "R(n)"
msratioPlot (rnorm(8000), labels = FALSE)
title(xlab = xlab, ylab = ylab, main = "Standard Normal")
msratioPlot (rexp(8000), labels = FALSE)
title(xlab = xlab, ylab = ylab, main = "Exponential")
msratioPlot (rt(8000, 4), labels = FALSE)
title(xlab = xlab, ylab = ylab, main = "Student-t")
msratioPlot (rcauchy(8000), labels = FALSE)
title(xlab = xlab, ylab = ylab, main = "Cauchy")
msratioPlot (bmw, labels = FALSE)
title(xlab = xlab, ylab = ylab, main = "BMW Returns")
## recordsPlot -
xmpExtremes("Next: Records Plot >")
# Record fire insurance losses in Denmark
par(mfrow = c(2, 2))
data(danish)
recordsPlot(danish)
text(1, 7.9, pos = 4, "Danish Fire")
# BMW Stocks
data(bmw)
recordsPlot(bmw)
text(1, 12.8, pos = 4, "BMW Shares")
## ssrecordsPlot -
xmpExtremes("Next: Subsample Record Plot >")
# Record fire insurance losses in Denmark
ssrecordsPlot(danish)
text(1, 9.2, pos = 4, "Danish Fire")
# BMW Stocks
ssrecordsPlot(bmw)
text(1, 10.5, pos = 4, "BMW Shares")
## xacfPlot -
xmpExtremes("Next: ACF Plot of Exceedences >")
# Plot ACF of Heights/Distances of Eceedences over threshold:
par(mfrow = c(2, 2))
data(bmw)
xacfPlot(bmw)
## findThreshold -
xmpExtremes("Start: Find Thresold >")
# Find threshold giving (at least) fifty exceedances
# for Danish Fire data
data(danish)
findThreshold(danish, n = c(10, 50, 100))
## blockMaxima -
xmpExtremes("Next: Compute Block Maxima >")
# Block Maxima (Minima) for the right and left tails
# of the BMW log returns:
data(bmw)
par(mfrow = c(2, 1))
blockMaxima( bmw, block = 100)
blockMaxima(-bmw, block = 100)
## deCluster -
xmpExtremes("Next: De-Cluster Exceedences >")
# Decluster the 200 exceedances of a particular
# threshold in the negative BMW log-return data
par(mfrow = c(2, 2))
fit = potFit(-bmw, nextremes = 200)
deCluster(fit$fit$data, 30)
Run the code above in your browser using DataLab