par(mfrow=c(2,1))
x = rgamma(1000, shape = 2)
xx = seq(-1, 10, 0.01)
y = dgamma(xx, shape = 2)
# Bulk model base tail fraction
fit = fgammagpdcon(x, phiu = TRUE, std.err = FALSE)
hist(x, breaks = 100, freq = FALSE, xlim = c(-1, 10))
lines(xx, y)
lines(xx, dgammagpdcon(xx, gshape = fit$gshape, gscale = fit$gscale, u = fit$u,
xi = fit$xi, phiu = TRUE), col="red")
abline(v = fit$u)
# Parameterised tail fraction
fit2 = fgammagpdcon(x, phiu = FALSE, std.err = FALSE)
plot(xx, y, type = "l")
lines(xx, dgammagpdcon(xx, gshape = fit$gshape, gscale = fit$gscale, u = fit$u,
xi = fit$xi, phiu = TRUE), col="red")
lines(xx, dgammagpdcon(xx, gshape = fit2$gshape, gscale = fit2$gscale, u = fit2$u,
xi = fit2$xi, phiu = fit2$phiu), col="blue")
abline(v = fit$u, col = "red")
abline(v = fit2$u, col = "blue")
legend("topright", c("True Density","Bulk Tail Fraction","Parameterised Tail Fraction"),
col=c("black", "red", "blue"), lty = 1)
Run the code above in your browser using DataLab