library(extRemes)
## Loading required package: Lmoments
## Loading required package: distillery
## Loading required package: car
## 
## Attaching package: 'extRemes'
## The following objects are masked from 'package:stats':
## 
##     qqnorm, qqplot
library(fitdistrplus)
## Loading required package: MASS
## Loading required package: survival
data("Potomac")
head(Potomac)
##   Year   Flow
## 1 1895  68500
## 2 1896  56000
## 3 1897 204000
## 4 1898 127000
## 5 1899 128000
## 6 1900  57700
dane <- Potomac$Flow


dopasuj <- function(dane){

model_GEV <- fevd(dane/10000, type="GEV" )
tmp <- summary(model_GEV); tmp$AIC
tmp <- as.numeric(tmp$AIC)

model_Weibull <- fitdist(dane/10000, "weibull", method = "mle")
model_Lnorm <- fitdist(dane/10000, "lnorm", method = "mle")
model_Gamma <- fitdist(dane/10000, "gamma")

c(model_Weibull$aic, model_Lnorm$aic, model_Gamma$aic, tmp)
}


wynik <- dopasuj(dane = dane)
## 
## fevd(x = dane/10000, type = "GEV")
## 
## [1] "Estimation Method used: MLE"
## 
## 
##  Negative Log-Likelihood Value:  332.1375 
## 
## 
##  Estimated parameters:
##  location     scale     shape 
## 8.7535770 4.2499288 0.1907679 
## 
##  Standard Error Estimates:
##   location      scale      shape 
## 0.46576676 0.36589034 0.07607097 
## 
##  Estimated parameter covariance matrix.
##             location        scale        shape
## location  0.21693867  0.094262079 -0.010576700
## scale     0.09426208  0.133875740 -0.001594657
## shape    -0.01057670 -0.001594657  0.005786793
## 
##  AIC = 670.2751 
## 
##  BIC = 678.2654
macierz <- data.frame(a=dane, b=dane)
wynik <- apply(X = macierz, MARGIN = 2, FUN = dopasuj)
## 
## fevd(x = dane/10000, type = "GEV")
## 
## [1] "Estimation Method used: MLE"
## 
## 
##  Negative Log-Likelihood Value:  332.1375 
## 
## 
##  Estimated parameters:
##  location     scale     shape 
## 8.7535770 4.2499288 0.1907679 
## 
##  Standard Error Estimates:
##   location      scale      shape 
## 0.46576676 0.36589034 0.07607097 
## 
##  Estimated parameter covariance matrix.
##             location        scale        shape
## location  0.21693867  0.094262079 -0.010576700
## scale     0.09426208  0.133875740 -0.001594657
## shape    -0.01057670 -0.001594657  0.005786793
## 
##  AIC = 670.2751 
## 
##  BIC = 678.2654 
## 
## fevd(x = dane/10000, type = "GEV")
## 
## [1] "Estimation Method used: MLE"
## 
## 
##  Negative Log-Likelihood Value:  332.1375 
## 
## 
##  Estimated parameters:
##  location     scale     shape 
## 8.7535770 4.2499288 0.1907679 
## 
##  Standard Error Estimates:
##   location      scale      shape 
## 0.46576676 0.36589034 0.07607097 
## 
##  Estimated parameter covariance matrix.
##             location        scale        shape
## location  0.21693867  0.094262079 -0.010576700
## scale     0.09426208  0.133875740 -0.001594657
## shape    -0.01057670 -0.001594657  0.005786793
## 
##  AIC = 670.2751 
## 
##  BIC = 678.2654
# library(readxl)
# read_excel(path = , sheet = ,)