1
votes

I am now using the extremes package to fit a generalized extreme value (GEV) distribution, and I want to use the Kolmogorov-Smirnov test to estimate the goodness of fit, but get the following error:

library(extRemes)
library(eva)
data("PORTw", package = "extRemes")
fit1 <- fevd(TMX1, PORTw, units = "deg C")
ks.test(PORTw$TMX1,"pgev",fit1$results$par[[1]],fit1$results$par[[2]],shape=fit1$results$par[[3]])

`Warning message:
In ks.test(PORTw$TMX1, "pgev", fit1$results$par[[1]], fit1$results$par[[2]],  :
  ties should not be present for the Kolmogorov-Smirnov test`

So, my question is, how to perform a Kolmogorov-Smirnov test for the GEV fit with ties? Or, is there any other goodness of fit test for fitting a distribution available in R? Thanks a lot.

2
You "wonder how to do this this == _what_? in R". You cannot possibly be asking how to do a KS test in R, right? At least not without doing your own search, right?IRTFM
Sorry for the vague question and I have edited it with more information.Yang Yang
That was only a warning. You should have seen at the console (but failed to copy the output) results from a KS-test. Again ... can you explain in a complete natural language manner what the statistical question really is? Or why you think the output is incorrect? Perhaps you need to read some statistical theory that will explain why ties are not expected with a KS test? Or post on CrossValidated.com with a question about the underlying theory and what degree of worry to apply to this event?IRTFM
You might want to actually look at your data: table(PORTw$TMX1)IRTFM
Thanks. I do not notice that this is only a warning and I can see the results. The question is, is there any statistical difference between fit1 and a theoretical GEV distribution? The aim is to evaluate the goodness of fit for the fit1model.Yang Yang

2 Answers

1
votes

I recommend the "EnvStats" package. You will have more versatility for goodness of fit test:

library(EnvStats)
# For a data set called X
X <- rgevd(500)
# Generalized Extreme Value (EnvStats)
egevd(X, method = "mle")# Maximum likelihood
# Goodness of fit test
gofTest(X, distribution = "gev",test = "ks")#Kolmogorov-Smirnov
gofTest(X, distribution = "gev",test = "chisq")#Chi-Squared
1
votes

"EnvStats" package.

library(EnvStats)
set.seed(250) 
dat <- rpareto(30, location = 1, shape = 1)  
head(dat)
epareto(dat)
gofTest(dat, distribution = "pareto",test = "ks")#Kolmogorov-Smirnov
plot.gof(gofTest(dat, distribution = "pareto",test = "ks"))#Plot