extreme R package for Flood frequency analysis?

167 Views Asked by At

Below is my code where i am trying to estimate frequency of DF data.frame for various return period. I am getting error as i estimate return_quantiles. Any thoughts how to fix this?

library(extRemes)
library(tidyverse)

DF <- data.frame(Date = seq(as.Date("1980-01-01"), 
                            to = as.Date("2020-12-31"), 
                            by = "day"), 
                 A1 = runif(14976,1,500))

# Extract the annual maximum values
annual_max <- aggregate(A1 ~ year(Date), data = DF, FUN = max)
max_values <- annual_max$A1


gev_fit <- extRemes::fevd(max_values, type = "GEV")


return_period <- c(2, 5, 10, 20, 50, 100)  # Update with desired return periods
return_quantiles <- extRemes::qgev(return_period, gev_fit)

# Print the estimated return period and corresponding quantile
for (i in 1:length(return_period)) {
  print(paste("Return Period:", return_period[i], "years"))
  print(paste("Estimated Quantile:", return_quantiles[i]))
  print("---------------")
}
1

There are 1 best solutions below

0
Asif Iqbal Shah On
# maximum-likelihood fitting of the GEV distribution
fit_mle <- fevd(discharge, method = "MLE", type="GEV")
# diagnostic plots
plot(fit_mle)
# return levels:
rl_mle <- return.level(fit_mle, conf = 0.05, return.period= c(2, 5, 10, 20, 50, 100))

check whether it works