I am trying to calculate return levels for maximum daily precipitation using a set of stations. Data are stored in three columns - station, year, precip. The aim is to calculate return levels (i.e. the 2, 5, 10, 20, 25, 50, 100 year event) for daily precipitation.
I have already fitted best distribution using nsRFA package. It seem that GEV GPA and GLO are the distributions that fit the data the best. Using chatGPT I managed to create a working code to calculate return levels for stations with fitted GEV distribution. It uses extREMES package, but I didnt have any luck to code a code that will wok for GPA or GLO. I found some possible methods online but I am not able to fit them to my needs with my very poor coding skills. Is it possible in extremes or different package is needed.
Thanks for help.
My code for GEV looks like this:
# Load necessary packageslibrary(extRemes)library(dplyr)library(tidyr)# Read data from the CSV filedata <- read.csv("precip_GEV.csv")datacalculate_return_levels <- function(station_data) { gev_fit <- fevd(station_data$precip, threshold = NULL, type = "GEV", method = "MLE") return_levels <- return.level(gev_fit, return.period = c(2, 3, 4, 5, 10, 20, 25, 50, 100, 200)) return(return_levels)}return_levels <- data %>% group_by(station) %>% summarize(return_levels = list(calculate_return_levels(data[data$station == first(station),])))return_levels <- return_levels %>% unnest(return_levels)print(return_levels, n = 20)write.csv(return_levels, "return_levels_table_GEV.csv", row.names = FALSE)