Density, Distribution, Quantile and Random Number Generation methods for the Semi-Parametric Distribution.

1 2 3 4 |

`n` |
[rspd] - |

`p` |
a vector of probability levels, the desired probability for the quantile estimate (e.g. 0.99 for the 99th percentile). |

`x,q` |
[pspd,dspd] - |

`fit` |
[all] - |

`linear` |
[all] - |

All values are numeric vectors:

`d*`

returns the density (pdf),

`p*`

returns the probability (cdf),

`q*`

returns the quantiles (inverse cdf), and

`r*`

generates random deviates.

The density is computed using the generalized pareto distribution in the tails, while for the middle, the density is computed by using a smooth gradient approach. Interpolation is used to splice together the ends with the middle portion, providing for an approximate piecewise constant density function. As such, caution should be used when interpreting results obtained by use of this function.

Alec Stephenson for the functions from R\'s `evd`

package,

Alec Stephenson for the functions from R\'s `evir`

package,

Alexander McNeil for the EVIS functions underlying the `evir`

package,

Diethelm Wuetrz for the `fExtremes`

Implementation of the gpd,

Alexios Ghalanos for the SPD Implementation,

Embrechts, P., Klueppelberg, C., Mikosch, T. (1997); *Modelling Extremal
Events*, Springer.

Carmona, R. (2004);*Statistical Anlaysis of Financial Data in Splus*,
Springer.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | ```
## Not run:
library(MASS)
x = SP500/100
fit=spdfit(x, upper=0.9, lower=0.1)
## rspd -
par(mfrow = c(2, 2), cex = 0.7)
r = rspd(n = 1000, fit)
hist(r, n = 100, probability = TRUE, xlab = "r",
col = "steelblue", border = "white",main = "Density")
box()
## dspd -
# Plot empirical density and compare with true density:
r = rspd(n = 1000, fit)
hist(r, n = 100, probability = TRUE, xlab = "r",
col = "steelblue", border = "white",main = "Density")
box()
x = seq(-0.3, 0.3, length.out = 1000)
lines(x, dspd(x, fit), col = "darkorange",lwd=2)
## pspd -
# Plot df and compare with true df:
plot(sort(r), (1:length(r)/length(r)),
ylim = c(0, 1), pch = 19,
cex = 0.5, ylab = "p", xlab = "q", main = "CDF")
grid()
q = seq(-0.3, 0.3, length.out = 1000)
lines(q, pspd(q, fit), col = "darkorange",lwd=2)
## End(Not run)
``` |

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.

All documentation is copyright its authors; we didn't write any of that.