library(data.table) library(ggplot2) library(evdflex) library(evd)
The following example data will help to demonstrate the usage of this package.
data <- fread("../tests/testthat/testData.txt") data <- data[, 1 : 4, with = FALSE] setnames(data, c("Station", "m10", "m20", "Date")) setcolorder(data, c("Date", "Station", "m10", "m20")) invisible(data[, Date := as.Date(paste0(Date), "%Y%m%d")]) setkey(data, Date, Station)
knitr::kable(head(data)) knitr::kable(tail(data))
fpar <- function(p, xpar) { loc <- p[1] scale <- p[2] shape <- p[3] list(loc = loc, scale = scale, shape = shape) }
Fit for fixed 10 min data and for arbitrary 10 min data using the range likelihood.
fitSimple <- FitGevFlex(data[, m10], start = c(7, 2.5, 0.05), fpar = fpar) fitGrouped <- FitGevFlex(data[, .(m10, m20)], start = c(7, 2.5, 0.05), fpar = fpar, likelihood = "grouped")
setkey(data, m10) invisible(data[, x := qgev((1:.N)/(.N+1))]) invisible(data[, fitSimple := qgev((1:.N)/(.N+1), loc = fitSimple$estimate[1], scale = fitSimple$estimate[2], shape = fitSimple$estimate[3] )]) invisible(data[, fitGrouped := qgev((1:.N)/(.N+1), loc = fitGrouped$estimate[1], scale = fitGrouped$estimate[2], shape = fitGrouped$estimate[3] )]) ggplot(data, aes(y = m10, x = x)) + geom_point() + geom_point(aes(y = m20), shape = 2) + geom_line(aes(y = fitSimple), lty = 2, col = 2) + geom_line(aes(y = fitGrouped), lty = 2, col = 4)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.