'Fit GEV distribution in R

I try to fit my precipitation data to gev distribution by using "fitdist" function. Could someone tell me how I can do it? I can run other distributions, but it always shows me an error when I type in distribution.name "gev"

Total99 <- subset(data2, Precip_total>quantile(Precip_total, 0.99))`
Total99_60s<-subset(Total99,year>1960)
descdist(Total99_60s$Precip_total,discrete=FALSE)
fg<-fitdist(Total99_60s$Precip_total,"gamma")

fln<-fitdist(Total99_60s$Precip_total,"lnorm")
fw<-fitdist(Total99_60s$Precip_total,"weibull")
plot.legend<-c("Weibull","lognormal","gamma")
denscomp(list(fw,fln,fg),legendtext = plot.legend)

qqcomp(list(fw, fln, fg), legendtext = plot.legend)
cdfcomp(list(fw, fln, fg), legendtext = plot.legend)
ppcomp(list(fw, fln, fg), legendtext = plot.legend)
#gev#
fitgev<-fitdist(Total99_60s$Precip_total,"gev"
Error in computing default starting values.
Error in manageparam(start.arg = start, fix.arg = fix.arg, obs = data,  : 
  Error in start.arg.default(obs, distname) : 
  Unknown starting values for distribution gev.
library(lmomco)
lmom<-lmoms(Total99_60s$Precip_total,nmom=5)
para<-pargev(lmom,checklmom=TRUE)
dgev<-pdfgev
pgev<-cdfgev
dgev <- function(x,xi,alpha,kappa) {
  pdfgev(x,list(type="gev",para=c(xi,alpha,kappa),source="pargev"))
}
fitgev<-fitdist(Total99_60s$Precip_total,"gev",start=para[[2]])
Error in manageparam(start.arg = start, fix.arg = fix.arg, obs = data,  : 
  Wrong type of argument for start

How can I find a good parameter?



Solution 1:[1]

The error message is telling you that you need to provide the start parameter in the call of fitdist when method is "gev". Try this:

start <- list(loc = 0.0, scale = 1.0, shape = 1.0)
fitgev <- fitdist(Total99_60s$Precip_total, "gev", start = start)

You might have to provide different numbers in start. Ideally these numbers should be a "pretty good" guess of the parameters.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Warren Weckesser