Learn R Programming

spd (version 2.0-1)

spd-methods: Method: Semi-Parametric Distribution

Description

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

Usage

dspd(x, fit, linear)
pspd(q, fit, linear)
qspd(p, fit, linear)
rspd(n, fit, linear)

Arguments

n
[rspd] - the number of random deviates to be generated from fitted distribution.
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] - a numeric vector of quantiles.
fit
[all] - the object of class SPDFIT created by calling the spdfit function.
linear
[all] - logical, if TRUE interior smoothing function uses linear interpolation rather than constant.

Value

  • 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.

References

Embrechts, P., Klueppelberg, C., Mikosch, T. (1997); Modelling Extremal Events, Springer. Carmona, R. (2004);Statistical Anlaysis of Financial Data in Splus, Springer.

Examples

Run this code
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)

Run the code above in your browser using DataLab