# Simulated data from an exponential distribution (xi=0)
y = rexp(n=3000, rate=2)
fit = vglm(y ~ 1, gpd(threshold=0.5), trace=TRUE)
fitted(fit)[1:5,]
coef(fit, matrix=TRUE) # xi should be close to 0
Coef(fit)
summary(fit)
yt = y[y>fit@extra$threshold] # Note the threshold is stored here
all.equal(c(yt), c(fit@y)) # TRUE
# Check the 90 percentile
i = yt < fitted(fit)[1,"90%"]
100*table(i)/sum(table(i)) # Should be 90%
# Check the 95 percentile
i = yt < fitted(fit)[1,"95%"]
100*table(i)/sum(table(i)) # Should be 95%
plot(yt, col="blue", las=1, main="Fitted 90% and 95% quantiles")
matlines(1:length(yt), fitted(fit), lty=2:3, lwd=2)
# Another example
nn = 2000; threshold = 0; x = runif(nn)
xi = exp(-0.8)-0.5
y = rgpd(nn, scale=exp(1+0.2*x), shape=xi)
fit = vglm(y ~ x, gpd(threshold), trace=TRUE)
Coef(fit)
coef(fit, matrix=TRUE)
Run the code above in your browser using DataLab