par(mfrow=c(2,1))
x = rbeta(1000, shape1 = 0.5, shape2 = 2)
xx = seq(-0.1, 2, 0.01)
y = dbeta(xx, shape1 = 0.5, shape2 = 2)
# Bulk model base tail fraction
fit = fbetagpd(x, phiu = TRUE, std.err = FALSE)
hist(x, breaks = 100, freq = FALSE, xlim = c(-0.1, 2))
lines(xx, y)
lines(xx, dbetagpd(xx, bshape1 = fit$bshape1, bshape2 = fit$bshape2, u = fit$u,
sigmau = fit$sigmau, xi = fit$xi, phiu = TRUE), col="red")
abline(v = fit$u)
# Parameterised tail fraction
fit2 = fbetagpd(x, phiu = FALSE, std.err = FALSE)
plot(xx, y, type = "l")
lines(xx, dbetagpd(xx, bshape1 = fit$bshape1, bshape2 = fit$bshape2,, u = fit$u,
sigmau = fit$sigmau, xi = fit$xi, phiu = TRUE), col="red")
lines(xx, dbetagpd(xx, bshape1 = fit2$bshape1, bshape2 = fit2$bshape2,, u = fit2$u,
sigmau = fit2$sigmau, 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