## ---- fig.height=4, fig.width=4------------------------------------------
library(floodnetRfa)
## Extract the annual maximums
anData <- ExtractAmax(flow ~ date, flowStJohn, tol = 365)
## ----fig.height=4, fig.width=6-------------------------------------------
## Graph of the trend in annula maximums
plot(flow~date, anData)
fit <- with(anData, smooth.spline(date,flow))
lines(predict(fit), col = 'red', lwd = 2)
abline(h = mean(anData$flow), lty = 3, col = 'blue')
## Outcome of Mann-Kendall test
MKendall(anData$flow)
## ------------------------------------------------------------------------
fitMle <- FitAmax(anData$flow, 'gev', method = 'mle')
print(fitMle)
## ------------------------------------------------------------------------
## Fit GEV distribution using L-moments
fitLmm <-FitAmax(anData$flow, 'gev', method = 'lmom', varcov = FALSE)
## ------------------------------------------------------------------------
## Flood quantiles with uncertainty
predict(fitMle, q = c(.9,.99), se = TRUE, ci = 'delta', alpha = .1)
## ------------------------------------------------------------------------
out <- predict(fitLmm, q = c(.9,.99), ci = 'boot', nsim = 100, out.matrix = TRUE)
## Estimated Flood quantiles
print(out$pred)
## Bootstraps sample of model parameters
out$para[1:3,]
## Bootstraps sample of flood quantiles
print(out$qua[1:3,])
## ---- fig.height= 4,fig.width=6------------------------------------------
## Return level plot
plot(fitMle, ci = TRUE)
## ------------------------------------------------------------------------
## Anderson-Darling goodness of fit test
GofTest(fitLmm, nsim = 500)
## ------------------------------------------------------------------------
##
FitAmax(anData$flow, 'ln3', method = 'lmom', varcov = FALSE)
## ------------------------------------------------------------------------
## Function that compute the AIC for a given distribution
FAIC <- function(d)
AIC(FitAmax(anData$flow, d, method = 'mle', varcov = FALSE))
## AIC of all distribution
sapply(c('gev','glo','ln3','pe3'), FAIC)
## Automatic selection of the distribution
FitAmax.auto(anData$flow, method = 'mle', tol.gev = 2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.