# NOT RUN {
# We need the fExtremes package
got_fExtremes <- requireNamespace("fExtremes", quietly = TRUE)
if (got_fExtremes) {
library(fExtremes)
# GEV
# An example from the fExtremes::gevFit documentation
set.seed(4082019)
x <- gevSim(model = list(xi=0.25, mu=0, beta=1), n = 1000)
# Fit GEV distribution by maximum likelihood estimation
fit <- gevFit(x)
adj_fit <- alogLik(fit)
summary(adj_fit)
# GP
# An example from the fExtremes::gpdFit documentation
# Simulate GP data
x <- gpdSim(model = list(xi = 0.25, mu = 0, beta = 1), n = 1000)
# Fit GP distribution by maximum likelihood estimation
fit <- gpdFit(x, u = min(x))
adj_fit <- alogLik(fit)
summary(adj_fit)
}
# }
Run the code above in your browser using DataLab