用 POT package
完整例子,肯定够用了——
##Simulate a sample from a GPD(0,1,0.2):
x <- rgpd(100, 0, 1, 0.2)
##Evaluate density at x=3 and probability of non-exceedance:
dgpd(3, 0, 1, 0.2); pgpd(3, 0, 1, 0.2)
##Compute the quantile with non-exceedance probability 0.95:
qgpd(0.95, 0, 1, 0.2)
##What about the bivariate case? Just the same
y <- rbvgpd(100, model = "alog", alpha = 0.2, asCoef1 = 0.8, asCoef2 = 0.2, mar1 = c(0, 1, 0.2), mar2 = c(10, 1, 0.5))
##Evaluate the probability to not exceed (5,14)
pbvgpd(c(3,15), model = "alog", alpha = 0.2, asCoef1 = 0.8, asCoef2 = 0.2, mar1 = c(0, 1, 0.2), mar2 = c(10, 1, 0.5))
##Maximum likelihood estimate (threshold = 0):
mle <- fitgpd(x, 0)
##Probability Weighted Moments:
pwu <- fitgpd(x, 0, "pwmu")
##Maximum Goodness-of-Fit estimators:
adr <- fitgpd(x, 0, "mgf", stat = "ADR")
##Specifying a known parameter:
fitgpd(x, 0, "mple", shape = 0.2)
##Specifying starting values for numerical optimizations:
fitgpd(x, 0, "mdpd", start = list(scale = 1, shape = 0.2))
##Fit a bivariate GPD with a logistic dependence:
log <- fitbvgpd(y, c(0,10), "log")
##Generic function for the univariate and bivariate cases:
plot(mle); plot(log)
##Return level plots:
retlev(mle, npy = 2); retlev(log)
##Probability-Probability and Q-Q plots:
pp(mle); qq(mle)
##Plot the density:
dens(mle)
##Plot the Pickands' dependence function:
pickdep(log)
##Spectral density plot:
specdens(log)
##Profile Likelihood (quantiles):
confint(mle, prob = 0.95)
##Profile Likelihood (parameters):
confint(mle, "scale"); confint(mle, "shape")
|