## Garonne data. Use a "Rendata" object as 'x'. Historical data are used!
fit <- Renouv(x = Garonne, distname = "weibull", trace = 1,
main = "'Garonne' data")
summary(fit)
## generates a warning because of the ties
fit2 <- Renouv(x = Garonne, distname = "GPD",
jitter.KS = FALSE,
threshold = 2800, trace = 1,
main = "'Garonne' data with threshold = 2800 and GPD fit")
## use a numeric vector as 'x'
fit3 <-
Renouv(x = Garonne$OTdata$Flow,
threshold = 2500,
effDuration = 100,
distname = "GPD",
OTS.data = list(numeric(0), c(6800, 7200)),
OTS.effDuration = c(100, 150),
OTS.threshold = c(7000, 6000),
trace = 1,
main = "'Garonne' data with artificial \"OTS\" data")
## Add historical (fictive) data
fit4 <- Renouv(x = Garonne$OTdata$Flow,
threshold = 2500,
effDuration = 100,
distname = "weibull",
fixed.par.y = list(shape = 1.1),
OTS.data = list(numeric(0), c(6800, 7200)),
OTS.effDuration = c(100, 150),
OTS.threshold = c(7000, 6000),
trace = 0,
main = "'Garonne' data with artificial \"OTS\" data")
##============================================================================
## use the 'venice' dataset in a r-largest fit from the 'evd' package
##============================================================================
## transform data: each row is a block
MAX.data <- as.list(as.data.frame(t(venice)))
## remove the NA imposed by the rectangular matrix format
MAX.data <- lapply(MAX.data, function(x) x[!is.na(x)])
MAX.effDuration <- rep(1, length(MAX.data))
## fit a Renouv model with no OT data. The threshold
## must be in the support of the gev distribution
u <- 66
fit.gpd <- Renouv(x = NULL,
MAX.data = MAX.data,
MAX.effDuration = MAX.effDuration,
distname.y = "GPD",
threshold = u,
numDeriv = FALSE,
trace = 0,
plot = FALSE)
if (FALSE) {
require(ismev)
## compare with results from the ismev package
fit.gev <- rlarg.fit(venice)
est.gev <- fit.gev$mle
names(est.gev) <- c("loc", "scale", "shape")
## transform the 'gev' fit into a Ren parameter set.
cov.gev <- fit.gev$cov
rownames(cov.gev) <- colnames(cov.gev) <- c("loc", "scale", "shape")
trans <- gev2Ren(est.gev,
threshold = u,
vcovGev = cov.gev)
est <- cbind(ismev = trans, RenextLab = coef(fit.gpd))
colnames(est) <- c("ismev", "RenextLab")
print(est)
## fill a 3d array with the two gpd covariance matrices
cov2 <- attr(trans, "vcov")[c(1, 3, 4), c(1, 3, 4)]
## covariance
covs <-
array(dim = c(2, 3, 3),
dimnames = list(c("ismev", "RenextLab"),
colnames(fit.gpd$cov), colnames(fit.gpd$cov)))
covs["ismev", , ] <- cov2
covs["RenextLab", , ] <- fit.gpd$cov
print(covs)
}
Run the code above in your browser using DataLab