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("---------------")
}
check whether it works